diff --git a/py-kivy/.gitignore b/py-kivy/.gitignore index 722d5e7..10a81cc 100644 --- a/py-kivy/.gitignore +++ b/py-kivy/.gitignore @@ -1 +1,3 @@ .vscode +__pycache__ +.hypothesis diff --git a/py-kivy/testfastapi.py b/py-kivy/test_fastapi.py similarity index 94% rename from py-kivy/testfastapi.py rename to py-kivy/test_fastapi.py index 31c3f07..646f485 100644 --- a/py-kivy/testfastapi.py +++ b/py-kivy/test_fastapi.py @@ -2,12 +2,10 @@ import pytest from fastapi.testclient import TestClient from hypothesis import given, strategies as st from bson import ObjectId -from fastapi_server import app, db # Import your FastAPI app and database connection +from fastapi_server import app, db client = TestClient(app) -# Helper function to clear the database before each test - @pytest.fixture(autouse=True) def clear_db(): @@ -15,7 +13,9 @@ def clear_db(): yield db.items.delete_many({}) -# Traditional unit tests +# --======-----------==== +# Unit tests +# --======-----------==== def test_create_item(): @@ -81,7 +81,9 @@ def test_delete_item(): get_response = client.get(f"/items/{item_id}") assert get_response.status_code == 404 +# --======-----------==== # Property-based tests +# --======-----------==== @given( @@ -138,8 +140,6 @@ def test_read_items_property(items): assert "quantity" in retrieved_item assert "unit" in retrieved_item -# Add more property-based tests for update and delete operations if needed - if __name__ == "__main__": pytest.main([__file__])