コード例 #1
0
 def test_enrollment_once_per_customer_code_max_limit(self):
     """
     Scenario: Dynamic Enrollment Once Per Customer - Code Max Limit: Each
     code can be used up to the number of allowed uses and after that it
     is not usable by any user
     """
     maximum_uses = 2
     self.coupon = Coupon(COURSE_CATALOG_TYPE['multi'],
                          COUPON_TYPE['enroll'],
                          VOUCHER_TYPE['once_per_cust'],
                          catalog_query=CATALOG_QUERY,
                          course_seat_types=COURSE_SEAT_TYPES['prof'],
                          stock_record_ids=[],
                          max_uses=maximum_uses)
     self.coupon.setup_coupons_using_api(self.course_price)
     self.addCleanup(self.coupon.delete_coupon)
     coupon_code = self.coupon.coupon_codes[0]
     for i in range(maximum_uses):
         if i < maximum_uses:
             # Register to application using api
             self.register_using_api(
                 construct_course_basket_page_url(self.course_id))
             self.enroll_using_enrollment_code(coupon_code)
             self.assert_enrollment_and_logout()
         else:
             # Register to application using api
             self.register_using_api(
                 construct_course_basket_page_url(self.course_id))
             self.assertEqual(
                 self.error_message_on_invalid_coupon_code(coupon_code),
                 ONCE_PER_CUSTOMER_CODE_MAX_LIMIT)
コード例 #2
0
 def test_discount_single_use_percentage_code(self):
     """
     Scenario: Discount Single Use Percentage Code: Code cannot be reused
     """
     self.coupon = Coupon(
         COURSE_CATALOG_TYPE['single'],
         COUPON_TYPE['disc'],
         VOUCHER_TYPE['single'],
         course_id=self.course_id,
         seat_type=SEAT_TYPE['prof'],
         stock_record_ids=self.stock_record_id,
         benefit_type=BENEFIT_TYPE['per'],
         benefit_value=BENEFIT_VALUE['per']
     )
     self.coupon.setup_coupons_using_api(self.course_price)
     coupon_code = self.coupon.coupon_codes[0]
     # Delete coupon after test
     self.addCleanup(self.coupon.delete_coupon)
     # Register to application using api
     self.register_using_api(
         construct_course_basket_page_url(self.course_id)
     )
     self.enroll_using_discount_code(coupon_code)
     self.assert_enrollment_and_logout()
     self.register_using_api(
         construct_course_basket_page_url(self.course_id)
     )
     self.assertEqual(
         self.error_message_on_invalid_coupon_code(coupon_code),
         SINGLE_USE_CODE_REUSE_ERROR.format(coupon_code)
     )
コード例 #3
0
 def test_discount_single_use_percentage_code(self):
     """
     Scenario: Dynamic Discount Single Use Percentage Code: Code cannot
     be reused
     """
     self.coupon = Coupon(COURSE_CATALOG_TYPE['multi'],
                          COUPON_TYPE['disc'],
                          VOUCHER_TYPE['single'],
                          catalog_query=CATALOG_QUERY,
                          stock_record_ids=[],
                          course_seat_types=COURSE_SEAT_TYPES['prof'],
                          benefit_type=BENEFIT_TYPE['per'],
                          benefit_value=BENEFIT_VALUE['per'])
     self.coupon.setup_coupons_using_api(self.course_price)
     coupon_code = self.coupon.coupon_codes[0]
     # Login to application using the existing credentials
     self.login_page.visit()
     # Register to application using api
     self.register_using_api(
         construct_course_basket_page_url(self.course_id))
     self.enroll_using_discount_code(coupon_code)
     self.assert_enrollment_and_logout_of_ecommerce()
     # Register to application using api
     self.register_using_api(
         construct_course_basket_page_url(self.course_id))
     self.assertEqual(
         self.error_message_on_invalid_coupon_code(coupon_code),
         SINGLE_USE_CODE_REUSE_ERROR.format(coupon_code))
