-
Notifications
You must be signed in to change notification settings - Fork 36
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
ca37a88
commit 557eed8
Showing
1 changed file
with
30 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""Runs tests on the robot APIs.""" | ||
|
||
import asyncio | ||
|
||
from fastapi.testclient import TestClient | ||
from pytest_mock.plugin import MockType | ||
|
||
from store.app.db import create_tables | ||
|
||
def test_robots(app_client: TestClient) -> None: | ||
asyncio.run(create_tables()) | ||
|
||
test_username = "test" | ||
test_email = "[email protected]" | ||
test_password = "test password" | ||
|
||
# Register. | ||
response = app_client.post("/users/register", json={"username": test_username, "email": test_email, "password": test_password}) | ||
assert response.status_code == 200 | ||
|
||
# Log in. | ||
response = app_client.post("/users/login", json={"email": test_email, "password": test_password}) | ||
assert response.status_code == 200 | ||
assert "session_token" in response.cookies | ||
|
||
# Create a part. | ||
response = app_client.post("/parts/add", json={"part_id": "", "owner": "", "name": "test part", "description": "test description", "images": [{"url": "", "caption": ""}]}) | ||
|
||
# Create a robot. | ||
response = app_client.post("/robots/add", json={"robot_id": "", "owner": "", "name": "test robot", "description": "test description", "bom": [], "images": [{"url": "", "caption": ""}]}) |