Commit e512a506 by Ben Patterson

Use helper method for generating unique user identities.

parent bed5d3e8
......@@ -41,8 +41,7 @@ class CohortConfigurationTest(EventsTestMixin, UniqueCourseTest, CohortTestMixin
self.manual_cohort_id = self.add_manual_cohort(self.course_fixture, self.manual_cohort_name)
# create a non-instructor who will be registered for the course and in the manual cohort.
self.student_name = "student_" + str(uuid.uuid4().hex)[:12]
self.student_email = self.student_name + "@example.com"
self.student_name, self.student_email = self._generate_unique_user_data()
self.student_id = AutoAuthPage(
self.browser, username=self.student_name, email=self.student_email,
course_id=self.course_id, staff=False
......@@ -50,16 +49,14 @@ class CohortConfigurationTest(EventsTestMixin, UniqueCourseTest, CohortTestMixin
self.add_user_to_cohort(self.course_fixture, self.student_name, self.manual_cohort_id)
# create a second student user
self.other_student_name = "other_" + str(uuid.uuid4().hex)[:12]
self.other_student_email = self.other_student_name + "@example.com"
self.other_student_name, self.other_student_email = self._generate_unique_user_data()
self.other_student_id = AutoAuthPage(
self.browser, username=self.other_student_name, email=self.other_student_email,
course_id=self.course_id, staff=False
).visit().get_user_id()
# login as an instructor
self.instructor_name = "instructor_" + str(uuid.uuid4().hex)[:12]
self.instructor_email = self.instructor_name + "@example.com"
self.instructor_name, self.instructor_email = self._generate_unique_user_data()
self.instructor_id = AutoAuthPage(
self.browser, username=self.instructor_name, email=self.instructor_email,
course_id=self.course_id, staff=True
......@@ -331,6 +328,12 @@ class CohortConfigurationTest(EventsTestMixin, UniqueCourseTest, CohortTestMixin
writer.writerow(line)
self.addCleanup(os.remove, filename)
def _generate_unique_user_data(self):
unique_username = 'user' + str(uuid.uuid4().hex)[:12]
unique_email = unique_username + "@example.com"
return unique_username, unique_email
def test_add_new_cohort(self):
"""
Scenario: A new manual cohort can be created, and a student assigned to it.
......
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