[Pkg-telepathy-commits] [telepathy-mission-control-6] 28/90: Re-enable regression tests for account import, and add more
Simon McVittie
smcv at debian.org
Wed May 14 12:09:01 UTC 2014
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch debian
in repository telepathy-mission-control-6.
commit 457a0e06d720f002eb24e9196dd289174e1a2346
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date: Thu Mar 20 15:23:01 2014 +0000
Re-enable regression tests for account import, and add more
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=70991
---
tests/twisted/Makefile.am | 2 +
tests/twisted/account-storage/5-12.py | 3 -
tests/twisted/account-storage/5-14.py | 3 -
tests/twisted/account-storage/{5-12.py => 5-17.py} | 13 +-
.../twisted/account-storage/{5-12.py => 5-99-5.py} | 11 +-
tests/twisted/account-storage/storage_helper.py | 169 ++++++++++++++++++++-
6 files changed, 177 insertions(+), 24 deletions(-)
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index c09a6d3..05bc479 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -76,6 +76,8 @@ TWISTED_SPECIAL_BUILD_TESTS = \
account-storage/diverted-storage.py \
account-storage/5-12.py \
account-storage/5-14.py \
+ account-storage/5-17.py \
+ account-storage/5-99-5.py \
account-storage/create-new.py \
account-storage/load-keyfiles.py \
account-manager/server-drops-us.py \
diff --git a/tests/twisted/account-storage/5-12.py b/tests/twisted/account-storage/5-12.py
index 1781661..9075d76 100644
--- a/tests/twisted/account-storage/5-12.py
+++ b/tests/twisted/account-storage/5-12.py
@@ -19,9 +19,6 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA
-print "SKIP: MC 6 does not currently import MC 5 accounts"
-raise SystemExit(77)
-
from storage_helper import test_keyfile
from mctest import exec_test
diff --git a/tests/twisted/account-storage/5-14.py b/tests/twisted/account-storage/5-14.py
index d902d91..42deb3e 100644
--- a/tests/twisted/account-storage/5-14.py
+++ b/tests/twisted/account-storage/5-14.py
@@ -19,9 +19,6 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA
-print "SKIP: MC 6 does not currently import MC 5 accounts"
-raise SystemExit(77)
-
from storage_helper import test_keyfile
from mctest import exec_test
diff --git a/tests/twisted/account-storage/5-12.py b/tests/twisted/account-storage/5-17.py
similarity index 73%
copy from tests/twisted/account-storage/5-12.py
copy to tests/twisted/account-storage/5-17.py
index 1781661..300c85c 100644
--- a/tests/twisted/account-storage/5-12.py
+++ b/tests/twisted/account-storage/5-17.py
@@ -1,5 +1,5 @@
# Test for a former default account storage backend:
-# ~/.mission-control/accounts.cfg, as used in MC 5.0 to 5.13.1
+# XDG_DATA_HOME/telepathy/mission-control/, as used in MC 5.17
#
# Copyright (C) 2009-2010 Nokia Corporation
# Copyright (C) 2009-2014 Collabora Ltd.
@@ -19,14 +19,11 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA
-print "SKIP: MC 6 does not currently import MC 5 accounts"
-raise SystemExit(77)
-
-from storage_helper import test_keyfile
+from storage_helper import test_variant_file
from mctest import exec_test
-def test_5_12(q, bus, mc):
- test_keyfile(q, bus, mc, '5.12')
+def test(q, bus, mc):
+ test_variant_file(q, bus, mc, '5.17')
if __name__ == '__main__':
- exec_test(test_5_12, {}, preload_mc=False, use_fake_accounts_service=False)
+ exec_test(test, {}, preload_mc=False, use_fake_accounts_service=False)
diff --git a/tests/twisted/account-storage/5-12.py b/tests/twisted/account-storage/5-99-5.py
similarity index 76%
copy from tests/twisted/account-storage/5-12.py
copy to tests/twisted/account-storage/5-99-5.py
index 1781661..0276238 100644
--- a/tests/twisted/account-storage/5-12.py
+++ b/tests/twisted/account-storage/5-99-5.py
@@ -1,5 +1,5 @@
# Test for a former default account storage backend:
-# ~/.mission-control/accounts.cfg, as used in MC 5.0 to 5.13.1
+# XDG_DATA_HOME/telepathy-1/mission-control/accounts.cfg, as used in MC 5.99.5
#
# Copyright (C) 2009-2010 Nokia Corporation
# Copyright (C) 2009-2014 Collabora Ltd.
@@ -19,14 +19,11 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA
-print "SKIP: MC 6 does not currently import MC 5 accounts"
-raise SystemExit(77)
-
from storage_helper import test_keyfile
from mctest import exec_test
-def test_5_12(q, bus, mc):
- test_keyfile(q, bus, mc, '5.12')
+def test(q, bus, mc):
+ test_keyfile(q, bus, mc, '5.99.5')
if __name__ == '__main__':
- exec_test(test_5_12, {}, preload_mc=False, use_fake_accounts_service=False)
+ exec_test(test, {}, preload_mc=False, use_fake_accounts_service=False)
diff --git a/tests/twisted/account-storage/storage_helper.py b/tests/twisted/account-storage/storage_helper.py
index 6d78fa1..5f81548 100644
--- a/tests/twisted/account-storage/storage_helper.py
+++ b/tests/twisted/account-storage/storage_helper.py
@@ -87,6 +87,18 @@ def test_keyfile(q, bus, mc, how_old='5.12'):
'w')
avatar_bin.write('hello, world')
avatar_bin.close()
+ elif how_old == '5.99.5':
+ old_key_file_name = os.path.join(os.environ['XDG_DATA_HOME'],
+ 'telepathy-1', 'mission-control', 'accounts.cfg')
+
+ avatar_dir = (os.environ['XDG_DATA_DIRS'].split(':')[0] +
+ '/telepathy-1/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')
@@ -130,11 +142,162 @@ AutomaticPresence=2;available;;
mc = MC(q, bus)
account_manager, properties, interfaces = connect_to_mc(q, bus, mc)
- # During MC startup, it moved the old keyfile's contents into
- # variant-based files, and deleted the old keyfile.
- assert not os.path.exists(old_key_file_name)
+ if how_old < '5.99':
+ # MC did not delete the old files...
+ assert os.path.exists(old_key_file_name)
+
+ # ... but it did import them
+ assert os.path.exists(os.path.join(os.environ['XDG_DATA_HOME'],
+ 'telepathy', 'mission-control', 'MIGRATED-TO-TELEPATHY-1.txt'))
+ else:
+ # if upgrading Tp 1 to Tp 1, the old file *is* deleted
+ assert not os.path.exists(old_key_file_name)
+
+ assert os.path.exists(a1_new_variant_file_name)
+ assert os.path.exists(a2_new_variant_file_name)
+ assertEquals("'First among equals'",
+ account_store('get', 'variant-file', 'DisplayName',
+ account=a1_tail))
+ assertEquals("'Second to none'",
+ account_store('get', 'variant-file', 'DisplayName',
+ account=a2_tail))
+ # Because the CM is installed, we can work out the right types
+ # for the parameters, too.
+ assertEquals("'dontdivert1 at example.com'",
+ account_store('get', 'variant-file', 'param-account',
+ account=a1_tail))
+ assertEquals("'dontdivert2 at example.com'",
+ account_store('get', 'variant-file', 'param-account',
+ account=a2_tail))
+
+ # Also, MC has both accounts in memory...
+ assertContains(cs.ACCOUNT_PATH_PREFIX + a1_tail,
+ properties['UsableAccounts'])
+ account = get_fakecm_account(bus, mc, cs.ACCOUNT_PATH_PREFIX + a1_tail)
+ assertEquals('dontdivert1 at example.com',
+ 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['UsableAccounts'])
+ account = get_fakecm_account(bus, mc, cs.ACCOUNT_PATH_PREFIX + a2_tail)
+ assertEquals('dontdivert2 at example.com',
+ account.Properties.Get(cs.ACCOUNT, 'Parameters')['account'])
+ assertEquals('Second to none',
+ account.Properties.Get(cs.ACCOUNT, 'DisplayName'))
+
+ # ... and no other accounts.
+ assertLength(2, properties['UsableAccounts'])
+
+def test_variant_file(q, bus, mc, how_old='5.17'):
+ simulated_cm = SimulatedConnectionManager(q, bus)
+
+ if how_old == '5.17':
+ tp_dir = 'telepathy'
+ top_priority = os.path.join(os.environ['XDG_DATA_HOME'],
+ tp_dir, 'mission-control')
+ low_priority = os.path.join(os.environ['XDG_DATA_DIRS'].split(':')[0],
+ tp_dir, 'mission-control')
+
+ os.makedirs(top_priority)
+ avatar_bin = open(top_priority +
+ '/fakecm-fakeprotocol-dontdivert1_40example_2ecom0.avatar',
+ 'w')
+ avatar_bin.write('hello, world')
+ avatar_bin.close()
+
+ os.makedirs(low_priority)
+ avatar_bin = open(low_priority +
+ '/fakecm-fakeprotocol-dontdivert1_40example_2ecom0.avatar',
+ 'w')
+ avatar_bin.write('this version is not used')
+ avatar_bin.close()
+
+ avatar_bin = open(low_priority +
+ '/fakecm-fakeprotocol-dontdivert2_40example_2ecom0.avatar',
+ 'w')
+ avatar_bin.write('second chance')
+ avatar_bin.close()
+ else:
+ raise AssertionError('Unsupported value for how_old')
+
+ a1_old_variant_file_name = os.path.join(top_priority,
+ 'fakecm-fakeprotocol-dontdivert1_40example_2ecom0.account')
+
+ a1_masked_variant_file_name = os.path.join(low_priority,
+ 'fakecm-fakeprotocol-dontdivert1_40example_2ecom0.account')
+
+ a2_old_variant_file_name = os.path.join(low_priority,
+ 'fakecm-fakeprotocol-dontdivert2_40example_2ecom0.account')
+
+ a1_new_variant_file_name = os.path.join(os.environ['XDG_DATA_HOME'],
+ 'telepathy-1', 'mission-control',
+ 'fakecm-fakeprotocol-dontdivert1_40example_2ecom0.account')
+ a1_tail = 'fakecm/fakeprotocol/dontdivert1_40example_2ecom0'
+
+ a2_new_variant_file_name = os.path.join(os.environ['XDG_DATA_HOME'],
+ 'telepathy-1', 'mission-control',
+ 'fakecm-fakeprotocol-dontdivert2_40example_2ecom0.account')
+ a2_tail = 'fakecm/fakeprotocol/dontdivert2_40example_2ecom0'
+
+ open(a1_old_variant_file_name, 'w').write(r"""{
+'manager': <'fakecm'>,
+'protocol': <'fakeprotocol'>,
+'Parameters': <{
+ 'account': <'dontdivert1 at example.com'>,
+ 'password': <'1'>
+ }>,
+'DisplayName': <'First among equals'>,
+'AutomaticPresence': <(uint32 2, 'available', '')>,
+'AvatarMime': <'text/plain'>,
+'avatar_token': <'hello, world'>
+}""")
+
+ open(a1_masked_variant_file_name, 'w').write(r"""{
+'manager': <'fakecm'>,
+'protocol': <'fakeprotocol'>,
+'Parameters': <{
+ 'account': <'dontdivert1 at example.com'>,
+ 'password': <'1'>
+ }>,
+'DisplayName': <'this version is not used'>,
+'AutomaticPresence': <(uint32 2, 'available', '')>,
+'AvatarMime': <'text/plain'>,
+'avatar_token': <'this version is not used'>
+}""")
+
+ open(a2_old_variant_file_name, 'w').write(r"""{
+'manager': <'fakecm'>,
+'protocol': <'fakeprotocol'>,
+'Parameters': <{
+ 'account': <'dontdivert2 at example.com'>,
+ 'password': <'2'>
+ }>,
+'DisplayName': <'Second to none'>,
+'AutomaticPresence': <(uint32 2, 'available', '')>,
+'AvatarMime': <'text/plain'>,
+'avatar_token': <'second chance'>
+}""")
+
+ mc = MC(q, bus)
+ account_manager, properties, interfaces = connect_to_mc(q, bus, mc)
+
+ # MC did not delete the old files...
+ assert os.path.exists(a1_old_variant_file_name)
+ assert os.path.exists(a1_masked_variant_file_name)
+ assert os.path.exists(a2_old_variant_file_name)
+
+ # ... but it did import them
+ assert os.path.exists(os.path.join(os.environ['XDG_DATA_HOME'],
+ 'telepathy', 'mission-control', 'MIGRATED-TO-TELEPATHY-1.txt'))
+
assert os.path.exists(a1_new_variant_file_name)
assert os.path.exists(a2_new_variant_file_name)
+
assertEquals("'First among equals'",
account_store('get', 'variant-file', 'DisplayName',
account=a1_tail))
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-telepathy/telepathy-mission-control-6.git
More information about the Pkg-telepathy-commits
mailing list