Skip to content

Commit

Permalink
fix: use _DEFAULT_PASSWORD variable in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CefBoud committed Nov 4, 2023
1 parent 789ca42 commit e65e326
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions section_to_course/api/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

# pylint: disable=no-self-use
from common.djangoapps.student.tests.factories import UserFactory
from common.djangoapps.student.tests.factories import UserFactory, TEST_PASSWORD
from django.urls import reverse
from rest_framework import status
from rest_framework.test import APITestCase
Expand Down Expand Up @@ -54,7 +54,7 @@ def test_rejects_unauthorized(self):
Test that the API rejects unauthorized users.
"""
user = UserFactory.create()
assert self.client.login(username=user.username, password='test')
assert self.client.login(username=user.username, password=TEST_PASSWORD)
response = self.client.get(
reverse('section_to_course:section_autocomplete', kwargs={'course_id': 'course-v1:edX+DemoX+Demo_Course'})
)
Expand All @@ -65,7 +65,7 @@ def test_rejects_malformed(self):
Test that the API rejects malformed course IDs.
"""
user = UserFactory.create(is_staff=True)
assert self.client.login(username=user.username, password='test')
assert self.client.login(username=user.username, password=TEST_PASSWORD)
response = self.client.get(
reverse('section_to_course:section_autocomplete', kwargs={'course_id': 'malarkey'})
)
Expand All @@ -76,7 +76,7 @@ def test_handles_nonexistent(self):
Test that the API rejects malformed course IDs.
"""
user = UserFactory.create(is_staff=True)
assert self.client.login(username=user.username, password='test')
assert self.client.login(username=user.username, password=TEST_PASSWORD)
response = self.client.get(
reverse('section_to_course:section_autocomplete', kwargs={'course_id': 'course-v1:edX+DemoX+Demo_Course'}),
)
Expand All @@ -87,7 +87,7 @@ def test_handles_blank(self):
Test that blank terms return all sections.
"""
user = UserFactory.create(is_staff=True)
assert self.client.login(username=user.username, password='test')
assert self.client.login(username=user.username, password=TEST_PASSWORD)
create_subsections()
response = self.client.get(
reverse('section_to_course:section_autocomplete', kwargs={'course_id': 'course-v1:edX+DemoX+Demo_Course'}),
Expand All @@ -105,7 +105,7 @@ def test_filters_existing(self):
Test that autocomplete filters existing sections.
"""
user = UserFactory.create(is_staff=True)
assert self.client.login(username=user.username, password='test')
assert self.client.login(username=user.username, password=TEST_PASSWORD)
section_data = create_subsections()
SectionToCourseLinkFactory(source_course=section_data['course'], source_section=section_data['experimentation'])
response = self.client.get(
Expand All @@ -123,7 +123,7 @@ def test_filters_names(self):
Test that autocomplete filters names.
"""
user = UserFactory.create(is_staff=True)
assert self.client.login(username=user.username, password='test')
assert self.client.login(username=user.username, password=TEST_PASSWORD)
create_subsections()
response = self.client.get(
reverse('section_to_course:section_autocomplete', kwargs={'course_id': 'course-v1:edX+DemoX+Demo_Course'})
Expand All @@ -141,7 +141,7 @@ def test_filters_keys(self):
Test that autocomplete filters keys.
"""
user = UserFactory.create(is_staff=True)
assert self.client.login(username=user.username, password='test')
assert self.client.login(username=user.username, password=TEST_PASSWORD)
create_subsections()
response = self.client.get(
reverse('section_to_course:section_autocomplete', kwargs={'course_id': 'course-v1:edX+DemoX+Demo_Course'})
Expand Down
4 changes: 2 additions & 2 deletions section_to_course/tests/test_admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Tests for the admin views of the section_to_course app.
"""
from common.djangoapps.student.tests.factories import UserFactory # pylint: disable=import-error
from common.djangoapps.student.tests.factories import UserFactory, TEST_PASSWORD # pylint: disable=import-error
from django.test import TestCase
from django.urls import reverse
from django.utils import timezone
Expand Down Expand Up @@ -31,7 +31,7 @@ def setUp(self):
"""Set up our admin test cases."""
super().setUp()
user = UserFactory.create(is_staff=True, is_superuser=True)
self.client.login(username=user.username, password='test')
self.client.login(username=user.username, password=TEST_PASSWORD)

def test_listing(self):
"""Test that the admin listing page loads."""
Expand Down

0 comments on commit e65e326

Please sign in to comment.