Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
course-discovery
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
course-discovery
Commits
efcb54c1
Commit
efcb54c1
authored
Apr 28, 2016
by
Clinton Blackburn
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #88 from edx/clintonb/gateway-update
Updated API gateway tests
parents
f1aa2e90
70d18d56
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
9 deletions
+9
-9
acceptance_tests/config.py
+6
-6
acceptance_tests/test_api_gateway.py
+3
-3
No files found.
acceptance_tests/config.py
View file @
efcb54c1
import
os
API_GATEWAY_
DISCOVERY_ROOT
=
os
.
environ
.
get
(
'API_GATEWAY_DISCOVERY
_ROOT'
)
if
not
API_GATEWAY_
DISCOVERY
_ROOT
:
raise
RuntimeError
(
'API_GATEWAY_
DISCOVERY_ROOT (e.g. https://api.edx.org/discovery
/v1) must be supplied!'
)
API_GATEWAY_
CATALOG_ROOT
=
os
.
environ
.
get
(
'API_GATEWAY_CATALOG
_ROOT'
)
if
not
API_GATEWAY_
CATALOG
_ROOT
:
raise
RuntimeError
(
'API_GATEWAY_
CATALOG_ROOT (e.g. https://api.edx.org/catalog
/v1) must be supplied!'
)
DISCOVERY_API_ACCESS_TOKEN
=
os
.
environ
.
get
(
'DISCOVERY_
API_ACCESS_TOKEN'
)
if
not
DISCOVERY_
API_ACCESS_TOKEN
:
raise
RuntimeError
(
'
DISCOVERY_
API_ACCESS_TOKEN must be supplied!'
)
API_ACCESS_TOKEN
=
os
.
environ
.
get
(
'
API_ACCESS_TOKEN'
)
if
not
API_ACCESS_TOKEN
:
raise
RuntimeError
(
'API_ACCESS_TOKEN must be supplied!'
)
CATALOG_ID
=
int
(
os
.
environ
.
get
(
'CATALOG_ID'
,
1
))
COURSE_ID
=
os
.
environ
.
get
(
'COURSE_ID'
,
'edX/DemoX'
)
...
...
acceptance_tests/test_api_gateway.py
View file @
efcb54c1
...
...
@@ -4,7 +4,7 @@ from unittest import TestCase
import
ddt
import
requests
from
acceptance_tests.config
import
API_GATEWAY_
DISCOVERY_ROOT
,
DISCOVERY_
API_ACCESS_TOKEN
,
CATALOG_ID
from
acceptance_tests.config
import
API_GATEWAY_
CATALOG_ROOT
,
API_ACCESS_TOKEN
,
CATALOG_ID
@ddt.ddt
...
...
@@ -17,7 +17,7 @@ class ApiGatewayTests(TestCase):
def
get_discovery_api_gateway_url
(
self
,
path
):
""" Returns a complete URL for the given path, routed through the API gateway. """
return
'{root}/{path}'
.
format
(
root
=
API_GATEWAY_
DISCOVERY
_ROOT
.
rstrip
(
'/'
),
path
=
path
)
return
'{root}/{path}'
.
format
(
root
=
API_GATEWAY_
CATALOG
_ROOT
.
rstrip
(
'/'
),
path
=
path
)
def
assert_api_response
(
self
,
path
,
expected_status_code
=
200
,
**
headers
):
"""
...
...
@@ -36,7 +36,7 @@ class ApiGatewayTests(TestCase):
def
test_endpoint_ok
(
self
,
path
):
""" Verify the endpoint returns HTTP 200 for valid requests. """
headers
=
{
'Authorization'
:
'Bearer {token}'
.
format
(
token
=
DISCOVERY_
API_ACCESS_TOKEN
)
'Authorization'
:
'Bearer {token}'
.
format
(
token
=
API_ACCESS_TOKEN
)
}
self
.
assert_api_response
(
path
,
**
headers
)
...
...
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