コード例 #4
0
 def test_discount_single_use_percentage_code(self):
     """
     Scenario: Discount Single Use Percentage Code: Code cannot be reused
     """
     self.coupon = Coupon(COURSE_CATALOG_TYPE['single'],
                          COUPON_TYPE['disc'],
                          VOUCHER_TYPE['single'],
                          course_id=self.course_id,
                          seat_type=SEAT_TYPE['prof'],
                          stock_record_ids=self.stock_record_id,
                          benefit_type=BENEFIT_TYPE['per'],
                          benefit_value=BENEFIT_VALUE['per'])
     self.coupon.setup_coupons_using_api(self.course_price)
     coupon_code = self.coupon.coupon_codes[0]
     # Delete coupon after test
     self.addCleanup(self.coupon.delete_coupon)
     # Register to application using api
     self.register_using_api(
         construct_course_basket_page_url(self.course_id))
     self.enroll_using_discount_code(coupon_code)
     self.assert_enrollment_and_logout()
     self.register_using_api(
         construct_course_basket_page_url(self.course_id))
     self.assertEqual(
         self.error_message_on_invalid_coupon_code(coupon_code),
         SINGLE_USE_CODE_REUSE_ERROR.format(coupon_code))
コード例 #5
0
 def test_discount_single_use_percentage_code(self):
     """
     Scenario: Dynamic Discount Single Use Percentage Code: Code cannot
     be reused
     """
     self.coupon = Coupon(
         COURSE_CATALOG_TYPE['multi'],
         COUPON_TYPE['disc'],
         VOUCHER_TYPE['single'],
         catalog_query=CATALOG_QUERY,
         stock_record_ids=[],
         course_seat_types=COURSE_SEAT_TYPES['prof'],
         benefit_type=BENEFIT_TYPE['per'],
         benefit_value=BENEFIT_VALUE['per']
     )
     self.coupon.setup_coupons_using_api(self.course_price)
     coupon_code = self.coupon.coupon_codes[0]
     # Login to application using the existing credentials
     self.login_page.visit()
     # Register to application using api
     self.register_using_api(
         construct_course_basket_page_url(self.course_id)
     )
     self.enroll_using_discount_code(coupon_code)
     self.assert_enrollment_and_logout()
     # Register to application using api
     self.register_using_api(
         construct_course_basket_page_url(self.course_id)
     )
     self.assertEqual(
         self.error_message_on_invalid_coupon_code(coupon_code),
         SINGLE_USE_CODE_REUSE_ERROR.format(coupon_code)
     )
コード例 #6
0
 def test_enrollment_once_per_customer_code_max_limit(self):
     """
     Scenario: Enrollment Once Per Customer - Code Max Limit: Each code can
     be used up to the number of allowed uses and after that it is not
     usable by any user
     """
     maximum_uses = 2
     self.coupon = Coupon(COURSE_CATALOG_TYPE['single'],
                          COUPON_TYPE['enroll'],
                          VOUCHER_TYPE['once_per_cust'],
                          course_id=self.course_info,
                          seat_type=SEAT_TYPE['prof'],
                          stock_record_ids=self.stock_record_id,
                          max_uses=maximum_uses)
     self.coupon.setup_coupons_using_api(self.course_price)
     coupon_code = self.coupon.coupon_codes[0]
     # Delete coupon after test
     self.addCleanup(self.coupon.delete_coupon)
     # Login to application using the existing credentials
     for i in range(maximum_uses):
         # Register to application using api
         self.register_using_api(
             construct_course_basket_page_url(self.course_id))
         if i < maximum_uses:
             self.enroll_using_enrollment_code(coupon_code)
             self.assert_enrollment_and_logout()
         else:
             self.assertEqual(
                 self.error_message_on_invalid_coupon_code(coupon_code),
                 ONCE_PER_CUSTOMER_CODE_MAX_LIMIT)
コード例 #7
0
    def test_discount_single_use_fixed_code_expired(self):
        """
        Scenario: Discount Single Use Fixed Code: Relevant error message is
        displayed on the use of Expired coupon
        """
        self.coupon = Coupon(
            COURSE_CATALOG_TYPE['single'],
            COUPON_TYPE['disc'],
            VOUCHER_TYPE['single'],
            end_datetime=EXPIRED_END_DATE,
            course_id=self.course_id,
            seat_type=SEAT_TYPE['prof'],
            stock_record_ids=self.stock_record_id,
            benefit_type=BENEFIT_TYPE['abs'],
            benefit_value=BENEFIT_VALUE['fixed']
        )

        self.coupon.setup_coupons_using_api(self.course_price)
        coupon_code = self.coupon.coupon_codes[0]
        # Delete coupon after test
        self.addCleanup(self.coupon.delete_coupon)
        # Register to application using api
        self.register_using_api(
            construct_course_basket_page_url(self.course_id)
        )
        self.assertEqual(
            self.error_message_on_invalid_coupon_code(coupon_code),
            EXPIRED_CODE_ERROR.format(coupon_code)
        )
