Skip to content

Commit e3851ab

Browse files
committed
test: Update to reuse variables in more places.
Some of the places where we had explicit copies of the password were not necessary so we referece the exsting TEST_PASSWORD variable where possible.
1 parent 64e91d4 commit e3851ab

File tree

11 files changed

+22
-20
lines changed

11 files changed

+22
-20
lines changed

cms/djangoapps/contentstore/tests/test_i18n.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def setUp(self):
184184

185185
self.uname = 'testuser'
186186
self.email = '[email protected]'
187-
self.password = 'Password1234'
187+
self.password = self.TEST_PASSWORD
188188

189189
# Create the use so we can log them in.
190190
self.user = UserFactory.create(username=self.uname, email=self.email, password=self.password)

lms/djangoapps/course_api/tests/mixins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from common.djangoapps.student.tests.factories import UserFactory, CourseEnrollmentFactory, CourseAccessRoleFactory
99
from xmodule.modulestore.tests.factories import ToyCourseFactory # lint-amnesty, pylint: disable=wrong-import-order
1010

11-
TEST_PASSWORD = 'edx'
11+
TEST_PASSWORD = 'Password1234'
1212

1313

1414
class CourseApiFactoryMixin:

lms/djangoapps/course_blocks/transformers/tests/helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def setUp(self):
5050
"""
5151
super().setUp()
5252
# Set up users.
53-
self.password = 'Password1234'
53+
self.password = self.TEST_PASSWORD
5454
self.user = UserFactory.create(password=self.password)
5555
self.staff = UserFactory.create(password=self.password, is_staff=True)
5656

@@ -253,7 +253,7 @@ def setUp(self):
253253
parent_block.children.append(self.xblock_keys[i])
254254
update_block(parent_block)
255255

256-
self.password = 'Password1234'
256+
self.password = self.TEST_PASSWORD
257257
self.student = UserFactory.create(is_staff=False, username='test_student', password=self.password)
258258
self.staff = UserFactory.create(is_staff=True, username='test_staff', password=self.password)
259259
CourseEnrollmentFactory.create(

lms/djangoapps/course_wiki/tests/tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def setUp(self):
2424
# Create two accounts
2525
self.student = '[email protected]'
2626
self.instructor = '[email protected]'
27-
self.password = 'Password1234'
27+
self.password = self.TEST_PASSWORD
2828
for username, email in [('u1', self.student), ('u2', self.instructor)]:
2929
self.create_account(username, email, self.password)
3030
self.activate_user(email)

lms/djangoapps/courseware/tests/test_submitting_problems.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def setUp(self):
154154
# create a test student
155155
self.course = CourseFactory.create(display_name=self.COURSE_NAME, number=self.COURSE_SLUG)
156156
self.student = '[email protected]'
157-
self.password = 'Password1234'
157+
self.password = self.TEST_PASSWORD
158158
self.create_account('u1', self.student, self.password)
159159
self.activate_user(self.student)
160160
self.enroll(self.course)

lms/djangoapps/grades/rest_api/v1/tests/test_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ class CourseSubmissionHistoryWithDataTest(TestSubmittingProblems):
548548
def setUp(self):
549549
super().setUp()
550550
self.namespaced_url = 'grades_api:v1:submission_history'
551-
self.password = 'Password1234'
551+
self.password = self.TEST_PASSWORD
552552
self.basic_setup()
553553
self.global_staff = GlobalStaffFactory.create()
554554

lms/djangoapps/mobile_api/testutils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def setUp(self):
5050
certificate_available_date=datetime.datetime.now(pytz.UTC)
5151
)
5252
self.user = UserFactory.create()
53-
self.password = 'Password1234'
53+
self.password = self.TEST_PASSWORD
5454
self.username = self.user.username
5555
self.api_version = API_V1
5656
IgnoreMobileAvailableFlagConfig(enabled=False).save()

lms/djangoapps/survey/tests/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def setUp(self):
2828
self.client = Client()
2929

3030
# Create two accounts
31-
self.password = 'Password1234'
31+
self.password = self.TEST_PASSWORD
3232
self.student = UserFactory.create(
3333
username='student', email='[email protected]', password=self.password,
3434
)

lms/djangoapps/survey/tests/test_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def setUp(self):
2929
self.client = Client()
3030

3131
# Create two accounts
32-
self.password = 'Password1234'
32+
self.password = self.TEST_PASSWORD
3333
self.student = UserFactory.create(username='student', email='[email protected]', password=self.password)
3434

3535
self.test_survey_name = 'TestSurvey'

lms/djangoapps/verify_student/tests/test_views.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ def mock_render_to_response(*args, **kwargs):
9393
3W+sdGFUK3GH1NAX71VxbAlFVLUetcMwai1+wXmGkRw6A7YezVFnhw==
9494
-----END RSA PRIVATE KEY-----"""
9595

