Adding initial camera functions
This commit is contained in:
33
tests/test_camera.py
Normal file
33
tests/test_camera.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from collections.abc import Generator
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
from flask.testing import FlaskClient
|
||||
|
||||
from src.app import app
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client() -> Generator[FlaskClient, Any, Any]:
|
||||
app.config["TESTING"] = True
|
||||
with app.test_client() as client:
|
||||
yield client
|
||||
|
||||
|
||||
def test_camera_start(client: FlaskClient) -> None:
|
||||
response = client.post("/camera/start")
|
||||
assert response.status_code == 200
|
||||
assert response.get_json()["status"] == "started"
|
||||
|
||||
|
||||
def test_camera_stop(client: FlaskClient) -> None:
|
||||
client.post("/camera/start")
|
||||
response = client.post("/camera/stop")
|
||||
assert response.status_code == 200
|
||||
assert response.get_json()["status"] == "stopped"
|
||||
|
||||
|
||||
def test_index_page(client: FlaskClient) -> None:
|
||||
response = client.get("/")
|
||||
assert response.status_code == 200
|
||||
assert b"Pi Camera" in response.data
|
||||
Reference in New Issue
Block a user