3453: Add ensure_unique_name=True to collection create.
[arvados.git] / sdk / python / tests / test_websockets.py
1 import run_test_server
2 import unittest
3 import arvados
4 import arvados.events
5 import time
6
7 class WebsocketTest(run_test_server.TestCaseWithServers):
8     MAIN_SERVER = {'websockets': True}
9
10     def on_event(self, ev):
11         if self.state == 1:
12             self.assertEqual(200, ev['status'])
13             self.state = 2
14         elif self.state == 2:
15             self.assertEqual(self.h[u'uuid'], ev[u'object_uuid'])
16             self.state = 3
17         elif self.state == 3:
18             self.fail()
19
20     def runTest(self):
21         self.state = 1
22
23         run_test_server.authorize_with("admin")
24         api = arvados.api('v1', cache=False)
25         arvados.events.subscribe(api, [['object_uuid', 'is_a', 'arvados#human']], lambda ev: self.on_event(ev))
26         time.sleep(1)
27         self.h = api.humans().create(body={}).execute()
28         time.sleep(1)