Merge pull request #26174 from edx/lint-amnesty
Applied pylint-amnesty to lms/djangoapps/badges
This commit is contained in:
@@ -3,7 +3,7 @@ Admin registration for Badge Models
|
||||
"""
|
||||
|
||||
|
||||
from config_models.admin import ConfigurationModelAdmin
|
||||
from config_models.admin import ConfigurationModelAdmin # lint-amnesty, pylint: disable=import-error
|
||||
from django.contrib import admin
|
||||
|
||||
from lms.djangoapps.badges.models import BadgeClass, CourseCompleteImageConfiguration, CourseEventBadgesConfiguration
|
||||
|
||||
@@ -3,7 +3,7 @@ Serializers for Badges
|
||||
"""
|
||||
|
||||
|
||||
from rest_framework import serializers
|
||||
from rest_framework import serializers # lint-amnesty, pylint: disable=import-error
|
||||
|
||||
from lms.djangoapps.badges.models import BadgeAssertion, BadgeClass
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ Tests for the badges API views.
|
||||
|
||||
|
||||
import six
|
||||
from ddt import data, ddt, unpack
|
||||
from ddt import data, ddt, unpack # lint-amnesty, pylint: disable=import-error
|
||||
from django.conf import settings
|
||||
from django.test.utils import override_settings
|
||||
from six.moves import range
|
||||
@@ -13,8 +13,8 @@ from lms.djangoapps.badges.tests.factories import BadgeAssertionFactory, BadgeCl
|
||||
from openedx.core.lib.api.test_utils import ApiTestCase
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
from common.djangoapps.util.testing import UrlResetMixin
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase # lint-amnesty, pylint: disable=import-error, wrong-import-order
|
||||
from xmodule.modulestore.tests.factories import CourseFactory # lint-amnesty, pylint: disable=import-error, wrong-import-order
|
||||
|
||||
FEATURES_WITH_BADGES_ENABLED = settings.FEATURES.copy()
|
||||
FEATURES_WITH_BADGES_ENABLED['ENABLE_OPENBADGES'] = True
|
||||
@@ -27,7 +27,7 @@ class UserAssertionTestCase(UrlResetMixin, ModuleStoreTestCase, ApiTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(UserAssertionTestCase, self).setUp()
|
||||
super(UserAssertionTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.course = CourseFactory.create()
|
||||
self.user = UserFactory.create()
|
||||
# Password defined by factory.
|
||||
|
||||
@@ -3,12 +3,12 @@ API views for badges
|
||||
"""
|
||||
|
||||
|
||||
from edx_rest_framework_extensions.auth.session.authentication import SessionAuthenticationAllowInactiveUser
|
||||
from opaque_keys import InvalidKeyError
|
||||
from opaque_keys.edx.django.models import CourseKeyField
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from rest_framework import generics
|
||||
from rest_framework.exceptions import APIException
|
||||
from edx_rest_framework_extensions.auth.session.authentication import SessionAuthenticationAllowInactiveUser # lint-amnesty, pylint: disable=import-error
|
||||
from opaque_keys import InvalidKeyError # lint-amnesty, pylint: disable=import-error
|
||||
from opaque_keys.edx.django.models import CourseKeyField # lint-amnesty, pylint: disable=import-error
|
||||
from opaque_keys.edx.keys import CourseKey # lint-amnesty, pylint: disable=import-error
|
||||
from rest_framework import generics # lint-amnesty, pylint: disable=import-error
|
||||
from rest_framework.exceptions import APIException # lint-amnesty, pylint: disable=import-error
|
||||
|
||||
from lms.djangoapps.badges.models import BadgeAssertion
|
||||
from openedx.core.djangoapps.user_api.permissions import is_field_shared_factory
|
||||
@@ -119,7 +119,7 @@ class UserBadgeAssertions(generics.ListAPIView):
|
||||
try:
|
||||
course_id = CourseKey.from_string(provided_course_id)
|
||||
except InvalidKeyError:
|
||||
raise InvalidCourseKeyError
|
||||
raise InvalidCourseKeyError # lint-amnesty, pylint: disable=raise-missing-from
|
||||
elif 'slug' not in self.request.query_params:
|
||||
# Need to get all badges for the user.
|
||||
course_id = None
|
||||
|
||||
@@ -7,13 +7,13 @@ import hashlib
|
||||
import logging
|
||||
import mimetypes
|
||||
|
||||
import requests
|
||||
import requests # lint-amnesty, pylint: disable=import-error
|
||||
import six
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from eventtracking import tracker
|
||||
from lazy import lazy
|
||||
from requests.packages.urllib3.exceptions import HTTPError
|
||||
from eventtracking import tracker # lint-amnesty, pylint: disable=import-error
|
||||
from lazy import lazy # lint-amnesty, pylint: disable=no-name-in-module
|
||||
from requests.packages.urllib3.exceptions import HTTPError # lint-amnesty, pylint: disable=import-error
|
||||
|
||||
from lms.djangoapps.badges.backends.base import BadgeBackend
|
||||
from lms.djangoapps.badges.models import BadgeAssertion
|
||||
@@ -29,7 +29,7 @@ class BadgrBackend(BadgeBackend):
|
||||
badges = []
|
||||
|
||||
def __init__(self):
|
||||
super(BadgrBackend, self).__init__()
|
||||
super(BadgrBackend, self).__init__() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
if not settings.BADGR_API_TOKEN:
|
||||
raise ImproperlyConfigured("BADGR_API_TOKEN not set.")
|
||||
|
||||
|
||||
@@ -5,12 +5,12 @@ Tests for BadgrBackend
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
import ddt
|
||||
import ddt # lint-amnesty, pylint: disable=import-error
|
||||
import six
|
||||
from django.db.models.fields.files import ImageFieldFile
|
||||
from django.test.utils import override_settings
|
||||
from lazy.lazy import lazy
|
||||
from mock import Mock, call, patch
|
||||
from lazy.lazy import lazy # lint-amnesty, pylint: disable=import-error, no-name-in-module
|
||||
from mock import Mock, call, patch # lint-amnesty, pylint: disable=import-error
|
||||
|
||||
from lms.djangoapps.badges.backends.badgr import BadgrBackend
|
||||
from lms.djangoapps.badges.models import BadgeAssertion
|
||||
@@ -18,8 +18,8 @@ from lms.djangoapps.badges.tests.factories import BadgeClassFactory
|
||||
from openedx.core.lib.tests.assertions.events import assert_event_matches
|
||||
from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory
|
||||
from common.djangoapps.track.tests import EventTrackingTestCase
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase # lint-amnesty, pylint: disable=import-error, wrong-import-order
|
||||
from xmodule.modulestore.tests.factories import CourseFactory # lint-amnesty, pylint: disable=import-error, wrong-import-order
|
||||
|
||||
BADGR_SETTINGS = {
|
||||
'BADGR_API_TOKEN': '12345',
|
||||
@@ -43,7 +43,7 @@ class BadgrBackendTestCase(ModuleStoreTestCase, EventTrackingTestCase):
|
||||
"""
|
||||
Create a course and user to test with.
|
||||
"""
|
||||
super(BadgrBackendTestCase, self).setUp()
|
||||
super(BadgrBackendTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
# Need key to be deterministic to test slugs.
|
||||
self.course = CourseFactory.create(
|
||||
org='edX', course='course_test', run='test_run', display_name='Badged',
|
||||
@@ -72,14 +72,14 @@ class BadgrBackendTestCase(ModuleStoreTestCase, EventTrackingTestCase):
|
||||
"""
|
||||
Make sure the handler generates the correct URLs for different API tasks.
|
||||
"""
|
||||
self.assertEqual(self.handler._base_url, 'https://example.com/v1/issuer/issuers/test-issuer')
|
||||
self.assertEqual(self.handler._badge_create_url, 'https://example.com/v1/issuer/issuers/test-issuer/badges')
|
||||
self.assertEqual(self.handler._base_url, 'https://example.com/v1/issuer/issuers/test-issuer') # lint-amnesty, pylint: disable=no-member
|
||||
self.assertEqual(self.handler._badge_create_url, 'https://example.com/v1/issuer/issuers/test-issuer/badges') # lint-amnesty, pylint: disable=no-member
|
||||
self.assertEqual(
|
||||
self.handler._badge_url('test_slug_here'),
|
||||
self.handler._badge_url('test_slug_here'), # lint-amnesty, pylint: disable=no-member
|
||||
'https://example.com/v1/issuer/issuers/test-issuer/badges/test_slug_here'
|
||||
)
|
||||
self.assertEqual(
|
||||
self.handler._assertion_url('another_test_slug'),
|
||||
self.handler._assertion_url('another_test_slug'), # lint-amnesty, pylint: disable=no-member
|
||||
'https://example.com/v1/issuer/issuers/test-issuer/badges/another_test_slug/assertions'
|
||||
)
|
||||
|
||||
@@ -93,7 +93,7 @@ class BadgrBackendTestCase(ModuleStoreTestCase, EventTrackingTestCase):
|
||||
"""
|
||||
Check to make sure the handler generates appropriate HTTP headers.
|
||||
"""
|
||||
self.check_headers(self.handler._get_headers())
|
||||
self.check_headers(self.handler._get_headers()) # lint-amnesty, pylint: disable=no-member
|
||||
|
||||
@patch('requests.post')
|
||||
def test_create_badge(self, post):
|
||||
@@ -123,7 +123,7 @@ class BadgrBackendTestCase(ModuleStoreTestCase, EventTrackingTestCase):
|
||||
"""
|
||||
BadgrBackend.badges.append(EXAMPLE_SLUG)
|
||||
self.handler._create_badge = Mock()
|
||||
self.handler._ensure_badge_created(self.badge_class)
|
||||
self.handler._ensure_badge_created(self.badge_class) # lint-amnesty, pylint: disable=no-member
|
||||
self.assertFalse(self.handler._create_badge.called)
|
||||
|
||||
@ddt.unpack
|
||||
@@ -133,7 +133,7 @@ class BadgrBackendTestCase(ModuleStoreTestCase, EventTrackingTestCase):
|
||||
('no_course_badge_class', 'test_componenttest_slug')
|
||||
)
|
||||
def test_slugs(self, badge_class_type, slug):
|
||||
self.assertEqual(self.handler._slugify(getattr(self, badge_class_type)), slug)
|
||||
self.assertEqual(self.handler._slugify(getattr(self, badge_class_type)), slug) # lint-amnesty, pylint: disable=no-member
|
||||
|
||||
@patch('requests.get')
|
||||
def test_ensure_badge_created_checks(self, get):
|
||||
@@ -142,7 +142,7 @@ class BadgrBackendTestCase(ModuleStoreTestCase, EventTrackingTestCase):
|
||||
get.return_value = response
|
||||
self.assertNotIn('test_componenttest_slug', BadgrBackend.badges)
|
||||
self.handler._create_badge = Mock()
|
||||
self.handler._ensure_badge_created(self.badge_class)
|
||||
self.handler._ensure_badge_created(self.badge_class) # lint-amnesty, pylint: disable=no-member
|
||||
self.assertTrue(get.called)
|
||||
args, kwargs = get.call_args
|
||||
self.assertEqual(
|
||||
@@ -161,7 +161,7 @@ class BadgrBackendTestCase(ModuleStoreTestCase, EventTrackingTestCase):
|
||||
get.return_value = response
|
||||
self.assertNotIn(EXAMPLE_SLUG, BadgrBackend.badges)
|
||||
self.handler._create_badge = Mock()
|
||||
self.handler._ensure_badge_created(self.badge_class)
|
||||
self.handler._ensure_badge_created(self.badge_class) # lint-amnesty, pylint: disable=no-member
|
||||
self.assertTrue(self.handler._create_badge.called)
|
||||
self.assertEqual(self.handler._create_badge.call_args, call(self.badge_class))
|
||||
self.assertIn(EXAMPLE_SLUG, BadgrBackend.badges)
|
||||
@@ -178,7 +178,7 @@ class BadgrBackendTestCase(ModuleStoreTestCase, EventTrackingTestCase):
|
||||
response.json.return_value = result
|
||||
post.return_value = response
|
||||
self.recreate_tracker()
|
||||
self.handler._create_assertion(self.badge_class, self.user, 'https://example.com/irrefutable_proof')
|
||||
self.handler._create_assertion(self.badge_class, self.user, 'https://example.com/irrefutable_proof') # lint-amnesty, pylint: disable=no-member
|
||||
args, kwargs = post.call_args
|
||||
self.assertEqual(
|
||||
args[0],
|
||||
|
||||
@@ -14,7 +14,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from lms.djangoapps.badges.models import BadgeAssertion, BadgeClass, CourseCompleteImageConfiguration
|
||||
from lms.djangoapps.badges.utils import requires_badges_enabled, site_prefix
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=import-error, wrong-import-order
|
||||
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -7,8 +7,8 @@ from uuid import uuid4
|
||||
from lms.djangoapps.badges.events import course_complete
|
||||
from lms.djangoapps.certificates.models import GeneratedCertificate
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase # lint-amnesty, pylint: disable=import-error, wrong-import-order
|
||||
from xmodule.modulestore.tests.factories import CourseFactory # lint-amnesty, pylint: disable=import-error, wrong-import-order
|
||||
|
||||
|
||||
class CourseCompleteTestCase(ModuleStoreTestCase):
|
||||
@@ -17,7 +17,7 @@ class CourseCompleteTestCase(ModuleStoreTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(CourseCompleteTestCase, self).setUp()
|
||||
super(CourseCompleteTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
# Need key to be deterministic to test slugs.
|
||||
self.course = CourseFactory.create(
|
||||
org='edX', course='course_test', run='test_run', display_name='Badged',
|
||||
|
||||
@@ -5,17 +5,17 @@ Tests the course meta badging events
|
||||
|
||||
import six
|
||||
from six.moves import range, zip
|
||||
from ddt import data, ddt, unpack
|
||||
from ddt import data, ddt, unpack # lint-amnesty, pylint: disable=import-error
|
||||
from django.conf import settings
|
||||
from django.test.utils import override_settings
|
||||
from mock import patch
|
||||
from mock import patch # lint-amnesty, pylint: disable=import-error
|
||||
|
||||
from lms.djangoapps.badges.tests.factories import CourseEventBadgesConfigurationFactory, RandomBadgeClassFactory
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses, GeneratedCertificate
|
||||
from common.djangoapps.student.models import CourseEnrollment
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase # lint-amnesty, pylint: disable=import-error, wrong-import-order
|
||||
from xmodule.modulestore.tests.factories import CourseFactory # lint-amnesty, pylint: disable=import-error, wrong-import-order
|
||||
|
||||
|
||||
@ddt
|
||||
@@ -27,7 +27,7 @@ class CourseEnrollmentBadgeTest(ModuleStoreTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(CourseEnrollmentBadgeTest, self).setUp()
|
||||
super(CourseEnrollmentBadgeTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.badge_classes = [
|
||||
RandomBadgeClassFactory(
|
||||
issuing_component='openedx__course'
|
||||
@@ -77,7 +77,7 @@ class CourseCompletionBadgeTest(ModuleStoreTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(CourseCompletionBadgeTest, self).setUp()
|
||||
super(CourseCompletionBadgeTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.badge_classes = [
|
||||
RandomBadgeClassFactory(
|
||||
issuing_component='openedx__course'
|
||||
@@ -131,7 +131,7 @@ class CourseGroupBadgeTest(ModuleStoreTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(CourseGroupBadgeTest, self).setUp()
|
||||
super(CourseGroupBadgeTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.badge_classes = [
|
||||
RandomBadgeClassFactory(
|
||||
issuing_component='openedx__course'
|
||||
|
||||
@@ -6,23 +6,23 @@ Database models for the badges app
|
||||
from importlib import import_module
|
||||
|
||||
import six
|
||||
from config_models.models import ConfigurationModel
|
||||
from config_models.models import ConfigurationModel # lint-amnesty, pylint: disable=import-error
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db import models
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.encoding import python_2_unicode_compatible # lint-amnesty, pylint: disable=no-name-in-module
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from jsonfield import JSONField
|
||||
from lazy import lazy
|
||||
from model_utils.models import TimeStampedModel
|
||||
from opaque_keys import InvalidKeyError
|
||||
from opaque_keys.edx.django.models import CourseKeyField
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from jsonfield import JSONField # lint-amnesty, pylint: disable=import-error
|
||||
from lazy import lazy # lint-amnesty, pylint: disable=no-name-in-module
|
||||
from model_utils.models import TimeStampedModel # lint-amnesty, pylint: disable=import-error
|
||||
from opaque_keys import InvalidKeyError # lint-amnesty, pylint: disable=import-error
|
||||
from opaque_keys.edx.django.models import CourseKeyField # lint-amnesty, pylint: disable=import-error
|
||||
from opaque_keys.edx.keys import CourseKey # lint-amnesty, pylint: disable=import-error
|
||||
|
||||
from lms.djangoapps.badges.utils import deserialize_count_specs
|
||||
from openedx.core.djangolib.markup import HTML, Text
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=import-error, wrong-import-order
|
||||
|
||||
|
||||
def validate_badge_image(image):
|
||||
@@ -66,7 +66,7 @@ class BadgeClass(models.Model):
|
||||
mode = models.CharField(max_length=100, default=u'', blank=True)
|
||||
image = models.ImageField(upload_to=u'badge_classes', validators=[validate_badge_image])
|
||||
|
||||
def __str__(self):
|
||||
def __str__(self): # lint-amnesty, pylint: disable=invalid-str-returned
|
||||
return HTML(u"<Badge '{slug}' for '{issuing_component}'>").format(
|
||||
slug=HTML(self.slug), issuing_component=HTML(self.issuing_component)
|
||||
)
|
||||
@@ -129,15 +129,15 @@ class BadgeClass(models.Model):
|
||||
"""
|
||||
Contacts the backend to have a badge assertion created for this badge class for this user.
|
||||
"""
|
||||
return self.backend.award(self, user, evidence_url=evidence_url)
|
||||
return self.backend.award(self, user, evidence_url=evidence_url) # lint-amnesty, pylint: disable=no-member
|
||||
|
||||
def save(self, **kwargs):
|
||||
def save(self, **kwargs): # lint-amnesty, pylint: disable=arguments-differ
|
||||
"""
|
||||
Slugs must always be lowercase.
|
||||
"""
|
||||
self.slug = self.slug and self.slug.lower()
|
||||
self.issuing_component = self.issuing_component and self.issuing_component.lower()
|
||||
super(BadgeClass, self).save(**kwargs)
|
||||
super(BadgeClass, self).save(**kwargs) # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
class Meta(object):
|
||||
app_label = "badges"
|
||||
@@ -159,7 +159,7 @@ class BadgeAssertion(TimeStampedModel):
|
||||
image_url = models.URLField()
|
||||
assertion_url = models.URLField()
|
||||
|
||||
def __str__(self):
|
||||
def __str__(self): # lint-amnesty, pylint: disable=invalid-str-returned
|
||||
return HTML(u"<{username} Badge Assertion for {slug} for {issuing_component}").format(
|
||||
username=HTML(self.user.username),
|
||||
slug=HTML(self.badge_class.slug),
|
||||
@@ -211,7 +211,7 @@ class CourseCompleteImageConfiguration(models.Model):
|
||||
default=False,
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
def __str__(self): # lint-amnesty, pylint: disable=invalid-str-returned
|
||||
return HTML(u"<CourseCompleteImageConfiguration for '{mode}'{default}>").format(
|
||||
mode=HTML(self.mode),
|
||||
default=HTML(u" (default)") if self.default else HTML(u'')
|
||||
@@ -273,7 +273,7 @@ class CourseEventBadgesConfiguration(ConfigurationModel):
|
||||
)
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
def __str__(self): # lint-amnesty, pylint: disable=invalid-str-returned
|
||||
return HTML(u"<CourseEventBadgesConfiguration ({})>").format(
|
||||
Text(u"Enabled") if self.enabled else Text(u"Disabled")
|
||||
)
|
||||
|
||||
@@ -5,12 +5,12 @@ Factories for Badge tests
|
||||
|
||||
from random import random
|
||||
|
||||
import factory
|
||||
import factory # lint-amnesty, pylint: disable=import-error
|
||||
from django.core.files.base import ContentFile
|
||||
from factory import DjangoModelFactory
|
||||
from factory.django import ImageField
|
||||
from factory import DjangoModelFactory # lint-amnesty, pylint: disable=import-error
|
||||
from factory.django import ImageField # lint-amnesty, pylint: disable=import-error
|
||||
|
||||
from lms.djangoapps.badges.models import BadgeAssertion, BadgeClass, CourseCompleteImageConfiguration, CourseEventBadgesConfiguration
|
||||
from lms.djangoapps.badges.models import BadgeAssertion, BadgeClass, CourseCompleteImageConfiguration, CourseEventBadgesConfiguration # lint-amnesty, pylint: disable=line-too-long
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ from django.core.files.storage import default_storage
|
||||
from django.db.utils import IntegrityError
|
||||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
from mock import Mock, patch
|
||||
from path import Path
|
||||
from mock import Mock, patch # lint-amnesty, pylint: disable=import-error
|
||||
from path import Path # lint-amnesty, pylint: disable=import-error
|
||||
from six.moves import range
|
||||
|
||||
from lms.djangoapps.badges.models import (
|
||||
@@ -23,15 +23,15 @@ from lms.djangoapps.badges.models import (
|
||||
from lms.djangoapps.badges.tests.factories import BadgeAssertionFactory, BadgeClassFactory, RandomBadgeClassFactory
|
||||
from lms.djangoapps.certificates.tests.test_models import TEST_DATA_ROOT
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase # lint-amnesty, pylint: disable=import-error, wrong-import-order
|
||||
from xmodule.modulestore.tests.factories import CourseFactory # lint-amnesty, pylint: disable=import-error, wrong-import-order
|
||||
|
||||
|
||||
def get_image(name):
|
||||
"""
|
||||
Get one of the test images from the test data directory.
|
||||
"""
|
||||
return ImageFile(open(TEST_DATA_ROOT / 'badges' / name + '.png', mode='rb')) # pylint: disable=open-builtin
|
||||
return ImageFile(open(TEST_DATA_ROOT / 'badges' / name + '.png', mode='rb')) # lint-amnesty, pylint: disable=bad-option-value, open-builtin
|
||||
|
||||
|
||||
@override_settings(MEDIA_ROOT=TEST_DATA_ROOT)
|
||||
@@ -40,7 +40,7 @@ class BadgeImageConfigurationTest(TestCase):
|
||||
Test the validation features of BadgeImageConfiguration.
|
||||
"""
|
||||
|
||||
def tearDown(self):
|
||||
def tearDown(self): # lint-amnesty, pylint: disable=super-method-not-called
|
||||
tmp_path = Path(TEST_DATA_ROOT / 'course_complete_badges')
|
||||
Path.rmtree_p(tmp_path)
|
||||
|
||||
@@ -78,7 +78,7 @@ class BadgeClassTest(ModuleStoreTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(BadgeClassTest, self).setUp()
|
||||
super(BadgeClassTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.addCleanup(self.cleanup_uploads)
|
||||
|
||||
def cleanup_uploads(self):
|
||||
@@ -163,7 +163,7 @@ class BadgeClassTest(ModuleStoreTestCase):
|
||||
self.assertEqual(badge_class.description, 'This is a test')
|
||||
self.assertEqual(badge_class.criteria, 'https://example.com/test_criteria')
|
||||
self.assertEqual(badge_class.display_name, 'Super Badge')
|
||||
self.assertTrue('good' in badge_class.image.name.rsplit('/', 1)[-1])
|
||||
self.assertTrue('good' in badge_class.image.name.rsplit('/', 1)[-1]) # lint-amnesty, pylint: disable=wrong-assert-type
|
||||
|
||||
def test_get_badge_class_nocreate(self):
|
||||
"""
|
||||
|
||||
40
pylintrc
40
pylintrc
@@ -73,10 +73,10 @@ persistent = yes
|
||||
load-plugins = edx_lint.pylint,pylint_django,pylint_celery
|
||||
|
||||
[MESSAGES CONTROL]
|
||||
enable =
|
||||
enable =
|
||||
blacklisted-name,
|
||||
line-too-long,
|
||||
|
||||
|
||||
syntax-error,
|
||||
init-is-generator,
|
||||
return-in-init,
|
||||
@@ -199,7 +199,7 @@ enable =
|
||||
anomalous-unicode-escape-in-string,
|
||||
bad-open-mode,
|
||||
boolean-datetime,
|
||||
|
||||
|
||||
fatal,
|
||||
astroid-error,
|
||||
parse-error,
|
||||
@@ -207,20 +207,20 @@ enable =
|
||||
django-not-available,
|
||||
raw-checker-failed,
|
||||
django-not-available-placeholder,
|
||||
|
||||
|
||||
empty-docstring,
|
||||
invalid-characters-in-docstring,
|
||||
missing-docstring,
|
||||
wrong-spelling-in-comment,
|
||||
wrong-spelling-in-docstring,
|
||||
|
||||
|
||||
unused-import,
|
||||
unused-variable,
|
||||
unused-argument,
|
||||
|
||||
|
||||
exec-used,
|
||||
eval-used,
|
||||
|
||||
|
||||
bad-classmethod-argument,
|
||||
bad-mcs-classmethod-argument,
|
||||
bad-mcs-method-argument,
|
||||
@@ -255,31 +255,30 @@ enable =
|
||||
model-has-unicode,
|
||||
model-no-explicit-unicode,
|
||||
protected-access,
|
||||
|
||||
|
||||
deprecated-module,
|
||||
deprecated-method,
|
||||
|
||||
|
||||
too-many-nested-blocks,
|
||||
too-many-statements,
|
||||
too-many-boolean-expressions,
|
||||
|
||||
|
||||
wrong-import-order,
|
||||
wrong-import-position,
|
||||
wildcard-import,
|
||||
|
||||
|
||||
missing-final-newline,
|
||||
mixed-line-endings,
|
||||
trailing-newlines,
|
||||
trailing-whitespace,
|
||||
unexpected-line-ending-format,
|
||||
mixed-indentation,
|
||||
|
||||
|
||||
bad-option-value,
|
||||
unrecognized-inline-option,
|
||||
useless-suppression,
|
||||
bad-inline-option,
|
||||
deprecated-pragma,
|
||||
disable =
|
||||
disable =
|
||||
bad-continuation,
|
||||
invalid-name,
|
||||
misplaced-comparison-constant,
|
||||
@@ -289,7 +288,7 @@ disable =
|
||||
unused-wildcard-import,
|
||||
global-statement,
|
||||
no-else-return,
|
||||
|
||||
|
||||
apply-builtin,
|
||||
backtick,
|
||||
basestring-builtin,
|
||||
@@ -364,6 +363,7 @@ disable =
|
||||
no-else-break,
|
||||
no-else-continue,
|
||||
useless-object-inheritance,
|
||||
useless-suppression,
|
||||
|
||||
[REPORTS]
|
||||
output-format = text
|
||||
@@ -409,7 +409,7 @@ ignore-imports = no
|
||||
ignore-mixin-members = yes
|
||||
ignored-classes = SQLObject
|
||||
unsafe-load-any-extension = yes
|
||||
generated-members =
|
||||
generated-members =
|
||||
REQUEST,
|
||||
acl_users,
|
||||
aq_parent,
|
||||
@@ -435,7 +435,7 @@ generated-members =
|
||||
[VARIABLES]
|
||||
init-import = no
|
||||
dummy-variables-rgx = _|dummy|unused|.*_unused
|
||||
additional-builtins =
|
||||
additional-builtins =
|
||||
|
||||
[CLASSES]
|
||||
defining-attr-methods = __init__,__new__,setUp
|
||||
@@ -456,9 +456,9 @@ max-public-methods = 20
|
||||
|
||||
[IMPORTS]
|
||||
deprecated-modules = regsub,TERMIOS,Bastion,rexec
|
||||
import-graph =
|
||||
ext-import-graph =
|
||||
int-import-graph =
|
||||
import-graph =
|
||||
ext-import-graph =
|
||||
int-import-graph =
|
||||
|
||||
[EXCEPTIONS]
|
||||
overgeneral-exceptions = Exception
|
||||
|
||||
Reference in New Issue
Block a user