fixing flakiness of tests due to redundant id created by faker.
This commit is contained in:
@@ -30,7 +30,6 @@ class TestEnterpriseCourseEnrollmentCreateOldOrder(TestCase):
|
||||
def setUpTestData(cls):
|
||||
super(TestEnterpriseCourseEnrollmentCreateOldOrder, cls).setUpTestData()
|
||||
UserFactory(username=TEST_ECOMMERCE_WORKER)
|
||||
cls.enrollment_count = 30
|
||||
cls._create_enterprise_course_enrollments(30)
|
||||
|
||||
@classmethod
|
||||
@@ -74,7 +73,10 @@ class TestEnterpriseCourseEnrollmentCreateOldOrder(TestCase):
|
||||
output
|
||||
)
|
||||
)
|
||||
self.assertEqual(mock_create_manual_enrollment_orders.call_count, 4) # batch of 4 (10, 10, 10, 2)
|
||||
# There are total 32 enrollments so there would be 4 batches (i.e: [10, 10, 10, 2])
|
||||
# as there are 2 enrollments in last batch and that 2 enrollments are not valid enrollment to process,
|
||||
# so _create_manual_enrollment_orders will not be called for last batch.
|
||||
self.assertEqual(mock_create_manual_enrollment_orders.call_count, 3)
|
||||
|
||||
@patch('lms.djangoapps.commerce.management.commands.create_orders_for_old_enterprise_course_enrollment'
|
||||
'.Command._create_manual_enrollment_orders')
|
||||
|
||||
@@ -71,6 +71,5 @@ class EnterpriseCourseEnrollmentFactory(factory.django.DjangoModelFactory):
|
||||
|
||||
model = EnterpriseCourseEnrollment
|
||||
|
||||
id = factory.LazyAttribute(lambda x: FAKER.random_int(min=1)) # pylint: disable=no-member
|
||||
course_id = factory.LazyAttribute(lambda x: FAKER.slug()) # pylint: disable=no-member
|
||||
enterprise_customer_user = factory.SubFactory(EnterpriseCustomerUserFactory)
|
||||
|
||||
Reference in New Issue
Block a user