Beispiel #1
0
async def test_fill_queue(service: EventService):

    queue = []
    service.record_event('1-2-3', 1, queue)
    service.record_event('2-3-4', 4, queue)

    assert queue == [
        dict(event_id='1-2-3', count=1),
        dict(event_id='2-3-4', count=4),
    ]
async def test_fill_queue(service: EventService):

    queue = []
    service.record_event("1-2-3", 0, queue)
    service.record_event("1-2-3", 1, queue)
    service.record_event("2-3-4", 4, queue)

    assert queue == [
        dict(event_id="1-2-3", count=1),
        dict(event_id="2-3-4", count=4),
    ]
Beispiel #3
0
async def test_record_multiple(service: EventService):
    content = '''{"updated_events": [
        { "event_id": "1-2-3", "count": 1},
        { "event_id": "2-3-4", "count": 4}
    ]}'''.encode('utf-8')
    service.api_accessor.api_post = CoroMock(return_value=(None, content))

    queue = []
    service.record_event('1-2-3', 1, queue)
    service.record_event('2-3-4', 4, queue)

    assert queue == [
        dict(event_id='1-2-3', count=1),
        dict(event_id='2-3-4', count=4),
    ]

    result = await service.execute_batch_update(42, queue)
    assert result == json.loads(content.decode('utf-8'))['updated_events']

    service.api_accessor.api_post.assert_called_once_with("/events/recordMultiple", 42, data=dict(updates=queue))
Beispiel #4
0
def service(api_accessor: ApiAccessor):
    return EventService(api_accessor)
Beispiel #5
0
def event_service(api_accessor):
    from server.stats.event_service import EventService
    return EventService(api_accessor)