diff --git a/server/src/networking.py b/server/src/networking.py index 6f5c363..27f4fbe 100644 --- a/server/src/networking.py +++ b/server/src/networking.py @@ -40,7 +40,7 @@ async def request_data(request: RequestData): def db_handle_friend_request(self, sender: str, receiver: str): db = DataBase() db.connect_db() - table_name = "testing_table" + table_name = "user_table" sentfriends_column = "sent_friends" if db.search_user(table_name, receiver): @@ -91,7 +91,7 @@ async def check_friends_list(user: str = Query(..., alias="sender")): } def db_fetch_all_friends(self, user): - table_name = "testing_table" + table_name = "user_table" db = DataBase() db.connect_db() friends_list = db.search_entry(table_name, user, "friends_list") @@ -119,7 +119,7 @@ def db_friend_request_response( ): db = DataBase() db.connect_db() - table_name = "testing_table" + table_name = "user_table" friend_column = "friends_list" pending_friends_column = "pending_friends" @@ -128,7 +128,7 @@ def db_friend_request_response( table_name, user, pending_friends_column, requester ) - if db.search_user("testing_table", requester): + if db.search_user("user_table", requester): # if answer is yes (true) if answer: # add to friends @@ -145,7 +145,7 @@ def db_friend_request_response( else: db.close_con() self.logger.info( - f"Requester '{requester}' not found in testing_table" + f"Requester '{requester}' not found in user_table" ) return "user not found" @@ -169,7 +169,7 @@ async def remove_friend(request: FriendRemoval): def db_remove_friend(self, user: str, friend: str): db = DataBase() db.connect_db() - table_name = "testing_table" + table_name = "user_table" friend_column = "friends_list" print(f"Removing {friend} from {user}'s friends list") @@ -211,7 +211,7 @@ async def cancel_friend_request(request: FriendRemoval): def db_cancel_friend_request(self, user: str, friend: str): db = DataBase() db.connect_db() - table_name = "testing_table" + table_name = "user_table" sent_friend_column = "sent_friends" pending_column = "pending_friends" diff --git a/server/tests/test_networking.py b/server/tests/test_networking.py index ebac59d..5f9323a 100644 --- a/server/tests/test_networking.py +++ b/server/tests/test_networking.py @@ -60,9 +60,9 @@ def test_send_friend_request_success(test_app): assert data["message"] == "Friend request to Bob sent successfully" # assert data.message == "Friend request to Bob sent successfully" - mock_db.search_user.assert_called_once_with("testing_table", "Bob") + mock_db.search_user.assert_called_once_with("user_table", "Bob") mock_db.search_entry.assert_called_once_with( - "testing_table", "Bob", "pending_friends" + "user_table", "Bob", "pending_friends" ) @@ -166,13 +166,13 @@ def test_request_response_accepted(test_app): # Check DB calls mock_db.remove_from_array.assert_called_once_with( - "testing_table", "Alice", "pending_friends", "Bob" + "user_table", "Alice", "pending_friends", "Bob" ) mock_db.append_entry.assert_any_call( - "testing_table", "Bob", "Alice", "friends_list" + "user_table", "Bob", "Alice", "friends_list" ) mock_db.append_entry.assert_any_call( - "testing_table", "Alice", "Bob", "friends_list" + "user_table", "Alice", "Bob", "friends_list" ) @@ -197,7 +197,7 @@ def test_request_response_rejected(test_app): # Check DB calls mock_db.remove_from_array.assert_called_once_with( - "testing_table", "Alice", "pending_friends", "Bob" + "user_table", "Alice", "pending_friends", "Bob" ) # Make sure no calls were made to append entries for either user @@ -222,10 +222,10 @@ def test_cancel_friend_request_success(test_app): assert response.json()["message"] == "Friend request removed successfully" mock_db.remove_from_array.assert_any_call( - "testing_table", "Alice", "sent_friends", "Bob" + "user_table", "Alice", "sent_friends", "Bob" ) mock_db.remove_from_array.assert_any_call( - "testing_table", "Bob", "pending_friends", "Alice" + "user_table", "Bob", "pending_friends", "Alice" ) @@ -264,10 +264,10 @@ def test_remove_friend_success(test_app): assert response.json()["message"] == "Friend removed successfully" mock_db.remove_from_array.assert_any_call( - "testing_table", "Alice", "friends_list", "Bob" + "user_table", "Alice", "friends_list", "Bob" ) mock_db.remove_from_array.assert_any_call( - "testing_table", "Bob", "friends_list", "Alice" + "user_table", "Bob", "friends_list", "Alice" )