예제 #1
0
class EnrollmentApiMixin(object):
    def setUp(self):
        super(EnrollmentApiMixin, self).setUp()
        self.enrollment_api_client = EnrollmentApiClient()

    def assert_user_enrolled(self, username, course_id, mode='honor'):
        """ Verify the user is enrolled in the given course and mode. """
        status = self.enrollment_api_client.get_enrollment_status(
            username, course_id)
        self.assertDictContainsSubset({
            'is_active': True,
            'mode': mode
        }, status)

    def assert_user_not_enrolled(self, username, course_id):
        """ Verify the user is NOT enrolled in the given course. """
        try:
            status = self.enrollment_api_client.get_enrollment_status(
                username, course_id)
        except ValueError:
            # Silly Enrollment API doesn't actually return data if an enrollment does not exist.
            return

        # If/when the API is updated, use this code to check enrollment status.
        if status:
            msg = '{} should NOT be enrolled in {}'.format(username, course_id)
            self.assertDictContainsSubset({'is_active': False}, status, msg)
예제 #2
0
class EnrollmentApiMixin(object):
    def setUp(self):
        super(EnrollmentApiMixin, self).setUp()
        self.enrollment_api_client = EnrollmentApiClient()

    def assert_user_enrolled(self, username, course_id, mode='honor'):
        status = self.enrollment_api_client.get_enrollment_status(username, course_id)
        self.assertDictContainsSubset({'is_active': True, 'mode': mode}, status)
예제 #3
0
class EnrollmentApiMixin(object):
    def setUp(self):
        super(EnrollmentApiMixin, self).setUp()
        self.enrollment_api_client = EnrollmentApiClient()

    def assert_user_enrolled(self, username, course_id, mode='honor'):
        """ Verify the user is enrolled in the given course and mode. """
        status = self.enrollment_api_client.get_enrollment_status(username, course_id)
        self.assertDictContainsSubset({'is_active': True, 'mode': mode}, status)

    def assert_user_not_enrolled(self, username, course_id):
        """ Verify the user is NOT enrolled in the given course. """
        try:
            status = self.enrollment_api_client.get_enrollment_status(username, course_id)
        except ValueError:
            # Silly Enrollment API doesn't actually return data if an enrollment does not exist.
            return

        # If/when the API is updated, use this code to check enrollment status.
        if status:
            msg = '{} should NOT be enrolled in {}'.format(username, course_id)
            self.assertDictContainsSubset({'is_active': False}, status, msg)
예제 #4
0
class LoginEnrollmentTests(LoginMixin, WebAppTest):
    def setUp(self):
        super(LoginEnrollmentTests, self).setUp()
        self.course_id = COURSE_ID
        self.username = LMS_USERNAME
        self.enrollment_api_client = EnrollmentApiClient()
        self.ecommerce_api_client = EcommerceApiClient()

        # TODO Delete existing enrollments

    def _test_honor_enrollment_common(self):
        """
        Validates an order is created for the logged in user and that a corresponding order has been created.
        """
        # Get the latest order
        orders = self.ecommerce_api_client.orders()
        self.assertGreater(len(orders), 0, 'No orders found for the user!')
        order = orders[0]

        # TODO Find a better way to verify this is the correct enrollment.
        # Verify the date and status
        self.assertEqual(order['status'], 'Complete')

        order_date = order['date_placed']
        now = datetime.datetime.utcnow()
        self.assertLess(order_date, now)
        self.assertGreater(order_date, now - datetime.timedelta(seconds=ORDER_PROCESSING_TIME))

        # Verify user enrolled in course
        status = self.enrollment_api_client.get_enrollment_status(self.username, self.course_id)
        log.debug(status)
        self.assertDictContainsSubset({'is_active': True, 'mode': 'honor'}, status)

    def test_honor_enrollment_and_login(self):
        """ Verifies that a user can login and enroll in a course via the login page. """

        # Login and enroll via LMS
        self.login_with_lms(self.course_id)

        self._test_honor_enrollment_common()
예제 #5
0
 def setUp(self):
     super(EnrollmentApiMixin, self).setUp()
     self.enrollment_api_client = EnrollmentApiClient()
예제 #6
0
파일: mixins.py 프로젝트: ED-HEC/ecommerce
 def setUp(self):
     super(EnrollmentApiMixin, self).setUp()
     self.enrollment_api_client = EnrollmentApiClient()
예제 #7
0
 def setUp(self):
     super(LoginEnrollmentTests, self).setUp()
     self.course_id = COURSE_ID
     self.username = LMS_USERNAME
     self.enrollment_api_client = EnrollmentApiClient()
     self.ecommerce_api_client = EcommerceApiClient()