Skip to content

Commit

Permalink
Amend tests to add polldevs to ZinoServer
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaengland committed Jul 25, 2024
1 parent 21e9d1d commit c32ffa0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions tests/api/legacy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,15 @@ async def test_when_command_raises_unhandled_exception_then_exception_should_be_
assert "ZeroDivisionError" in caplog.text

def test_when_connected_it_should_register_instance_in_server(self, event_loop):
server = ZinoServer(loop=event_loop, state=ZinoState())
server = ZinoServer(loop=event_loop, state=ZinoState(), polldevs=dict())
protocol = Zino1BaseServerProtocol(server=server)
fake_transport = Mock()
protocol.connection_made(fake_transport)

assert protocol in server.active_clients

def test_when_disconnected_it_should_deregister_instance_from_server(self, event_loop):
server = ZinoServer(loop=event_loop, state=ZinoState())
server = ZinoServer(loop=event_loop, state=ZinoState(), polldevs=dict())
protocol = Zino1BaseServerProtocol(server=server)
fake_transport = Mock()
protocol.connection_made(fake_transport)
Expand Down Expand Up @@ -638,7 +638,7 @@ async def test_should_output_error_response_for_unknown_router(self, authenticat
class TestZino1ServerProtocolNtieCommand:
@pytest.mark.asyncio
async def test_when_nonce_is_bogus_it_should_respond_with_error(self, event_loop, authenticated_protocol):
server = ZinoServer(loop=event_loop, state=ZinoState())
server = ZinoServer(loop=event_loop, state=ZinoState(), polldevs=dict())
server.notification_channels = dict() # Ensure there are none for this test
authenticated_protocol.server = server

Expand All @@ -649,7 +649,7 @@ async def test_when_nonce_is_bogus_it_should_respond_with_error(self, event_loop

@pytest.mark.asyncio
async def test_when_nonce_exists_it_should_respond_with_ok(self, event_loop, authenticated_protocol):
server = ZinoServer(loop=event_loop, state=ZinoState())
server = ZinoServer(loop=event_loop, state=ZinoState(), polldevs=dict())
nonce = get_challenge()
mock_channel = Mock()
server.notification_channels[nonce] = mock_channel
Expand All @@ -662,7 +662,7 @@ async def test_when_nonce_exists_it_should_respond_with_ok(self, event_loop, aut

@pytest.mark.asyncio
async def test_when_nonce_exists_it_should_tie_the_corresponding_channel(self, event_loop, authenticated_protocol):
server = ZinoServer(loop=event_loop, state=ZinoState())
server = ZinoServer(loop=event_loop, state=ZinoState(), polldevs=dict())
nonce = get_challenge()
mock_channel = Mock()
server.notification_channels[nonce] = mock_channel
Expand Down
10 changes: 5 additions & 5 deletions tests/api/notify_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_when_connected_then_peer_name_should_be_available(self):
assert protocol.peer_name == expected

def test_when_connected_it_should_register_instance_in_server(self, event_loop):
server = ZinoServer(loop=event_loop, state=ZinoState())
server = ZinoServer(loop=event_loop, state=ZinoState(), polldevs=dict())
protocol = Zino1NotificationProtocol(server=server)
fake_transport = Mock()
protocol.connection_made(fake_transport)
Expand All @@ -37,7 +37,7 @@ def test_when_connected_it_should_register_instance_in_server(self, event_loop):
assert server.notification_channels[protocol.nonce] is protocol

def test_when_disconnected_it_should_deregister_instance_from_server(self, event_loop):
server = ZinoServer(loop=event_loop, state=ZinoState())
server = ZinoServer(loop=event_loop, state=ZinoState(), polldevs=dict())
protocol = Zino1NotificationProtocol(server=server)
fake_transport = Mock()
protocol.connection_made(fake_transport)
Expand All @@ -55,14 +55,14 @@ def test_notify_should_output_text_line(self):
assert response.startswith(b"42 test data")

def test_tied_to_should_be_settable_and_gettable(self, event_loop):
server = ZinoServer(loop=event_loop, state=ZinoState())
server = ZinoServer(loop=event_loop, state=ZinoState(), polldevs=dict())
protocol = Zino1NotificationProtocol()

protocol.tied_to = server
assert protocol.tied_to == server

def test_goodbye_should_close_transport(self, event_loop):
server = ZinoServer(loop=event_loop, state=ZinoState())
server = ZinoServer(loop=event_loop, state=ZinoState(), polldevs=dict())
protocol = Zino1NotificationProtocol(server=server)
fake_transport = Mock()
protocol.connection_made(fake_transport)
Expand Down Expand Up @@ -121,7 +121,7 @@ def test_should_make_notifications_for_state_changes(self, fake_event):

class TestZino1NotificationProtocolBuildAndSendNotifications:
def test_should_send_notifications_only_to_tied_channels(self, event_loop, fake_event, changed_fake_event):
server = ZinoServer(loop=event_loop, state=ZinoState())
server = ZinoServer(loop=event_loop, state=ZinoState(), polldevs=dict())
channel1 = Mock()
channel2 = Mock()
mock_api = Mock()
Expand Down
2 changes: 1 addition & 1 deletion tests/api/server_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


def test_zinoserver_should_serve_without_error(event_loop):
server = ZinoServer(event_loop, ZinoState())
server = ZinoServer(loop=event_loop, state=ZinoState(), polldevs=dict())
server.serve()
server.notify_server.close()
server.api_server.close()

0 comments on commit c32ffa0

Please sign in to comment.