Example #1
0
def test_event_manager_publish():
    """Test that EventManager publishing to clients works"""
    saved_data = {
        "user_id": None,
        "title": "asdf",
        "content": "asdf",
        "team_id": None,
        "user": None,
        "team": None,
        "date": "2019-01-28T01:20:46.017649+00:00",
        "id": 10,
    }

    event_manager = EventManager()
    event_manager.clients.append(defaultdict(Queue))
    event_manager.publish(data=saved_data, type="notification", channel="ctf")

    event = event_manager.clients[0]["ctf"].get()
    event = ServerSentEvent(**event)
    assert event.data == saved_data
Example #2
0
def test_event_manager_publish():
    """Test that EventManager publishing to clients works"""
    saved_data = {
        'user_id': None,
        'title': 'asdf',
        'content': 'asdf',
        'team_id': None,
        'user': None,
        'team': None,
        'date': '2019-01-28T01:20:46.017649+00:00',
        'id': 10
    }

    event_manager = EventManager()
    event_manager.clients.append(defaultdict(Queue))
    event_manager.publish(data=saved_data, type='notification', channel='ctf')

    event = event_manager.clients[0]['ctf'].get()
    event = ServerSentEvent(**event)
    assert event.data == saved_data