def test_partial_sync(self): parsed_dict = TestClass._load_response( "tests/data/sync.json") response = SyncResponse.from_dict(parsed_dict, 5) assert isinstance(response, PartialSyncResponse) assert len( response.rooms.join[ "!SVkFJHzfwvuaIEawgC:localhost" ].timeline.events ) == 0 assert len( response.rooms.join["!SVkFJHzfwvuaIEawgC:localhost"].state ) == 5 new_response = response.next_part(1) assert isinstance(new_response, PartialSyncResponse) assert len( new_response.rooms.join[ "!SVkFJHzfwvuaIEawgC:localhost" ].timeline.events ) == 0 assert len( new_response.rooms.join["!SVkFJHzfwvuaIEawgC:localhost"].state ) == 1 final_response = new_response.next_part() assert isinstance(final_response, SyncResponse) assert len( final_response.rooms.join[ "!SVkFJHzfwvuaIEawgC:localhost" ].timeline.events ) == 1
def test_sync_parse(self): parsed_dict = TestClass._load_response("tests/data/sync.json") response = SyncResponse.from_dict(parsed_dict) assert type(response) == SyncResponse
def test_sync_fail(self): parsed_dict = {} response = SyncResponse.from_dict(parsed_dict, 0) assert isinstance(response, SyncError)
async def events_from_sync(events, connector): response = SyncResponse.from_dict(sync_response(events)) return [m async for m in connector._parse_sync_response(response)]