コード例 #8
0
    def test_discount_single_use_fixed_code_expired(self):
        """
        Scenario: Discount Single Use Fixed Code: Relevant error message is
        displayed on the use of Expired coupon
        """
        self.coupon = Coupon(COURSE_CATALOG_TYPE['single'],
                             COUPON_TYPE['disc'],
                             VOUCHER_TYPE['single'],
                             end_datetime=EXPIRED_END_DATE,
                             course_id=self.course_id,
                             seat_type=SEAT_TYPE['prof'],
                             stock_record_ids=self.stock_record_id,
                             benefit_type=BENEFIT_TYPE['abs'],
                             benefit_value=BENEFIT_VALUE['fixed'])

        self.coupon.setup_coupons_using_api(self.course_price)
        coupon_code = self.coupon.coupon_codes[0]
        # Delete coupon after test
        self.addCleanup(self.coupon.delete_coupon)
        # Register to application using api
        self.register_using_api(
            construct_course_basket_page_url(self.course_id))
        self.assertEqual(
            self.error_message_on_invalid_coupon_code(coupon_code),
            EXPIRED_CODE_ERROR.format(coupon_code))
コード例 #9
0
    def test_discount_once_per_customer_fixed_code(self):
        """
        Scenario: Discount Once Per Customer Fixed Code: Code can be used up
        to the number of allowed uses and after that it is not usable by anyone
        """
        maximum_uses = 2
        self.coupon = Coupon(
            COURSE_CATALOG_TYPE['single'],
            COUPON_TYPE['disc'],
            VOUCHER_TYPE['once_per_cust'],
            course_id=self.course_id,
            seat_type=SEAT_TYPE['prof'],
            stock_record_ids=self.stock_record_id,
            benefit_type=BENEFIT_TYPE['abs'],
            benefit_value=BENEFIT_VALUE['fixed'],
            max_uses=maximum_uses
        )

        self.coupon.setup_coupons_using_api(self.course_price)
        coupon_code = self.coupon.coupon_codes[0]
        # Delete coupon after test
        self.addCleanup(self.coupon.delete_coupon)
        for i in range(maximum_uses):
            # Register to application using api
            self.register_using_api(
                construct_course_basket_page_url(self.course_id)
            )
            if i < maximum_uses:
                self.enroll_using_discount_code(coupon_code)
                self.assert_enrollment_and_logout()
            else:
                self.assertEqual(
                    self.error_message_on_invalid_coupon_code(coupon_code),
                    ONCE_PER_CUSTOMER_CODE_MAX_LIMIT
                )
コード例 #10
0
 def test_enrollment_once_per_customer_code_max_limit(self):
     """
     Scenario: Enrollment Once Per Customer - Code Max Limit: Each code can
     be used up to the number of allowed uses and after that it is not
     usable by any user
     """
     maximum_uses = 2
     self.coupon = Coupon(
         COURSE_CATALOG_TYPE['single'],
         COUPON_TYPE['enroll'],
         VOUCHER_TYPE['once_per_cust'],
         course_id=self.course_info,
         seat_type=SEAT_TYPE['prof'],
         stock_record_ids=self.stock_record_id,
         max_uses=maximum_uses
     )
     self.coupon.setup_coupons_using_api(self.course_price)
     coupon_code = self.coupon.coupon_codes[0]
     # Delete coupon after test
     self.addCleanup(self.coupon.delete_coupon)
     # Login to application using the existing credentials
     for i in range(maximum_uses):
         # Register to application using api
         self.register_using_api(
             construct_course_basket_page_url(self.course_id)
         )
         if i < maximum_uses:
             self.enroll_using_enrollment_code(coupon_code)
             self.assert_enrollment_and_logout()
         else:
             self.assertEqual(
                 self.error_message_on_invalid_coupon_code(coupon_code),
                 ONCE_PER_CUSTOMER_CODE_MAX_LIMIT
             )
コード例 #11
0
 def test_enrollment_single_use_code(self):
     """
     Scenario: Enrollment Single Use Code: Each code can be used by one
     person successfully
     """
     self.coupon = Coupon(
         COURSE_CATALOG_TYPE['single'],
         COUPON_TYPE['enroll'],
         VOUCHER_TYPE['single'],
         course_id=self.course_info,
         seat_type=SEAT_TYPE['prof'],
         stock_record_ids=self.stock_record_id,
         quantity=2
     )
     self.coupon.setup_coupons_using_api(self.course_price)
     coupon_codes = self.coupon.coupon_codes
     # Delete coupon after test
     self.addCleanup(self.coupon.delete_coupon)
     for coupon_code in coupon_codes:
         # Register to application using api
         self.register_using_api(
             construct_course_basket_page_url(self.course_id)
         )
         self.enroll_using_enrollment_code(coupon_code)
         self.assert_enrollment_and_logout()
