Commit c1b5a22b by Clinton Blackburn Committed by Clinton Blackburn

Updated e2e tests

- Using JWT access token
- Fixed issue with state field on checkout form

ECOM-7099
parent 0135e93c
......@@ -11,9 +11,8 @@ def get_access_token():
(str, datetime)
"""
# TODO Use JWT auth once https://github.com/edx/edx-platform/pull/14577 is merged/released.
return EdxRestApiClient.get_oauth_access_token(
OAUTH_ACCESS_TOKEN_URL, OAUTH_CLIENT_ID, OAUTH_CLIENT_SECRET,
OAUTH_ACCESS_TOKEN_URL, OAUTH_CLIENT_ID, OAUTH_CLIENT_SECRET, token_type='jwt'
)
......@@ -33,7 +32,7 @@ class BearerAuth(AuthBase):
class EnrollmentApiClient(object):
def __init__(self):
access_token, __ = get_access_token()
self.client = EdxRestApiClient(ENROLLMENT_API_URL, oauth_access_token=access_token, append_slash=False)
self.client = EdxRestApiClient(ENROLLMENT_API_URL, jwt=access_token, append_slash=False)
def get_enrollment_status(self, username, course_id):
"""
......
......@@ -2,6 +2,7 @@ import logging
import time
import uuid
import datetime
import requests
from edx_rest_api_client.client import EdxRestApiClient
from selenium.common.exceptions import TimeoutException
......@@ -155,7 +156,7 @@ class EcommerceApiMixin(object):
@property
def ecommerce_api_client(self):
access_token, __ = get_access_token()
return EdxRestApiClient(ECOMMERCE_API_URL, oauth_access_token=access_token)
return EdxRestApiClient(ECOMMERCE_API_URL, jwt=access_token)
def assert_order_created_and_completed(self):
orders = self.ecommerce_api_client.orders.get()['results']
......@@ -273,19 +274,6 @@ class PaymentMixin(object):
""" Submit the payment form. """
self.wait_for_payment_form()
# Select the appropriate <option> elements
select_fields = (
('#id_country', address['country']),
('#id_state', address['state']),
('#card-expiry-month', '12'),
('#card-expiry-year', '2030')
)
for selector, value in select_fields:
if value:
select = Select(self.browser.find_element_by_css_selector(selector))
select.select_by_value(value)
# Fill in the text fields
billing_information = {
'id_first_name': 'Ed',
'id_last_name': 'Xavier',
......@@ -297,6 +285,28 @@ class PaymentMixin(object):
'card-cvn': '123'
}
country = address['country']
state = address['state'] or ''
card_expiry_year = str(datetime.datetime.now().year + 3)
select_fields = [
('#id_country', country),
('#card-expiry-month', '12'),
('#card-expiry-year', card_expiry_year),
]
if country in ('US', 'CA',):
select_fields.append(('#id_state', state,))
else:
billing_information['id_state'] = state
# Select the appropriate <option> elements
for selector, value in select_fields:
if value:
select = Select(self.browser.find_element_by_css_selector(selector))
select.select_by_value(value)
# Fill in the text fields
for field, value in billing_information.items():
self.browser.find_element_by_css_selector('#' + field).send_keys(value)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment