def test_create_enrollment_task_course_in_catalog(self, mock_contains_course): """ Task should create an enterprise enrollment if the course_id handed to the function is part of the EnterpriseCustomer's catalogs """ mock_contains_course.return_value = True assert EnterpriseCourseEnrollment.objects.count() == 0 create_enterprise_enrollment(self.FAKE_COURSE_ID, self.enterprise_customer_user.id) assert EnterpriseCourseEnrollment.objects.count() == 1
def test_create_enrollment_task_course_not_in_catalog( self, mock_contains_course): """ Task should NOT create an enterprise enrollment if the course_id handed to the function is NOT part of the EnterpriseCustomer's catalogs """ mock_contains_course.return_value = False assert EnterpriseCourseEnrollment.objects.count() == 0 create_enterprise_enrollment('fake:course', self.enterprise_customer_user.id) assert EnterpriseCourseEnrollment.objects.count() == 0
def test_create_enrollment_task_no_create_duplicates(self): """ Task should return without creating a new EnterpriseCourseEnrollment if one with the course_id and enterprise_customer_user specified already exists. """ EnterpriseCourseEnrollment.objects.create( course_id='fake:course', enterprise_customer_user=self.enterprise_customer_user, ) assert EnterpriseCourseEnrollment.objects.count() == 1 create_enterprise_enrollment(self.FAKE_COURSE_ID, self.enterprise_customer_user.id) assert EnterpriseCourseEnrollment.objects.count() == 1
def test_create_enrollment_task_no_create_duplicates(self, catalog_api_client_mock): """ Task should return without creating a new EnterpriseCourseEnrollment if one with the course_id and enterprise_customer_user specified already exists. """ EnterpriseCourseEnrollment.objects.create( course_id=self.FAKE_COURSE_ID, enterprise_customer_user=self.enterprise_customer_user, ) catalog_api_client_mock.return_value.contains_content_items.return_value = False assert EnterpriseCourseEnrollment.objects.count() == 1 create_enterprise_enrollment( self.FAKE_COURSE_ID, self.enterprise_customer_user.id ) assert EnterpriseCourseEnrollment.objects.count() == 1