Skip to content

Commit

Permalink
Fix unit test to pass
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamin-lawson committed Mar 6, 2024
1 parent 37626aa commit 1de3e72
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions tests/unit_tests/test_lobbyconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,22 +161,28 @@ async def test_bad_command_calls_abort(lobbyconnection):


async def test_database_outage_error_responds_cleanly(lobbyconnection):
lobbyconnection.send = mock.AsyncMock()
lobbyconnection.abort = mock.AsyncMock()
lobbyconnection.check_policy_conformity = mock.AsyncMock(return_value=True)
lobbyconnection.send = mock.AsyncMock()

def mock_ensure_authenticated(cmd):
raise OperationalError(statement='', params=[], orig=None)

Check warning on line 169 in tests/unit_tests/test_lobbyconnection.py

View workflow job for this annotation

GitHub Actions / flake8

Single quotes found but double quotes preferred

lobbyconnection.ensure_authenticated = mock_ensure_authenticated

Check warning on line 172 in tests/unit_tests/test_lobbyconnection.py

View workflow job for this annotation

GitHub Actions / flake8

blank line contains whitespace

Check notice on line 172 in tests/unit_tests/test_lobbyconnection.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

tests/unit_tests/test_lobbyconnection.py#L172

Trailing whitespace
with pytest.raises(OperationalError):
await lobbyconnection.on_message_received({
"command": "hello",
"login": "test",
"password": sha256(b"test_password").hexdigest(),
"unique_id": "blah"
})
await lobbyconnection.on_message_received({
"command": "hello",
"login": "test",
"password": sha256(b"test_password").hexdigest(),
"unique_id": "blah"
})

Check warning on line 179 in tests/unit_tests/test_lobbyconnection.py

View workflow job for this annotation

GitHub Actions / flake8

blank line contains whitespace
lobbyconnection.send.assert_called_once_with({
"command": "notice",
"style": "error",
"text": "Unable to connect to database. Please try again later."
})

Check warning on line 185 in tests/unit_tests/test_lobbyconnection.py

View workflow job for this annotation

GitHub Actions / flake8

blank line contains whitespace
lobbyconnection.abort.assert_called_once_with("Error connecting to database")


Expand Down

0 comments on commit 1de3e72

Please sign in to comment.