diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-01-28 11:26:29 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-01-29 19:28:34 +0000 |
commit | 70272b8fd90c65700bd0f6a8d7a4cc3849d42e21 (patch) | |
tree | c8d570c2d0e641552d842b128ef14397ad6dfa33 | |
parent | ed7bf646a77630de9e24641d5ca889904132fe85 (diff) |
Only exercise old avatar storage locations in 5-12 and 5-14 tests
Otherwise, it will reduce test coverage while porting to Telepathy 1.0:
all the tests dealing with old locations need to be disabled until we
implement 0.x -> 1.0 migration.
-rw-r--r-- | tests/twisted/account-manager/auto-connect.py | 9 | ||||
-rw-r--r-- | tests/twisted/account-manager/avatar-refresh.py | 22 | ||||
-rw-r--r-- | tests/twisted/account-storage/storage_helper.py | 25 |
3 files changed, 33 insertions, 23 deletions
diff --git a/tests/twisted/account-manager/auto-connect.py b/tests/twisted/account-manager/auto-connect.py index 46b13364..28cfb2ab 100644 --- a/tests/twisted/account-manager/auto-connect.py +++ b/tests/twisted/account-manager/auto-connect.py @@ -21,6 +21,7 @@ import dbus """ import os +import os.path import dbus import dbus.service @@ -65,8 +66,12 @@ def preseed(q, bus, fake_accounts_service): 'password': r'\\\\ionstorm\\\\', }) - os.makedirs(accounts_dir + '/' + account_id) - avatar_bin = open(accounts_dir + '/' + account_id + '/avatar.bin', 'w') + avatar_filename = account_id + avatar_filename = avatar_filename.replace('/', '-') + '.avatar' + avatar_filename = (os.environ['XDG_DATA_HOME'] + + '/telepathy/mission-control/' + avatar_filename) + os.makedirs(os.path.dirname(avatar_filename)) + avatar_bin = open(avatar_filename, 'w') avatar_bin.write('Deus Ex') avatar_bin.close() diff --git a/tests/twisted/account-manager/avatar-refresh.py b/tests/twisted/account-manager/avatar-refresh.py index f76d7fb6..d914c439 100644 --- a/tests/twisted/account-manager/avatar-refresh.py +++ b/tests/twisted/account-manager/avatar-refresh.py @@ -90,15 +90,6 @@ class Account(object): avatar_bin = open(avatar_filename, 'w') avatar_bin.write(local_avatar) avatar_bin.close() - elif not avatars_persist: - self.avatar_location = 'old' - # exercise migration from ~/.mission-control in a - # situation where MC should "win" - os.makedirs(accounts_dir + '/' + self.id) - avatar_bin = open( - accounts_dir + '/' + self.id + '/avatar.bin', 'w') - avatar_bin.write(local_avatar) - avatar_bin.close() else: # store it in the normal location self.avatar_location = 'home' @@ -258,18 +249,7 @@ class Account(object): self.test_migration(bus, q, conn, account_proxy) def test_migration(self, bus, q, conn, account_proxy): - if self.avatar_location == 'old': - # The avatar got migrated to the new location. - assert not os.path.exists(os.environ['MC_ACCOUNT_DIR'] + '/' + - self.id + '/avatar.bin') - assert not os.path.exists(os.environ['MC_ACCOUNT_DIR'] + '/fakecm') - avatar_filename = self.id - avatar_filename = avatar_filename.replace('/', '-') + '.avatar' - avatar_filename = (os.environ['XDG_DATA_HOME'] + - '/telepathy/mission-control/' + avatar_filename) - assertEquals(conn.avatar[0], ''.join(open(avatar_filename, - 'r').readlines())) - elif self.avatar_location == 'datadir' and self.winner == 'service': + if self.avatar_location == 'datadir' and self.winner == 'service': # The avatar wasn't deleted from $XDG_DATA_DIRS, but it was # overridden. assert not os.path.exists(os.environ['MC_ACCOUNT_DIR'] + '/' + diff --git a/tests/twisted/account-storage/storage_helper.py b/tests/twisted/account-storage/storage_helper.py index 42bfcf1e..ebbe78e6 100644 --- a/tests/twisted/account-storage/storage_helper.py +++ b/tests/twisted/account-storage/storage_helper.py @@ -22,6 +22,8 @@ import errno import os import os.path +import dbus + from servicetest import ( assertEquals, assertContains, assertLength, ) @@ -63,10 +65,28 @@ def test_keyfile(q, bus, mc, how_old='5.12'): # code paths. dot_mission_control = os.environ['MC_ACCOUNT_DIR'] old_key_file_name = os.path.join(dot_mission_control, 'accounts.cfg') + + os.makedirs(dot_mission_control + + '/fakecm/fakeprotocol/dontdivert1_40example_2ecom0') + avatar_bin = open(dot_mission_control + + '/fakecm/fakeprotocol/dontdivert1_40example_2ecom0/avatar.bin', + 'w') + avatar_bin.write('hello, world') + avatar_bin.close() elif how_old == '5.14': # Same format, different location. old_key_file_name = os.path.join(os.environ['XDG_DATA_HOME'], 'telepathy', 'mission-control', 'accounts.cfg') + + # exercise override of an avatar in XDG_DATA_DIRS + avatar_dir = (os.environ['XDG_DATA_DIRS'].split(':')[0] + + '/telepathy/mission-control') + os.makedirs(avatar_dir) + avatar_bin = open(avatar_dir + + '/fakecm-fakeprotocol-dontdivert1_40example_2ecom0.avatar', + 'w') + avatar_bin.write('hello, world') + avatar_bin.close() else: raise AssertionError('Unsupported value for how_old') @@ -95,6 +115,8 @@ param-account=dontdivert1@example.com param-password=1 DisplayName=First among equals AutomaticPresence=2;available;; +AvatarMime=text/plain +avatar_token=hello, world [%s] manager=fakecm @@ -136,6 +158,9 @@ AutomaticPresence=2;available;; account.Properties.Get(cs.ACCOUNT, 'Parameters')['account']) assertEquals('First among equals', account.Properties.Get(cs.ACCOUNT, 'DisplayName')) + assertEquals((dbus.ByteArray('hello, world'), 'text/plain'), + account.Properties.Get(cs.ACCOUNT_IFACE_AVATAR, 'Avatar', + byte_arrays=True)) assertContains(cs.ACCOUNT_PATH_PREFIX + a2_tail, properties['ValidAccounts']) |