Commit 4d8dff3e by Waheed Ahmed Committed by GitHub

Merge pull request #356 from edx/waheed/fix-pylint-for-tests

Fixed pylint was not checking the files under publisher/tests and publisher_comments/tests.
parents 42b60c19 a7d81f88
from datetime import datetime from datetime import datetime
import factory
from django.contrib.auth.models import Group from django.contrib.auth.models import Group
import factory
from factory.fuzzy import FuzzyText, FuzzyChoice, FuzzyDecimal, FuzzyDateTime, FuzzyInteger from factory.fuzzy import FuzzyText, FuzzyChoice, FuzzyDecimal, FuzzyDateTime, FuzzyInteger
from pytz import UTC from pytz import UTC
......
# pylint: disable=no-member
import ddt import ddt
from mock import patch from mock import patch
from django.conf import settings from django.conf import settings
...@@ -647,10 +648,10 @@ class CourseRunDetailTests(TestCase): ...@@ -647,10 +648,10 @@ class CourseRunDetailTests(TestCase):
def _assert_dates(self, response): def _assert_dates(self, response):
""" Helper method to test all dates. """ """ Helper method to test all dates. """
for value in [ for value in [self.course_run.start,
self.course_run.start, self.course_run.end, self.course_run.end,
self.course_run.enrollment_start, self.course_run.enrollment_end self.course_run.enrollment_start,
]: self.course_run.enrollment_end]:
self.assertContains(response, value.strftime(self.date_format)) self.assertContains(response, value.strftime(self.date_format))
def _assert_subjects(self, response): def _assert_subjects(self, response):
...@@ -681,7 +682,7 @@ class CourseRunDetailTests(TestCase): ...@@ -681,7 +682,7 @@ class CourseRunDetailTests(TestCase):
""" Verify that `ViewPermissionMixin.get_course` return none """ Verify that `ViewPermissionMixin.get_course` return none
if `publisher_object` doesn't have `course` attr. if `publisher_object` doesn't have `course` attr.
""" """
non_staff_user, group = create_non_staff_user_and_login(self) non_staff_user, group = create_non_staff_user_and_login(self) # pylint: disable=unused-variable
page_url = reverse('publisher:publisher_course_run_detail', args=[self.course_run.id]) page_url = reverse('publisher:publisher_course_run_detail', args=[self.course_run.id])
with patch.object(CourseRunDetailView, 'get_object', return_value=non_staff_user): with patch.object(CourseRunDetailView, 'get_object', return_value=non_staff_user):
response = self.client.get(page_url) response = self.client.get(page_url)
......
# pylint: disable=no-member # pylint: disable=no-member
import ddt
from unittest import mock from unittest import mock
from django.test import TestCase from django.test import TestCase
import ddt
from course_discovery.apps.course_metadata.tests.factories import OrganizationFactory from course_discovery.apps.course_metadata.tests.factories import OrganizationFactory
from course_discovery.apps.publisher.models import Seat, State from course_discovery.apps.publisher.models import Seat, State
from course_discovery.apps.publisher.tests import factories from course_discovery.apps.publisher.tests import factories
......
...@@ -17,7 +17,7 @@ class CommentFactory(factory.DjangoModelFactory): ...@@ -17,7 +17,7 @@ class CommentFactory(factory.DjangoModelFactory):
comment = FuzzyText(prefix="Test Comment for çօմɾʂҽ") comment = FuzzyText(prefix="Test Comment for çօմɾʂҽ")
content_object = factory.SubFactory(CourseRunFactory) content_object = factory.SubFactory(CourseRunFactory)
user = UserFactory() user = factory.SubFactory(UserFactory)
site = factory.SubFactory(SiteFactory) site = factory.SubFactory(SiteFactory)
class Meta: class Meta:
......
...@@ -21,6 +21,7 @@ class AdminTests(TestCase): ...@@ -21,6 +21,7 @@ class AdminTests(TestCase):
def test_comment_detail_form(self): def test_comment_detail_form(self):
""" Verify in admin panel comment detail form contain the custom modified field. """ """ Verify in admin panel comment detail form contain the custom modified field. """
# pylint: disable=no-member
resp = self.client.get(reverse('admin:publisher_comments_comments_change', args=(self.comment.id,))) resp = self.client.get(reverse('admin:publisher_comments_comments_change', args=(self.comment.id,)))
self.assertContains(resp, 'modified') self.assertContains(resp, 'modified')
...@@ -28,6 +29,6 @@ class AdminTests(TestCase): ...@@ -28,6 +29,6 @@ class AdminTests(TestCase):
""" Verify in admin panel for comments loads only three models in content type drop down. """ """ Verify in admin panel for comments loads only three models in content type drop down. """
form = CommentsAdminForm(instance=self.comment) form = CommentsAdminForm(instance=self.comment)
self.assertListEqual( self.assertListEqual(
sorted([con.model for con in form.fields['content_type']._queryset]), sorted([con.model for con in form.fields['content_type']._queryset]), # pylint: disable=protected-access
sorted(['courserun', 'seat', 'course']) sorted(['courserun', 'seat', 'course'])
) )
...@@ -10,6 +10,7 @@ from course_discovery.apps.publisher.tests import factories ...@@ -10,6 +10,7 @@ from course_discovery.apps.publisher.tests import factories
from course_discovery.apps.publisher_comments.tests.factories import CommentFactory from course_discovery.apps.publisher_comments.tests.factories import CommentFactory
# pylint: disable=no-member
class CommentsTests(TestCase): class CommentsTests(TestCase):
""" Tests for the Comment functionality on `Courser`, `CourseRun` And `Seat` edit pages. """ """ Tests for the Comment functionality on `Courser`, `CourseRun` And `Seat` edit pages. """
def setUp(self): def setUp(self):
...@@ -43,7 +44,7 @@ class CommentsTests(TestCase): ...@@ -43,7 +44,7 @@ class CommentsTests(TestCase):
self.assertContains(response, 'Total Comments 0') self.assertContains(response, 'Total Comments 0')
comments = [] comments = []
for num in range(1, 10): for num in range(1, 10): # pylint: disable=unused-variable
comments.append(self._generate_comment(content_object=content_object, user=self.user)) comments.append(self._generate_comment(content_object=content_object, user=self.user))
response = self.client.get(reverse(page_path, kwargs={'pk': content_object.id})) response = self.client.get(reverse(page_path, kwargs={'pk': content_object.id}))
for comment in comments: for comment in comments:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment