Skip to content

Commit b95de1c

Browse files
CMSNAV-798: Add example .env file
1 parent 67e7bc9 commit b95de1c

3 files changed

Lines changed: 27 additions & 16 deletions

File tree

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
SHELL=/bin/bash -euo pipefail
22

3+
include .env
4+
export
5+
36
#Installs dependencies using poetry.
47
install-python:
58
poetry install
@@ -58,7 +61,7 @@ TEST_CMD := @APIGEE_ACCESS_TOKEN=$(APIGEE_ACCESS_TOKEN) \
5861
poetry run pytest -v \
5962
--color=yes \
6063
--api-name=nhs-website-content-api \
61-
--proxy-name=$(PROXY_NAME) \
64+
--proxy-name=$(PROXY_NAME) \
6265
-s
6366

6467
PROD_TEST_CMD := $(TEST_CMD) \

example.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
APIGEE_ACCESS_TOKEN=FOR-YOUR-EYES-ONLY
2+
PROXY_NAME=nhs-website-content-api-internal-dev
3+
SOURCE_COMMIT_ID=FOR-YOUR-EYES-ONLY

tests/test_endpoints.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
def test_ping(nhsd_apim_proxy_url):
1313
os.environ["PROXY_NAME"] = "dev"
14-
with open("smeg.txt", "w") as smeg:
15-
smeg.write(str(nhsd_apim_proxy_url))
1614
resp = requests.get(f"{nhsd_apim_proxy_url}/_ping")
1715
assert resp.status_code == 200
1816

@@ -22,20 +20,23 @@ def test_wait_for_ping(nhsd_apim_proxy_url):
2220
resp = requests.get(f"{nhsd_apim_proxy_url}/_ping")
2321
deployed_commit_id = resp.json().get("commitId")
2422

25-
while (deployed_commit_id != getenv('SOURCE_COMMIT_ID')
26-
and retries <= 30
27-
and resp.status_code == 200):
23+
while (
24+
deployed_commit_id != getenv('SOURCE_COMMIT_ID') and
25+
retries <= 30 and
26+
resp.status_code == 200
27+
):
2828
resp = requests.get(f"{nhsd_apim_proxy_url}/_ping")
2929
deployed_commit_id = resp.json().get("commitId")
3030
retries += 1
3131

3232
if resp.status_code != 200:
3333
pytest.fail(f"Status code {resp.status_code}, expecting 200")
34-
elif retries >= 30:
35-
pytest.fail("Timeout Error - max retries")
3634

3735
assert deployed_commit_id == getenv('SOURCE_COMMIT_ID')
3836

37+
if retries >= 30:
38+
pytest.fail("Timeout Error - max retries")
39+
3940

4041
@pytest.mark.smoketest
4142
@pytest.mark.skip(reason="Dont need to run on prod")
@@ -53,23 +54,27 @@ def test_wait_for_status(nhsd_apim_proxy_url, status_endpoint_auth_headers):
5354
resp = requests.get(f"{nhsd_apim_proxy_url}/_status", headers=status_endpoint_auth_headers)
5455
deployed_commit_id = resp.json().get("commitId")
5556

56-
while (deployed_commit_id != getenv('SOURCE_COMMIT_ID')
57-
and retries <= 30
58-
and resp.status_code == 200
59-
and resp.json().get("version")):
57+
while (
58+
deployed_commit_id != getenv('SOURCE_COMMIT_ID') and
59+
retries <= 30 and
60+
resp.status_code == 200 and
61+
resp.json().get("version")
62+
):
6063
resp = requests.get(f"{nhsd_apim_proxy_url}/_status", headers=status_endpoint_auth_headers)
6164
deployed_commit_id = resp.json().get("commitId")
6265
retries += 1
6366

6467
if resp.status_code != 200:
6568
pytest.fail(f"Status code {resp.status_code}, expecting 200")
66-
elif retries >= 30:
67-
pytest.fail("Timeout Error - max retries")
68-
elif not resp.json().get("version"):
69-
pytest.fail("version not found")
7069

7170
assert deployed_commit_id == getenv('SOURCE_COMMIT_ID')
7271

72+
if retries >= 30:
73+
pytest.fail("Timeout Error - max retries")
74+
75+
if not resp.json().get("version"):
76+
pytest.fail("version not found")
77+
7378

7479
def test_app_unauthorised(nhsd_apim_proxy_url, nhsd_apim_auth_headers):
7580
resp = requests.get(f"{nhsd_apim_proxy_url}/conditions/", headers=nhsd_apim_auth_headers)

0 commit comments

Comments
 (0)