示例#1
0
 def redeem_single_course_enrollment_coupon(self, coupon_url, target_page):
     """
     Redeem single course enrollment coupon
     Args
         coupon_url: Url of the coupon.
         target_page: Destination page.
     """
     redeem_coupon_page = RedeemCouponPage(self.browser, coupon_url).visit()
     redeem_coupon_page.wait_for_course_tile()
     self.verify_course_info_on_coupon_redeem_page(redeem_coupon_page)
     redeem_coupon_page.redeem_enrollment(target_page)
示例#2
0
 def test_apply_enrollment_once_per_customer_redeem_url(self):
     """
     Scenario: Registered Users: Dynamic Enrollment Once Per Customer
     Redeem URL: Each URL 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)
     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()
             self.redeem_multi_course_enrollment_coupon(
                 coupon_code, self.login_page, self.course_title)
             self.login_page.authenticate_user("coupon_user", PASSWORD)
             self.receipt_page.wait_for_page()
             self.verify_receipt_info_for_discounted_course()
             self.receipt_page.click_in_nav_to_go_to_dashboard()
             self.dashboard_page.wait_for_page()
             self.assert_enrollment_and_logout()
         else:
             self.register_using_api()
             redeem_coupon = RedeemCouponPage(self.browser,
                                              coupon_code).visit()
             self.assertEqual(redeem_coupon.error_message,
                              ONCE_PER_CUSTOMER_REDEEM_URL_MAX_LIMIT)
    def test_discount_once_per_customer_fixed_redeem_url_future(self):
        """
        Scenario: Discount Once Per Customer Fixed Redeem URL: Relevant error
        message is displayed on the use of future redeem url
        """

        self.coupon = Coupon(COURSE_CATALOG_TYPE['single'],
                             COUPON_TYPE['disc'],
                             VOUCHER_TYPE['once_per_cust'],
                             start_datetime=FUTURE_START_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'],
                             max_uses=2)

        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()
        redeem_coupon = RedeemCouponPage(self.browser, coupon_code).visit()
        self.assertEqual(redeem_coupon.error_message, FUTURE_REDEEM_URL_ERROR)
    def test_discount_once_per_customer_percentage_redeem_url(self):
        """
        Scenario: Inactive Users - Discount Once Per Customer Percentage
        Redeem URL: URL cannot be used twice by he same user
        """
        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['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)
        self.home.visit()
        self.redeem_single_course_discount_coupon(coupon_code)
        self.login_page.wait_for_page()
        self.login_page.toggle_to_registration_page()
        self.registration_page.wait_for_page()
        user_name = str(uuid.uuid4().node)
        temp_mail = user_name + "@example.com"

        self.registration_page.register_white_label_user(
            get_white_label_registration_fields(email=temp_mail,
                                                username=user_name))
        self.single_seat_basket.wait_for_page()
        self.make_payment_after_discount()
        self.assert_course_added_to_dashboard()
        redeem_coupon = RedeemCouponPage(self.browser, coupon_code).visit()
        self.assertEqual(redeem_coupon.error_message,
                         ONCE_PER_CUSTOMER_REDEEM_URL_SAME_USER_REUSE)
示例#5
0
    def redeem_single_course_discount_coupon(self, coupon_url):
        """
        Redeem single course discount coupon.

        Arguments:
            coupon_url: Url of the coupon.
        """
        redeem_coupon_page = RedeemCouponPage(self.browser, coupon_url)
        redeem_coupon_page.visit()
        redeem_coupon_page.wait_for_course_tile()
        self.verify_course_info_on_coupon_redeem_page(redeem_coupon_page)
        redeem_coupon_page.click_checkout_button(self.course_id)
 def redeem_multi_course_enrollment_coupon(self, coupon_url, target_page,
                                           course_title):
     """
     Redeem single course enrollment coupon
     Args
         coupon_url: Url of the coupon.
         target_page: Destination page.
         course_title: Title of the course.
     """
     redeem_coupon_page = RedeemCouponPage(self.browser, coupon_url).visit()
     redeem_coupon_page.wait_for_course_tile()
     redeem_coupon_page.set_course_tile_index(course_title)
     self.verify_course_info_on_coupon_redeem_page(redeem_coupon_page)
     redeem_coupon_page.redeem_enrollment(target_page)
示例#7
0
    def redeem_single_course_discount_coupon(self, coupon_url):
        """
        Redeem single course discount coupon.

        Arguments:
            coupon_url: Url of the coupon.
        """
        redeem_coupon_page = RedeemCouponPage(self.browser, coupon_url)
        redeem_coupon_page.visit()
        redeem_coupon_page.wait_for_course_tile()
        self.verify_course_info_on_coupon_redeem_page(redeem_coupon_page)
        redeem_coupon_page.click_checkout_button(self.course_id)
示例#8
0
 def redeem_single_course_enrollment_coupon(self, coupon_code, target_page):
     """
     Redeem single course enrollment coupon
     Args
         coupon_code: coupon_code to use as part of the url.
         target_page: Destination page.
     """
     redeem_coupon_page = RedeemCouponPage(self.browser, coupon_code).visit()
     redeem_coupon_page.wait_for_course_tile()
     self.verify_course_info_on_coupon_redeem_page(redeem_coupon_page)
     redeem_coupon_page.redeem_enrollment(target_page)
 def test_enrollment_once_per_customer_redeem_url_expired(self):
     """
     Scenario: Enrollment Once Per Customer Redeem URL: Relevant error
     message is displayed on the use of expired redeem url
     """
     self.coupon = Coupon(COURSE_CATALOG_TYPE['single'],
                          COUPON_TYPE['enroll'],
                          VOUCHER_TYPE['once_per_cust'],
                          end_datetime=EXPIRED_END_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()
     redeem_coupon = RedeemCouponPage(self.browser, coupon_code).visit()
     self.assertEqual(redeem_coupon.error_message, EXPIRED_REDEEM_URL_ERROR)