From 682d6b4e26a999018f64b908c95f771f370979b0 Mon Sep 17 00:00:00 2001 From: pmoharana-cmd Date: Mon, 22 Apr 2024 20:50:36 -0400 Subject: [PATCH] Resolve pytest changes --- backend/test/entities/sample_test.py | 21 --------------------- backend/test/services/user_test.py | 15 +++++++-------- 2 files changed, 7 insertions(+), 29 deletions(-) delete mode 100644 backend/test/entities/sample_test.py diff --git a/backend/test/entities/sample_test.py b/backend/test/entities/sample_test.py deleted file mode 100644 index d0cab09..0000000 --- a/backend/test/entities/sample_test.py +++ /dev/null @@ -1,21 +0,0 @@ -"""Sample Test File""" - -from sqlalchemy import Engine, select - -from ... import entities -from ...entities.sample_entity import SampleEntity - - -def test_entity_count(): - """Checks the number of entities to be inserted""" - print(entities.EntityBase.metadata.tables.keys()) - assert len(entities.EntityBase.metadata.tables.keys()) == 7 - - -def test_add_sample_data(session: Engine): - """Inserts a sample data point and verifies it is in the database""" - entity = SampleEntity(name="Praj", age=19, email="pmoha@unc.edu") - session.add(entity) - session.commit() - data = session.get(SampleEntity, 1) - assert data.name == "Praj" diff --git a/backend/test/services/user_test.py b/backend/test/services/user_test.py index 3f8b9b1..af91294 100644 --- a/backend/test/services/user_test.py +++ b/backend/test/services/user_test.py @@ -31,7 +31,7 @@ def test_create_id_exists(user_svc: UserService): def test_get_all(user_svc: UserService): """Test that all users can be retrieved.""" users = user_svc.all() - assert len(users) == 3 + assert len(users) == 4 def test_get_user_by_id(user_svc: UserService): @@ -56,12 +56,13 @@ def test_delete_user(user_svc: UserService): def test_delete_user_nonexistent(user_svc: UserService): """Test deleting a user that does not exist""" - with pytest.raises(Exception): + with pytest.raises(Exception): user_svc.delete(newUser) -def test_update_user(user_svc: UserService): + +def test_update_user(user_svc: UserService): """Test updating a user - Updating volunteer + Updating volunteer """ user = user_svc.get_user_by_id(volunteer.id) assert user is not None @@ -73,10 +74,8 @@ def test_update_user(user_svc: UserService): assert updated_user.username == "volunteer 1" assert updated_user.email == "newemail@compass.com" + def test_update_user_nonexistent(user_svc: UserService): - """ Test updated a user that does not exist""" + """Test updated a user that does not exist""" with pytest.raises(Exception): user_svc.update(newUser) - - -