Skip to content

Commit

Permalink
Cleaned up node server test
Browse files Browse the repository at this point in the history
  • Loading branch information
prologic committed May 30, 2015
1 parent 619940a commit 9d30d4e
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions tests/node/test_server.py
@@ -1,22 +1,26 @@
#!/usr/bin/env python


from __future__ import print_function

from pytest import PLATFORM, skip, fixture
from circuits import Event, Component, handler
from circuits.net.events import close
from circuits.net.sockets import UDPServer
from circuits.node import Node
from circuits.node.server import Server

if PLATFORM == 'win32':
skip('Broken on Windows')


from circuits import Event, Component
from circuits.net.events import close
from circuits.net.sockets import UDPServer
from circuits.node import Node


class return_value(Event):
success = True


class App(Component):

def return_value(self, event):
print('Hello client!', event.channels)

Expand Down Expand Up @@ -61,8 +65,7 @@ def test_auto_reconnect(app, watcher, manager):
app.unregister()
assert watcher.wait('unregistered', channel=app.channel)


for i in range(5):
for _ in range(5):
watcher.clear()
assert watcher.wait('connect', channel=chan)
assert watcher.wait('unreachable', channel=chan)
Expand All @@ -76,6 +79,7 @@ def test_auto_reconnect(app, watcher, manager):

client.unregister()


def test_server_send_all(app, watcher, manager):
client1 = App().register(manager)
node1 = Node().register(client1)
Expand All @@ -101,7 +105,6 @@ def test_server_send(app, watcher, manager):
chan1 = node1.add('client1', *app.bind)
assert watcher.wait('connected', channel=chan1)


client2 = App().register(manager)
node2 = Node().register(client2)
chan2 = node2.add('client2', *app.bind)
Expand All @@ -123,7 +126,6 @@ def test_server_send_multicast(app, watcher, manager):
chan1 = node1.add('client1', *app.bind)
assert watcher.wait('connected', channel=chan1)


client2 = App().register(manager)
node2 = Node().register(client2)
chan2 = node2.add('client2', *app.bind)
Expand All @@ -148,4 +150,4 @@ def test_server_send_multicast(app, watcher, manager):

client1.unregister()
client2.unregister()
client3.unregister()
client3.unregister()

0 comments on commit 9d30d4e

Please sign in to comment.