Commit 70d18d56 by Clinton Blackburn

Updated API gateway tests

The root path has changed from /discovery to /catalog.
parent f1aa2e90
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')
......
......@@ -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)
......
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