Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
ecommerce
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
ecommerce
Commits
c1b5a22b
Commit
c1b5a22b
authored
Feb 24, 2017
by
Clinton Blackburn
Committed by
Clinton Blackburn
Feb 24, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated e2e tests
- Using JWT access token - Fixed issue with state field on checkout form ECOM-7099
parent
0135e93c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
17 deletions
+26
-17
e2e/api.py
+2
-3
e2e/mixins.py
+24
-14
No files found.
e2e/api.py
View file @
c1b5a22b
...
@@ -11,9 +11,8 @@ def get_access_token():
...
@@ -11,9 +11,8 @@ def get_access_token():
(str, datetime)
(str, datetime)
"""
"""
# TODO Use JWT auth once https://github.com/edx/edx-platform/pull/14577 is merged/released.
return
EdxRestApiClient
.
get_oauth_access_token
(
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):
...
@@ -33,7 +32,7 @@ class BearerAuth(AuthBase):
class
EnrollmentApiClient
(
object
):
class
EnrollmentApiClient
(
object
):
def
__init__
(
self
):
def
__init__
(
self
):
access_token
,
__
=
get_access_token
()
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
):
def
get_enrollment_status
(
self
,
username
,
course_id
):
"""
"""
...
...
e2e/mixins.py
View file @
c1b5a22b
...
@@ -2,6 +2,7 @@ import logging
...
@@ -2,6 +2,7 @@ import logging
import
time
import
time
import
uuid
import
uuid
import
datetime
import
requests
import
requests
from
edx_rest_api_client.client
import
EdxRestApiClient
from
edx_rest_api_client.client
import
EdxRestApiClient
from
selenium.common.exceptions
import
TimeoutException
from
selenium.common.exceptions
import
TimeoutException
...
@@ -155,7 +156,7 @@ class EcommerceApiMixin(object):
...
@@ -155,7 +156,7 @@ class EcommerceApiMixin(object):
@property
@property
def
ecommerce_api_client
(
self
):
def
ecommerce_api_client
(
self
):
access_token
,
__
=
get_access_token
()
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
):
def
assert_order_created_and_completed
(
self
):
orders
=
self
.
ecommerce_api_client
.
orders
.
get
()[
'results'
]
orders
=
self
.
ecommerce_api_client
.
orders
.
get
()[
'results'
]
...
@@ -273,19 +274,6 @@ class PaymentMixin(object):
...
@@ -273,19 +274,6 @@ class PaymentMixin(object):
""" Submit the payment form. """
""" Submit the payment form. """
self
.
wait_for_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
=
{
billing_information
=
{
'id_first_name'
:
'Ed'
,
'id_first_name'
:
'Ed'
,
'id_last_name'
:
'Xavier'
,
'id_last_name'
:
'Xavier'
,
...
@@ -297,6 +285,28 @@ class PaymentMixin(object):
...
@@ -297,6 +285,28 @@ class PaymentMixin(object):
'card-cvn'
:
'123'
'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
():
for
field
,
value
in
billing_information
.
items
():
self
.
browser
.
find_element_by_css_selector
(
'#'
+
field
)
.
send_keys
(
value
)
self
.
browser
.
find_element_by_css_selector
(
'#'
+
field
)
.
send_keys
(
value
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment