-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c67647e
commit b124460
Showing
3 changed files
with
49 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,32 @@ | ||
|
||
def test_get_commands(fastapi_test_client, commands_json): | ||
from fastapi.testclient import TestClient | ||
|
||
from backend.api.models.request_model import CommandRequest | ||
from backend.data.enums import CommandStatus | ||
|
||
|
||
def test_get_commands(fastapi_test_client: TestClient, commands_json): | ||
with fastapi_test_client as client: | ||
response = client.get("/commands/") | ||
assert response.status_code == 200 | ||
assert response.json() == {"data": commands_json} | ||
res = client.get("/commands/") | ||
assert res.status_code == 200 | ||
assert res.json() == {"data": commands_json} | ||
|
||
|
||
def test_create_command(fastapi_test_client: TestClient): | ||
command = CommandRequest(command_type=1, params="123456789") | ||
model_dump = command.model_dump() | ||
print(model_dump) | ||
with fastapi_test_client as client: | ||
res = client.post("/commands/", json=model_dump, headers={"Content-Type": "application/json"}) | ||
# res = client.post("/commands/", json=command) | ||
res.raise_for_status() | ||
assert res.status_code == 200 | ||
result = res.json().get("data") | ||
assert result is not None | ||
assert result.get("id") == 3 | ||
assert result.get("command_type") == 1 | ||
assert result.get("status") == CommandStatus.PENDING.value | ||
assert result.get("params") == "123456789" | ||
# TODO: Figure out a better way to check the times | ||
assert result.get("created_on") | ||
assert result.get("updated_on") |