def setUp(self): enterprise_user = EnterpriseUserFactory(enterprise_user_id=1234) course_id = 'course-v1:edX+DemoX+DemoCourse' self.enrollment = EnterpriseEnrollmentFactory( enterprise_user=enterprise_user, course_id=course_id) super(TestEnterpriseEnrollment, self).setUp()
def test_create_enterpriseuser_error(self): """ Manangement command should successfully be able to create EnterpriseUser """ EnterpriseUserFactory(enterprise_id=self.uuid) assert EnterpriseUser.objects.count() == 1 args = [self.uuid] with mock.patch('enterprise_data.tests.test_utils.EnterpriseUserFactory') as mock_factory: mock_factory.side_effect = [Exception] with self.assertRaises(Exception): call_command('create_enterprise_user', *args) assert EnterpriseUser.objects.count() == 1
def handle(self, *args, **options): enterprise_id = options['enterprise_id'] try: for _ in range(10): user = EnterpriseUserFactory(enterprise_id=enterprise_id) for _ in range(5): EnterpriseEnrollmentFactory( enterprise_id=enterprise_id, enterprise_user=user, user_email=user.user_email) except Exception as exc: info = ( 'Error trying to create Enrollments for enterprise ' '{}: {}'.format(enterprise_id, exc) ) raise CommandError(info) from exc
def setUp(self): super(TestEnterpriseEnrollmentSerializer, self).setUp() EnterpriseUserFactory(enterprise_user_id=1) self.enrollment_data = { "id": 1, "enterprise_id": "ee5e6b3a-069a-4947-bb8d-d2dbc323396c", "enterprise_name": "Enterprise 1", "lms_user_id": 11, "enterprise_user": 1, "course_id": "edX/Open_DemoX/edx_demo_course", "enrollment_created_timestamp": "2014-06-27T16:02:38Z", "unenrollment_timestamp": None, "user_current_enrollment_mode": "verified", "consent_granted": 1, "letter_grade": "Pass", "progress_status": "Failed", "passed_timestamp": "2017-05-09T16:27:34.690065Z", "enterprise_sso_uid": "harry", "course_title": "All about acceptance testing!", "course_start": "2016-09-01T00:00:00Z", "course_end": "2016-12-01T00:00:00Z", "course_pacing_type": "instructor_paced", "course_duration_weeks": "8", "course_min_effort": 2, "course_max_effort": 4, "user_account_creation_timestamp": "2015-02-12T23:14:35Z", "user_email": "*****@*****.**", "user_username": "******", "course_key": "edX/Open_DemoX", "enterprise_site_id": 1, "current_grade": 0.80, "discount_price": "120.00", "last_activity_date": "2017-06-23", "coupon_code": "PIPNJSUK33P7PTZH", "user_country_code": "US", "course_price": "200.00", "coupon_name": "Enterprise Entitlement Coupon", "offer": "Percentage, 100 (#1234)", "unenrollment_end_within_date": None, } self.course_api_url = '/enterprise/v1/enterprise-catalogs/{enterprise_id}/courses/{course_id}'.format( enterprise_id=self.enrollment_data['enterprise_id'], course_id=self.enrollment_data['course_id'] )
def setUp(self): super().setUp() self.uuid = 'a'*32 self.enterprise_user = EnterpriseUserFactory(enterprise_id=self.uuid)
def setUp(self): super(TestCreateEnterpriseEnrollmentCommand, self).setUp() self.uuid = 'a' * 32 self.enterprise_user = EnterpriseUserFactory(enterprise_id=self.uuid)
def setUp(self): enterprise_id = 'ee5e6b3a-069a-4947-bb8d-d2dbc323396c' lms_user_id = 1234 self.user = EnterpriseUserFactory(lms_user_id=lms_user_id, enterprise_id=enterprise_id) super(TestEnterpriseUser, self).setUp()