autocommit 09-07-2024-22-10
This commit is contained in:
parent
83c55333c9
commit
972e9f235b
|
|
@ -1 +1,3 @@
|
|||
.vscode
|
||||
__pycache__
|
||||
.hypothesis
|
||||
|
|
|
|||
|
|
@ -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__])
|
||||
Loading…
Reference in New Issue