Skip to content

Commit 39807ee

Browse files
added a test for get_requirements
1 parent 350e60e commit 39807ee

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

tests/rest_tests/rest_tests.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
import logging
33
import os
44
import time
5+
import yaml
56

67
from fastapi.testclient import TestClient
78

89
from bibigrid.core.startup_rest import app
9-
from bibigrid.core.utility.paths.basic_path import ROOT_PATH
10+
from bibigrid.core.utility.paths.basic_path import ROOT_PATH, CLOUD_NODE_REQUIREMENTS_PATH
1011

1112
logging.basicConfig(level=logging.DEBUG)
1213

@@ -16,7 +17,20 @@
1617
CLUSTER_ID = "4242424242"
1718

1819
client = TestClient(app)
20+
# Read the cloud_node_requirements YAML file and load it into a dictionary
1921

22+
with open(CLOUD_NODE_REQUIREMENTS_PATH, "r", encoding="utf-8") as cloud_node_requirements_file:
23+
cloud_node_requirements = yaml.safe_load(cloud_node_requirements_file)
24+
25+
def test_get_requirements():
26+
response = client.get("/bibigrid/requirements")
27+
28+
# Assert the response status code is 200
29+
assert response.status_code == 200
30+
31+
# Assert the structure of the returned JSON content
32+
assert response.json() == {"cloud_node_requirements": cloud_node_requirements}
33+
logging.info(f"Response: {response.json()}")
2034

2135
def test_validate():
2236
response = client.post(f"/bibigrid/validate?cluster_id={CLUSTER_ID}", json=configurations_json)
@@ -65,6 +79,7 @@ def test_state(state):
6579

6680
# Run tests
6781
if __name__ == "__main__":
82+
test_get_requirements()
6883
test_validate()
6984
test_create()
7085
test_state("starting")

0 commit comments

Comments
 (0)