Example #1
0
class TestClient(TestCase):

    def setUp(self):
        ming.configure(**{
                'ming.zarkov.master':'mim:///',
                'ming.zarkov.database':'zarkov'})
        self.cli = ZarkovClient('tcp://localhost:6543')
        self.cli._sock = mock.Mock()

    def test_event_noval(self):
        self.cli.event_noval('nop', {'sample_context_key': 'sample_context_val'})
        assert self.cli._sock.send.call_count == 1
        sent = bson.BSON.decode(self.cli._sock.send.call_args[0][0])
        assert 'timestamp' in sent
        assert sent['$command'] == 'event_noval'
        assert sent['context'] == dict(sample_context_key='sample_context_val')
                
    def test_event(self):
        self.cli.event('nop', {'sample_context_key': 'sample_context_val'})
        assert self.cli._sock.send.call_count == 1
        assert bson.BSON.decode(self.cli._sock.send.call_args[0][0]) == dict(
            type='nop',
            extra=None,
            context=dict(
                sample_context_key='sample_context_val'))
Example #2
0
def runner(n, rate):
    cli = ZarkovClient('tcp://localhost:6543')
    tm_b = time.time()
    for chunk in xrange(n):
        for y in xrange(int(rate+1)):
            if n <= 0: return
            n -= 1
            cli.event_noval(
                type='foo',
                context=dict(
                    neighborhood='projects',
                    project='test',
                    tool='wiki',
                    app='home',
                    user='******'))
        to_wait = tm_b +  chunk + 1 - time.time()
        if to_wait > 0:
            gevent.sleep(to_wait)
Example #3
0
 def setUp(self):
     ming.configure(**{
             'ming.zarkov.master':'mim:///',
             'ming.zarkov.database':'zarkov'})
     self.cli = ZarkovClient('tcp://localhost:6543')
     self.cli._sock = mock.Mock()