Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions server/src/networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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"

Expand All @@ -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
Expand All @@ -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"

Expand All @@ -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")
Expand Down Expand Up @@ -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"

Expand Down
20 changes: 10 additions & 10 deletions server/tests/test_networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)


Expand Down Expand Up @@ -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"
)


Expand All @@ -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
Expand All @@ -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"
)


Expand Down Expand Up @@ -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"
)


Expand Down
Loading