Example #1
0
 def test_fetch_type(self):
     test_utils.wait_until(lambda : start.http_server.started)
     client = self.client
     client.create('Test', dict(testval=1, id='foo'))
     client.create('Test2', dict(testval=1, id='foo2'))
     models = client.fetch(typename='Test')
     assert len(models) == 1 and models[0].get('id') == 'foo'
Example #2
0
 def test_create(self):
     test_utils.wait_until(lambda : start.http_server.started)
     client = self.client
     client.create('Test', dict(testval=1, id='foo'))
     test_utils.wait_until(lambda : app.collections.get('Test', 'foo'))
     assert app.collections.get('Test', 'foo').get('testval') == 1
     assert client.fetch('Test', 'foo').get('testval') == 1
Example #3
0
 def test_delete(self):
     test_utils.wait_until(lambda : start.http_server.started)
     client = self.client                
     client.create('Test', dict(testval=1, id='foo'))
     client.create('Test', dict(testval=1, id='foo2'))
     client.delete('Test', 'foo')
     assert client.get('Test', 'foo') is None
     assert client.get('Test', 'foo2') is not None
Example #4
0
 def test_create(self):
     test_utils.wait_until(lambda : start.http_server.started)
     client = self.client
     model = make_model('Test', doc='defaultdoc',
                        testval=1, id='foo')
     client.create(model)
     test_utils.wait_until(lambda : app.collections.get('Test', 'defaultdoc', 'foo'))
     assert app.collections.get('Test', 'defaultdoc', 'foo').get('testval') == 1
     assert client.fetch('Test', 'foo').get('testval') == 1
Example #5
0
 def test_delete(self):
     test_utils.wait_until(lambda: start.http_server.started)
     client = self.client
     client.create(make_model('Test', doc='defaultdoc', testval=1,
                              id='foo'))
     client.create(
         make_model('Test', doc='defaultdoc', testval=1, id='foo2'))
     client.delete('Test', 'foo')
     assert client.get('Test', 'foo') is None
     assert client.get('Test', 'foo2') is not None
Example #6
0
 def test_fetch_type(self):
     test_utils.wait_until(lambda: start.http_server.started)
     client = self.client
     models = client.fetch(typename='Test')
     client.create(make_model('Test', doc='defaultdoc', testval=1,
                              id='foo'))
     client.create(
         make_model('Test2', doc='defaultdoc', testval=1, id='foo2'))
     models = client.fetch(typename='Test')
     assert len(models) == 1 and models[0].get('id') == 'foo'
Example #7
0
 def test_create(self):
     test_utils.wait_until(lambda: start.http_server.started)
     client = self.client
     model = make_model('Test', doc='defaultdoc', testval=1, id='foo')
     client.create(model)
     test_utils.wait_until(
         lambda: app.collections.get('Test', 'defaultdoc', 'foo'))
     assert app.collections.get('Test', 'defaultdoc',
                                'foo').get('testval') == 1
     assert client.fetch('Test', 'foo').get('testval') == 1
Example #8
0
 def test_update(self):
     test_utils.wait_until(lambda: start.http_server.started)
     client = self.client
     m = make_model('Test', doc='defaultdoc', testval=1, id='foo')
     client.create(m)
     m.set('testval', 2)
     client.update(m)
     test_utils.wait_until(lambda: app.collections.get(
         'Test', 'defaultdoc', 'foo').get('testval') == 2)
     assert app.collections.get('Test', 'defaultdoc',
                                'foo').get('testval') == 2
     assert client.get('Test', 'foo').get('testval') == 2
Example #9
0
 def test_fetch_docid(self):
     test_utils.wait_until(lambda : start.http_server.started)
     client = self.client
     client2 = self.client2
     client.create('Test', dict(testval=1, id='foo'))
     client.create('Test2', dict(testval=1, id='foo2'))
     client2.create('Test', dict(testval=1, id='foo3'))
     client2.create('Test2', dict(testval=1, id='foo4'))
     assert client.get('Test', 'foo').get('testval') == 1
     assert client.get('Test', 'foo3') is None
     assert client2.get('Test2', 'foo2') is None
     assert client2.get('Test', 'foo3').get('testval') == 1
