3 from __future__ import absolute_import, print_function
7 import arvnodeman.nodelist as nodelist
10 class ArvadosNodeListMonitorActorTestCase(testutil.RemotePollLoopActorTestMixin,
12 TEST_CLASS = nodelist.ArvadosNodeListMonitorActor
14 def build_monitor(self, side_effect, *args, **kwargs):
15 super(ArvadosNodeListMonitorActorTestCase, self).build_monitor(
17 self.client.nodes().list().execute.side_effect = side_effect
19 def test_uuid_is_subscription_key(self):
20 node = testutil.arvados_node_mock()
21 self.build_monitor([{'items': [node]}])
22 self.monitor.subscribe_to(node['uuid'],
23 self.subscriber).get(self.TIMEOUT)
24 self.stop_proxy(self.monitor)
25 self.subscriber.assert_called_with(node)
28 class CloudNodeListMonitorActorTestCase(testutil.RemotePollLoopActorTestMixin,
30 TEST_CLASS = nodelist.CloudNodeListMonitorActor
32 class MockNode(object):
33 def __init__(self, count):
35 self.name = 'test{}.example.com'.format(count)
36 self.private_ips = ['10.0.0.{}'.format(count)]
42 def build_monitor(self, side_effect, *args, **kwargs):
43 super(CloudNodeListMonitorActorTestCase, self).build_monitor(
45 self.client.list_nodes.side_effect = side_effect
47 def test_id_is_subscription_key(self):
48 node = self.MockNode(1)
49 self.build_monitor([[node]])
50 self.monitor.subscribe_to('1', self.subscriber).get(self.TIMEOUT)
51 self.stop_proxy(self.monitor)
52 self.subscriber.assert_called_with(node)
55 if __name__ == '__main__':