예제 #1
0
    def test_broadcast(self):
        loop = asyncio.new_event_loop()
        asyncio.set_event_loop(loop)
        client = TestClient()
        com = SocketCommunication('host', 'port', 'url')
        com.clients.add(client)

        loop.run_until_complete(com.broadcast(dumps({
            'event': 'ingest:update',
            '_created': datetime.now().isoformat()})))
        self.assertEqual(1, len(client.messages))

        loop.run_until_complete(com.broadcast(dumps({
            'event': 'ingest:update',
            '_created': datetime.now().isoformat()})))
        self.assertEqual(1, len(client.messages))

        loop.run_until_complete(com.broadcast(dumps({
            'event': 'foo',
            '_created': datetime.now().isoformat()})))
        self.assertEqual(2, len(client.messages))

        loop.run_until_complete(com.broadcast(dumps({
            'event': 'foo',
            '_created': datetime.now().isoformat()})))
        self.assertEqual(3, len(client.messages))

        loop.run_until_complete(com.broadcast(dumps({
            'event': 'ingest:update',
            '_created': (datetime.now() + timedelta(seconds=3600)).isoformat()})))
        self.assertEqual(4, len(client.messages))
예제 #2
0
    def test_broadcast(self):
        loop = asyncio.new_event_loop()
        asyncio.set_event_loop(loop)
        client = TestClient()
        com = SocketCommunication('host', 'port', 'url')
        com.clients.add(client)

        loop.run_until_complete(
            com.broadcast(
                dumps({
                    'event': 'ingest:update',
                    '_created': datetime.now().isoformat()
                })))
        self.assertEqual(1, len(client.messages))

        loop.run_until_complete(
            com.broadcast(
                dumps({
                    'event': 'ingest:update',
                    '_created': datetime.now().isoformat()
                })))
        self.assertEqual(1, len(client.messages))

        loop.run_until_complete(
            com.broadcast(
                dumps({
                    'event': 'foo',
                    '_created': datetime.now().isoformat()
                })))
        self.assertEqual(2, len(client.messages))

        loop.run_until_complete(
            com.broadcast(
                dumps({
                    'event': 'foo',
                    '_created': datetime.now().isoformat()
                })))
        self.assertEqual(3, len(client.messages))

        loop.run_until_complete(
            com.broadcast(
                dumps({
                    'event':
                    'ingest:update',
                    '_created':
                    (datetime.now() + timedelta(seconds=3600)).isoformat()
                })))
        self.assertEqual(4, len(client.messages))
예제 #3
0
    def test_broadcast(self):
        loop = asyncio.new_event_loop()
        asyncio.set_event_loop(loop)
        client = TestClient()
        com = SocketCommunication("host", "port", "url")
        com.clients.add(client)

        loop.run_until_complete(
            com.broadcast(
                dumps({
                    "event": "ingest:update",
                    "_created": datetime.now().isoformat()
                })))
        self.assertEqual(1, len(client.messages))

        loop.run_until_complete(
            com.broadcast(
                dumps({
                    "event": "ingest:update",
                    "_created": datetime.now().isoformat()
                })))
        self.assertEqual(1, len(client.messages))

        loop.run_until_complete(
            com.broadcast(
                dumps({
                    "event": "foo",
                    "_created": datetime.now().isoformat()
                })))
        self.assertEqual(2, len(client.messages))

        loop.run_until_complete(
            com.broadcast(
                dumps({
                    "event": "foo",
                    "_created": datetime.now().isoformat()
                })))
        self.assertEqual(3, len(client.messages))

        loop.run_until_complete(
            com.broadcast(
                dumps({
                    "event":
                    "ingest:update",
                    "_created":
                    (datetime.now() + timedelta(seconds=3600)).isoformat()
                })))
        self.assertEqual(4, len(client.messages))