96+
TEST_PASSWORD = 'Password1234'
97+
9698

9799
def _mock_payment_processors():
98100
"""
@@ -122,8 +124,8 @@ def test_start_new_verification(self):
122124
Test the case where the user has no pending `PhotoVerificationAttempts`,
123125
but is just starting their first.
124126
"""
125-
UserFactory.create(username="rusty", password='Password1234')
126-
self.client.login(username="rusty", password='Password1234')
127+
UserFactory.create(username="rusty", password=TEST_PASSWORD)
128+
self.client.login(username="rusty", password=TEST_PASSWORD)
127129

128130
def must_be_logged_in(self):
129131
self.assertHttpForbidden(self.client.get(self.start_url())) # lint-amnesty, pylint: disable=no-member
@@ -1055,11 +1057,11 @@ def setUp(self):
10551057
""" Create a user and course. """
10561058
super().setUp()
10571059

1058-
self.user = UserFactory.create(username="test", password='Password1234')
1060+
self.user = UserFactory.create(username="test", password=TEST_PASSWORD)
10591061
self.course = CourseFactory.create()
10601062
for mode, min_price in (('audit', 0), ('honor', 0), ('verified', 100)):
10611063
CourseModeFactory.create(mode_slug=mode, course_id=self.course.id, min_price=min_price, sku=self.make_sku())
1062-
self.client.login(username="test", password='Password1234')
1064+
self.client.login(username="test", password=TEST_PASSWORD)
10631065

10641066
def _assert_checked_out(
10651067
self,
@@ -1868,7 +1870,7 @@ def setUp(self):
18681870
super().setUp()
18691871

18701872
self.user = AdminFactory()
1871-
login_success = self.client.login(username=self.user.username, password='Password1234')
1873+
login_success = self.client.login(username=self.user.username, password=TEST_PASSWORD)
18721874
assert login_success
18731875
self.attempt = SoftwareSecurePhotoVerification(
18741876
status="submitted",
@@ -1895,7 +1897,7 @@ def test_photo_url_view_returns_404_if_invalid_receipt_id(self):
18951897

18961898
def test_403_for_non_staff(self):
18971899
self.user = UserFactory()
1898-
login_success = self.client.login(username=self.user.username, password='Password1234')
1900+
login_success = self.client.login(username=self.user.username, password=TEST_PASSWORD)
18991901
assert login_success
19001902
url = reverse('verification_photo_urls', kwargs={'receipt_id': str(self.receipt_id)})
19011903
response = self.client.get(url)
@@ -1934,7 +1936,7 @@ class TestDecodeImageViews(MockS3Boto3Mixin, TestVerificationBase):
19341936
def setUp(self):
19351937
super().setUp()
19361938
self.user = AdminFactory()
1937-
login_success = self.client.login(username=self.user.username, password='Password1234')
1939+
login_success = self.client.login(username=self.user.username, password=TEST_PASSWORD)
19381940
assert login_success
19391941

19401942
def _mock_submit_images(self):
@@ -1995,7 +1997,7 @@ def test_download_image_response(self, img_type, _mock_get_storage):
19951997
@ddt.data("face", "photo_id")
19961998
def test_403_for_non_staff(self, img_type):
19971999
self.user = UserFactory()
1998-
login_success = self.client.login(username=self.user.username, password='Password1234')
2000+
login_success = self.client.login(username=self.user.username, password=TEST_PASSWORD)
19992001
assert login_success
20002002

20012003
self._mock_submit_images()

0 commit comments

Comments
 (0)