Example #10
0
 def test_update(self):
     test_utils.wait_until(lambda : start.http_server.started)
     client = self.client
     m = make_model('Test', doc='defaultdoc', testval=1, id='foo')
     client.create(m)
     m.set('testval', 2)
     client.update(m)
     test_utils.wait_until(
         lambda : app.collections.get('Test', 'defaultdoc', 'foo').get('testval') == 2
         )
     assert app.collections.get('Test', 'defaultdoc', 'foo').get('testval') == 2
     assert client.get('Test', 'foo').get('testval') == 2
Example #11
0
 def tearDown(self):
     self.redisproc.close()
     if hasattr(self, 'rpcserver'):
         self.rpcserver.kill = True
         test_utils.wait_until(lambda : self.rpcserver.socket.closed)
         print 'rpcserver closed!'
     if hasattr(self, 'broker'):
         self.broker.kill = True
         def done():
             return self.broker.frontend.closed and self.broker.backend.closed
         test_utils.wait_until(done)
         print 'broker closed!'
     #we need this to wait for sockets to close, really annoying
     time.sleep(0.2)
Example #12
0
 def test_fetch_docid(self):
     test_utils.wait_until(lambda: start.http_server.started)
     client = self.client
     client2 = self.client2
     client.create(make_model('Test', doc='defaultdoc', testval=1,
                              id='foo'))
     client.create(
         make_model('Test2', doc='defaultdoc', testval=1, id='foo2'))
     client2.create(
         make_model('Test', doc='defaultdoc', testval=1, id='foo3'))
     client2.create(
         make_model('Test2', doc='defaultdoc', testval=1, id='foo4'))
     assert client.get('Test', 'foo').get('testval') == 1
     assert client.get('Test', 'foo3') is None
     assert client2.get('Test2', 'foo2') is None
     assert client2.get('Test', 'foo3').get('testval') == 1
Example #13
0
    def tearDown(self):
        self.redisproc.close()
        if hasattr(self, 'rpcserver'):
            self.rpcserver.kill = True
            test_utils.wait_until(lambda: self.rpcserver.socket.closed)
            print 'rpcserver closed!'
        if hasattr(self, 'broker'):
            self.broker.kill = True

            def done():
                return self.broker.frontend.closed and self.broker.backend.closed

            test_utils.wait_until(done)
            print 'broker closed!'
        #we need this to wait for sockets to close, really annoying
        time.sleep(0.2)
Example #14
0
 def test_ppirate_rpc(self):
     broker = arrayserverbroker.Broker(frontaddr, backaddr, self.config,
                                 timeout=100.0)
     broker.start()
     self.broker = broker
     rpcserver = TestRPCServer(backaddr, 'TEST', interval=100.0)
     rpcserver.start()
     test_utils.wait_until(lambda : len(broker.nodes) > 0)
     self.rpcserver = rpcserver
     rpcclient = client.ZDealerRPCClient(frontaddr)
     rpcclient.connect()
     data = [np.arange(2)]
     response, newdata  = rpcclient.rpc('echo', 'hello',
                                     dummykv='dummy', data=data)
     assert response['body'] == 'hello'
     assert response['dummykv'] == 'dummy'
     assert len(newdata) == 1
     assert (data[0] == newdata[0]).all()
Example #15
0
 def test_ppirate_rpc_arbitrary_data(self):
     broker = arrayserverbroker.Broker(frontaddr,
                                       backaddr,
                                       self.config,
                                       timeout=100.0)
     broker.start()
     self.broker = broker
     rpcserver = TestRPCServer(backaddr, 'TEST', interval=100.0)
     rpcserver.start()
     test_utils.wait_until(lambda: len(broker.nodes) > 0)
     self.rpcserver = rpcserver
     rpcclient = client.ZDealerRPCClient(frontaddr)
     rpcclient.connect()
     data = [{'hello': 'youarehere'}]
     response, newdata = rpcclient.rpc('echo',
                                       'hello',
                                       dummykv='dummy',
                                       data=data)
     assert response['body'] == 'hello'
     assert response['dummykv'] == 'dummy'
     assert len(newdata) == 1
     assert newdata[0] == data[0]