Skip to content

Commit

Permalink
tests: Add some placeholder json endpoint tests
Browse files Browse the repository at this point in the history
The endpoints "Server" and "log" have not been fully implemented in the
simulator api. Neither in the html or json API. To account for some of
the endpoints in the future, add a placeholder for the calls to make
sure they are filled in once the implementation is finished.

Signed-off-by: Esa Laakso <[email protected]>
  • Loading branch information
efdx committed Aug 5, 2024
1 parent 70aa833 commit 8d44545
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions test/sub_server/test_simulator_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,3 +384,83 @@ async def test_calls_json_simulate_reset_with_simulation(self, client, simulator

json_response = await resp.json()
assert json_response["result"] == "ok"

@pytest.mark.asyncio()
async def test_log_json_download(self, client, simulator):
"""
Test the /restapi/log endpoint with a download request.
This test is just a placeholder at the moment to make sure the endpoint
is reachable. The actual functionality is not implemented.
"""
url = f"http://{simulator.http_host}:{simulator.http_port}/restapi/log"
data = {
"submit": "Download",
}

# The call is undefined. Just make sure it returns 200
async with client.post(url, json=data) as resp:
assert resp.status == 200

json_response = await resp.json()
assert json_response["error"] == "log endpoint not implemented"

@pytest.mark.asyncio()
async def test_log_json_monitor(self, client, simulator):
"""
Test the /restapi/log endpoint with a monitor request.
This test is just a placeholder at the moment to make sure the endpoint
is reachable. The actual functionality is not implemented.
"""
url = f"http://{simulator.http_host}:{simulator.http_port}/restapi/log"
data = {
"submit": "Monitor",
}

# The call is undefined. Just make sure it returns 200
async with client.post(url, json=data) as resp:
assert resp.status == 200

json_response = await resp.json()
assert json_response["error"] == "log endpoint not implemented"

@pytest.mark.asyncio()
async def test_log_json_clear(self, client, simulator):
"""
Test the /restapi/log endpoint with a clear request.
This test is just a placeholder at the moment to make sure the endpoint
is reachable. The actual functionality is not implemented.
"""
url = f"http://{simulator.http_host}:{simulator.http_port}/restapi/log"
data = {
"submit": "Clear",
}

# The call is undefined. Just make sure it returns 200
async with client.post(url, json=data) as resp:
assert resp.status == 200

json_response = await resp.json()
assert json_response["error"] == "log endpoint not implemented"

@pytest.mark.asyncio()
async def test_server_json_restart(self, client, simulator):
"""
Test the /restapi/server endpoint with a restart request.
This test is just a placeholder at the moment to make sure the endpoint
is reachable. The actual functionality is not implemented.
"""
url = f"http://{simulator.http_host}:{simulator.http_port}/restapi/server"
data = {
"submit": "Restart",
}

# The call is undefined. Just make sure it returns 200
async with client.post(url, json=data) as resp:
assert resp.status == 200

json_response = await resp.json()
assert json_response["error"] == "server endpoint not implemented"

0 comments on commit 8d44545

Please sign in to comment.