def test_client_account_sharing(self, client): client.receive_response(self.login_response) with pytest.raises(ValueError): client.decrypt_event(None) assert not client.olm_account_shared assert client.should_upload_keys assert client.device_store client.receive_response(KeysUploadResponse(49, 49)) assert client.should_upload_keys client.receive_response(KeysUploadResponse(50, 50)) assert not client.should_upload_keys
def test_client_key_query(self, client): assert not client.should_query_keys client.receive_response(self.login_response) client.receive_response(KeysUploadResponse(50, 50)) assert not client.should_query_keys client.receive_response(self.sync_response) assert not client.device_store.users assert client.rooms[TEST_ROOM_ID] room = client.rooms[TEST_ROOM_ID] assert room.encrypted assert room.summary assert len(room.users) == 1 assert room.member_count == 2 assert room.summary.joined_member_count == 2 assert client.should_query_keys assert not client.device_store.users client.receive_response(self.keys_query_response) assert not client.should_query_keys assert client.device_store.users assert not room.members_synced client.receive_response(self.joined_members) assert room.members_synced assert client.should_query_keys assert client.users_for_key_query == set([BOB_ID])
def test_client_room_creation(self, client): client.receive_response(self.login_response) client.receive_response(KeysUploadResponse(50, 50)) assert not client.should_query_keys client.receive_response(self.sync_response) assert client.rooms[TEST_ROOM_ID] room = client.rooms[TEST_ROOM_ID] assert room.encrypted assert client.should_query_keys
def test_device_store(self, tempdir): client = Client("ephemeral", "DEVICEID", tempdir) client.receive_response(self.login_response) client.receive_response(KeysUploadResponse(50, 50)) assert not client.should_query_keys client.receive_response(self.sync_response) client.receive_response(self.keys_query_response) assert list(client.device_store.users) == [ALICE_ID] alice_device = client.device_store[ALICE_ID][ALICE_DEVICE_ID] assert alice_device client = Client("ephemeral", "DEVICEID", tempdir) client.receive_response(self.login_response) assert list(client.device_store.users) == [ALICE_ID] alice_device = client.device_store[ALICE_ID][ALICE_DEVICE_ID] assert alice_device
def test_query_rule(self): client = Client("ephemeral", "DEVICEID", ephemeral_dir) client.receive_response(self.login_response) assert client.store is not None client.receive_response(KeysUploadResponse(50, 50)) assert not client.should_query_keys client.receive_response(self.sync_response) assert client.should_query_keys client.receive_response(self.keys_query_response) assert client.olm.tracked_users == set([ALICE_ID]) assert list(client.device_store.users) == [ALICE_ID] assert not client.should_query_keys del client client = Client("ephemeral", "DEVICEID", ephemeral_dir) client.receive_response(self.login_response) assert not client.should_upload_keys assert not client.should_query_keys assert list(client.device_store.users) == [ALICE_ID] assert client.device_store.active_user_devices(ALICE_ID) alice_device = client.device_store[ALICE_ID][ALICE_DEVICE_ID] assert alice_device client.receive_response(self.second_sync) assert client.should_query_keys client.users_for_key_query == set([ALICE_ID]) client.receive_response(self.joined_members) client.users_for_key_query == set([ALICE_ID, BOB_ID]) client.receive_response(self.keys_query_response) assert client.olm.tracked_users == set([ALICE_ID]) assert client.users_for_key_query == set([BOB_ID]) assert client.should_query_keys