fix idiocies and so make tests pass

This commit is contained in:
Matthew Hodgson 2017-12-31 14:35:25 +00:00 committed by Hubert Chathi
parent 174be586e5
commit 15d513f16f
3 changed files with 15 additions and 11 deletions

View File

@ -207,6 +207,7 @@ class EndToEndRoomKeyStore(SQLBaseStore):
this_version = version
return self._simple_select_one_txn(
txn,
table="e2e_room_keys_versions",
keyvalues={
"user_id": user_id,
@ -243,9 +244,9 @@ class EndToEndRoomKeyStore(SQLBaseStore):
)
current_version = txn.fetchone()[0]
if current_version is None:
current_version = 0
current_version = '0'
new_version = current_version + 1
new_version = str(int(current_version) + 1)
self._simple_insert_txn(
txn,

View File

@ -35,4 +35,4 @@ CREATE TABLE e2e_room_keys_versions (
auth_data TEXT NOT NULL
);
CREATE UNIQUE INDEX e2e_room_keys_versions_user_idx ON e2e_room_keys_versions(user_id);
CREATE UNIQUE INDEX e2e_room_keys_versions_idx ON e2e_room_keys_versions(user_id, version);

View File

@ -37,7 +37,7 @@ class E2eRoomKeysHandlerTestCase(unittest.TestCase):
handlers=None,
replication_layer=mock.Mock(),
)
self.handler = synapse.handlers.e2e_keys.E2eRoomKeysHandler(self.hs)
self.handler = synapse.handlers.e2e_room_keys.E2eRoomKeysHandler(self.hs)
@defer.inlineCallbacks
@ -46,6 +46,7 @@ class E2eRoomKeysHandlerTestCase(unittest.TestCase):
if there is no version.
"""
local_user = "@boris:" + self.hs.hostname
res = None
try:
res = yield self.handler.get_version_info(local_user);
except errors.SynapseError as e:
@ -58,6 +59,7 @@ class E2eRoomKeysHandlerTestCase(unittest.TestCase):
if it doesn't exist.
"""
local_user = "@boris:" + self.hs.hostname
res = None
try:
res = yield self.handler.get_version_info(local_user, "mrflibble");
except errors.SynapseError as e:
@ -69,7 +71,7 @@ class E2eRoomKeysHandlerTestCase(unittest.TestCase):
"""Check that we can create and then retrieve versions.
"""
local_user = "@boris:" + self.hs.hostname
res = yield self.handler.create_version(user_id, {
res = yield self.handler.create_version(local_user, {
"algorithm": "m.megolm_backup.v1",
"auth_data": "first_version_auth_data",
});
@ -92,7 +94,7 @@ class E2eRoomKeysHandlerTestCase(unittest.TestCase):
});
# upload a new one...
res = yield self.handler.create_version(user_id, {
res = yield self.handler.create_version(local_user, {
"algorithm": "m.megolm_backup.v1",
"auth_data": "second_version_auth_data",
});
@ -111,7 +113,7 @@ class E2eRoomKeysHandlerTestCase(unittest.TestCase):
"""Check that we can create and then delete versions.
"""
local_user = "@boris:" + self.hs.hostname
res = yield self.handler.create_version(user_id, {
res = yield self.handler.create_version(local_user, {
"algorithm": "m.megolm_backup.v1",
"auth_data": "first_version_auth_data",
});
@ -121,6 +123,7 @@ class E2eRoomKeysHandlerTestCase(unittest.TestCase):
yield self.handler.delete_version(local_user, "1");
# check that it's gone
res = None
try:
res = yield self.handler.get_version_info(local_user, "1");
except errors.SynapseError as e:
@ -130,12 +133,12 @@ class E2eRoomKeysHandlerTestCase(unittest.TestCase):
@defer.inlineCallbacks
def test_get_room_keys(self):
pass
yield None
@defer.inlineCallbacks
def test_upload_room_keys(self):
pass
yield None
@defer.inlineCallbacks
def test_delete_room_keys(self):
pass
yield None