コード例 #12
0
 def test_enrollment_single_use_code_future(self):
     """
     Scenario: Enrollment Single Use Code: Relevant error message is
     displayed on the use of future coupon
     """
     self.coupon = Coupon(
         COURSE_CATALOG_TYPE['single'],
         COUPON_TYPE['enroll'],
         VOUCHER_TYPE['single'],
         start_datetime=FUTURE_START_DATE,
         course_id=self.course_info,
         seat_type=SEAT_TYPE['prof'],
         stock_record_ids=self.stock_record_id
     )
     self.coupon.setup_coupons_using_api(self.course_price)
     coupon_code = self.coupon.coupon_codes[0]
     # Delete coupon after test
     self.addCleanup(self.coupon.delete_coupon)
     # Register to application using api
     self.register_using_api(
         construct_course_basket_page_url(self.course_id)
     )
     self.assertEqual(
         self.error_message_on_invalid_coupon_code(coupon_code),
         FUTURE_CODE_ERROR.format(coupon_code)
     )
コード例 #13
0
 def test_enrollment_once_per_customer_code_max_limit(self):
     """
     Scenario: Dynamic Enrollment Once Per Customer - Code Max Limit: Each
     code can be used up to the number of allowed uses and after that it
     is not usable by any user
     """
     maximum_uses = 2
     self.coupon = Coupon(
         COURSE_CATALOG_TYPE['multi'],
         COUPON_TYPE['enroll'],
         VOUCHER_TYPE['once_per_cust'],
         catalog_query=CATALOG_QUERY,
         course_seat_types=COURSE_SEAT_TYPES['prof'],
         stock_record_ids=[],
         max_uses=maximum_uses
     )
     self.coupon.setup_coupons_using_api(self.course_price)
     self.addCleanup(self.coupon.delete_coupon)
     coupon_code = self.coupon.coupon_codes[0]
     for i in range(maximum_uses):
         if i < maximum_uses:
             # Register to application using api
             self.register_using_api(
                 construct_course_basket_page_url(self.course_id)
             )
             self.enroll_using_enrollment_code(coupon_code)
             self.assert_enrollment_and_logout()
         else:
             # Register to application using api
             self.register_using_api(
                 construct_course_basket_page_url(self.course_id)
             )
             self.assertEqual(
                 self.error_message_on_invalid_coupon_code(coupon_code),
                 ONCE_PER_CUSTOMER_CODE_MAX_LIMIT
             )
コード例 #14
0
 def test_enrollment_single_use_code_future(self):
     """
     Scenario: Enrollment Single Use Code: Relevant error message is
     displayed on the use of future coupon
     """
     self.coupon = Coupon(COURSE_CATALOG_TYPE['single'],
                          COUPON_TYPE['enroll'],
                          VOUCHER_TYPE['single'],
                          start_datetime=FUTURE_START_DATE,
                          course_id=self.course_info,
                          seat_type=SEAT_TYPE['prof'],
                          stock_record_ids=self.stock_record_id)
     self.coupon.setup_coupons_using_api(self.course_price)
     coupon_code = self.coupon.coupon_codes[0]
     # Delete coupon after test
     self.addCleanup(self.coupon.delete_coupon)
     # Register to application using api
     self.register_using_api(
         construct_course_basket_page_url(self.course_id))
     self.assertEqual(
         self.error_message_on_invalid_coupon_code(coupon_code),
         FUTURE_CODE_ERROR.format(coupon_code))
コード例 #15
0
 def test_enrollment_single_use_code(self):
     """
     Scenario: Enrollment Single Use Code: Each code can be used by one
     person successfully
     """
     self.coupon = Coupon(COURSE_CATALOG_TYPE['single'],
                          COUPON_TYPE['enroll'],
                          VOUCHER_TYPE['single'],
                          course_id=self.course_info,
                          seat_type=SEAT_TYPE['prof'],
                          stock_record_ids=self.stock_record_id,
                          quantity=2)
     self.coupon.setup_coupons_using_api(self.course_price)
     coupon_codes = self.coupon.coupon_codes
     # Delete coupon after test
     self.addCleanup(self.coupon.delete_coupon)
     for coupon_code in coupon_codes:
         # Register to application using api
         self.register_using_api(
             construct_course_basket_page_url(self.course_id))
         self.enroll_using_enrollment_code(coupon_code)
         self.assert_enrollment_and_logout()