[Pkg-telepathy-commits] [telepathy-mission-control-6] 230/280: Chop up the increasingly inaccurately-named default-keyring-storage test

Simon McVittie smcv at debian.org
Thu Mar 27 20:07:28 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 ed7bf646a77630de9e24641d5ca889904132fe85
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Mon Jan 27 20:58:20 2014 +0000

    Chop up the increasingly inaccurately-named default-keyring-storage test
    
    This test hasn't dealt with a keyring for a while, and now only covers
    "variant files". Split it into two: one deals with creating an account
    at runtime in the default backend, and one deals with loading files
    from disk.
---
 tests/twisted/Makefile.am                          |   3 +-
 tests/twisted/account-storage/create-new.py        | 136 +++++++++++
 .../account-storage/default-keyring-storage.py     | 265 ---------------------
 tests/twisted/account-storage/load-keyfiles.py     | 202 ++++++++++++++++
 4 files changed, 340 insertions(+), 266 deletions(-)

diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index 1f7dd21..2a96647 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -74,10 +74,11 @@ TWISTED_BASIC_TESTS = \
 # account-storage/*.py need their own instances.
 TWISTED_SPECIAL_BUILD_TESTS = \
 	account-manager/connectivity.py \
-	account-storage/default-keyring-storage.py \
 	account-storage/diverted-storage.py \
 	account-storage/5-12.py \
 	account-storage/5-14.py \
+	account-storage/create-new.py \
+	account-storage/load-keyfiles.py \
 	$(NULL)
 
 # Tests that are usually too slow to run.
diff --git a/tests/twisted/account-storage/create-new.py b/tests/twisted/account-storage/create-new.py
new file mode 100644
index 0000000..f77624a
--- /dev/null
+++ b/tests/twisted/account-storage/create-new.py
@@ -0,0 +1,136 @@
+# Test for "stringified GVariant per account" storage backend introduced in
+# Mission Control 5.16, when creating a new account stored in this default
+# backend
+#
+# Copyright (C) 2009-2010 Nokia Corporation
+# Copyright (C) 2009-2014 Collabora Ltd.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+
+import time
+import os
+import os.path
+import signal
+
+import dbus
+import dbus.service
+
+from servicetest import (
+    EventPattern, assertEquals,
+    )
+from mctest import (
+    exec_test, create_fakecm_account, connect_to_mc,
+    )
+from storage_helper import (account_store)
+import constants as cs
+
+def test(q, bus, mc):
+    ctl_dir = os.environ['MC_ACCOUNT_DIR']
+    old_key_file_name = os.path.join(ctl_dir, 'accounts.cfg')
+    newer_key_file_name = os.path.join(os.environ['XDG_DATA_HOME'],
+            'telepathy', 'mission-control', 'accounts.cfg')
+    new_variant_file_name = os.path.join(os.environ['XDG_DATA_HOME'],
+            'telepathy', 'mission-control',
+            'fakecm-fakeprotocol-dontdivert_40example_2ecom0.account')
+
+    account_manager, properties, interfaces = connect_to_mc(q, bus, mc)
+
+    assert properties.get('ValidAccounts') == [], \
+        properties.get('ValidAccounts')
+    assert properties.get('InvalidAccounts') == [], \
+        properties.get('InvalidAccounts')
+
+    params = dbus.Dictionary({"account": "dontdivert at example.com",
+        "password": "secrecy",
+        "snakes": dbus.UInt32(23)}, signature='sv')
+    (simulated_cm, account) = create_fakecm_account(q, bus, mc, params)
+
+    account_path = account.__dbus_object_path__
+
+    # Check the account is correctly created
+    properties = account_manager.GetAll(cs.AM,
+            dbus_interface=cs.PROPERTIES_IFACE)
+    assert properties is not None
+    assert properties.get('ValidAccounts') == [account_path], properties
+    account_path = properties['ValidAccounts'][0]
+    assert isinstance(account_path, dbus.ObjectPath), repr(account_path)
+    assert properties.get('InvalidAccounts') == [], properties
+
+    account_iface = dbus.Interface(account, cs.ACCOUNT)
+    account_props = dbus.Interface(account, cs.PROPERTIES_IFACE)
+
+    # Alter some miscellaneous r/w properties
+
+    account_props.Set(cs.ACCOUNT, 'DisplayName', 'Work account')
+    account_props.Set(cs.ACCOUNT, 'Icon', 'im-jabber')
+    account_props.Set(cs.ACCOUNT, 'Nickname', 'Joe Bloggs')
+    account_props.Set(cs.ACCOUNT, 'ConnectAutomatically', True)
+    account_props.Set(cs.ACCOUNT, 'AutomaticPresence',
+            (dbus.UInt32(cs.PRESENCE_EXTENDED_AWAY), 'xa',
+                'never online'))
+
+    # .. let's check the keyfile
+    assert not os.path.exists(old_key_file_name)
+    assert not os.path.exists(newer_key_file_name)
+    assert os.path.exists(new_variant_file_name)
+    assert 'Joe Bloggs' in open(new_variant_file_name).read()
+    assertEquals("'fakecm'", account_store('get', 'variant-file', 'manager'))
+    assertEquals("'fakeprotocol'", account_store('get', 'variant-file',
+        'protocol'))
+    assertEquals("'Work account'", account_store('get', 'variant-file',
+        'DisplayName'))
+    assertEquals("'im-jabber'", account_store('get', 'variant-file',
+        'Icon'))
+    assertEquals("'Joe Bloggs'", account_store('get', 'variant-file',
+        'Nickname'))
+    assertEquals('true', account_store('get', 'variant-file',
+        'ConnectAutomatically'))
+    assertEquals("(uint32 4, 'xa', 'never online')",
+            account_store('get', 'variant-file', 'AutomaticPresence'))
+    assertEquals("'dontdivert at example.com'",
+            account_store('get', 'variant-file', 'param-account'))
+    assertEquals("uint32 23",
+            account_store('get', 'variant-file', 'param-snakes'))
+    assertEquals("'secrecy'",
+            account_store('get', 'variant-file', 'param-password'))
+
+    assertEquals({'password': 'secrecy', 'account': 'dontdivert at example.com',
+        'snakes': 23}, account.Properties.Get(cs.ACCOUNT, 'Parameters'))
+
+    # Delete the account
+    assert account_iface.Remove() is None
+    account_event, account_manager_event = q.expect_many(
+        EventPattern('dbus-signal',
+            path=account_path,
+            signal='Removed',
+            interface=cs.ACCOUNT,
+            args=[]
+            ),
+        EventPattern('dbus-signal',
+            path=cs.AM_PATH,
+            signal='AccountRemoved',
+            interface=cs.AM,
+            args=[account_path]
+            ),
+        )
+
+    # Check the account is correctly deleted
+    assert not os.path.exists(old_key_file_name)
+    assert not os.path.exists(newer_key_file_name)
+    assert not os.path.exists(new_variant_file_name)
+
+if __name__ == '__main__':
+    exec_test(test, {}, timeout=10, use_fake_accounts_service=False)
diff --git a/tests/twisted/account-storage/default-keyring-storage.py b/tests/twisted/account-storage/default-keyring-storage.py
deleted file mode 100644
index 2281387..0000000
--- a/tests/twisted/account-storage/default-keyring-storage.py
+++ /dev/null
@@ -1,265 +0,0 @@
-# Test for default account storage backend.
-#
-# Copyright (C) 2009-2010 Nokia Corporation
-# Copyright (C) 2009-2010 Collabora Ltd.
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-
-import time
-import os
-import os.path
-import signal
-
-import dbus
-import dbus.service
-
-from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \
-        call_async, assertEquals, assertContains, assertDoesNotContain
-from mctest import (
-    exec_test, create_fakecm_account, get_fakecm_account, connect_to_mc,
-    keyfile_read, tell_mc_to_die, resuscitate_mc
-    )
-from storage_helper import (account_store)
-import constants as cs
-
-def test(q, bus, mc):
-    ctl_dir = os.environ['MC_ACCOUNT_DIR']
-    old_key_file_name = os.path.join(ctl_dir, 'accounts.cfg')
-    newer_key_file_name = os.path.join(os.environ['XDG_DATA_HOME'],
-            'telepathy', 'mission-control', 'accounts.cfg')
-    new_variant_file_name = os.path.join(os.environ['XDG_DATA_HOME'],
-            'telepathy', 'mission-control',
-            'fakecm-fakeprotocol-dontdivert_40example_2ecom0.account')
-    group = 'fakecm/fakeprotocol/dontdivert_40example_2ecom0'
-
-    account_manager, properties, interfaces = connect_to_mc(q, bus, mc)
-
-    assert properties.get('ValidAccounts') == [], \
-        properties.get('ValidAccounts')
-    assert properties.get('InvalidAccounts') == [], \
-        properties.get('InvalidAccounts')
-
-    params = dbus.Dictionary({"account": "dontdivert at example.com",
-        "password": "secrecy",
-        "snakes": dbus.UInt32(23)}, signature='sv')
-    (simulated_cm, account) = create_fakecm_account(q, bus, mc, params)
-
-    account_path = account.__dbus_object_path__
-
-    # Check the account is correctly created
-    properties = account_manager.GetAll(cs.AM,
-            dbus_interface=cs.PROPERTIES_IFACE)
-    assert properties is not None
-    assert properties.get('ValidAccounts') == [account_path], properties
-    account_path = properties['ValidAccounts'][0]
-    assert isinstance(account_path, dbus.ObjectPath), repr(account_path)
-    assert properties.get('InvalidAccounts') == [], properties
-
-    account_iface = dbus.Interface(account, cs.ACCOUNT)
-    account_props = dbus.Interface(account, cs.PROPERTIES_IFACE)
-
-    # Alter some miscellaneous r/w properties
-
-    account_props.Set(cs.ACCOUNT, 'DisplayName', 'Work account')
-    account_props.Set(cs.ACCOUNT, 'Icon', 'im-jabber')
-    account_props.Set(cs.ACCOUNT, 'Nickname', 'Joe Bloggs')
-    account_props.Set(cs.ACCOUNT, 'ConnectAutomatically', True)
-    account_props.Set(cs.ACCOUNT, 'AutomaticPresence',
-            (dbus.UInt32(cs.PRESENCE_EXTENDED_AWAY), 'xa',
-                'never online'))
-
-    tell_mc_to_die(q, bus)
-
-    # .. let's check the keyfile
-    assert not os.path.exists(old_key_file_name)
-    assert not os.path.exists(newer_key_file_name)
-    assert 'Joe Bloggs' in open(new_variant_file_name).read()
-    assertEquals("'fakecm'", account_store('get', 'variant-file', 'manager'))
-    assertEquals("'fakeprotocol'", account_store('get', 'variant-file',
-        'protocol'))
-    assertEquals("'Work account'", account_store('get', 'variant-file',
-        'DisplayName'))
-    assertEquals("'im-jabber'", account_store('get', 'variant-file',
-        'Icon'))
-    assertEquals("'Joe Bloggs'", account_store('get', 'variant-file',
-        'Nickname'))
-    assertEquals('true', account_store('get', 'variant-file',
-        'ConnectAutomatically'))
-    assertEquals("(uint32 4, 'xa', 'never online')",
-            account_store('get', 'variant-file', 'AutomaticPresence'))
-    assertEquals("'dontdivert at example.com'",
-            account_store('get', 'variant-file', 'param-account'))
-    assertEquals("uint32 23",
-            account_store('get', 'variant-file', 'param-snakes'))
-    assertEquals("'secrecy'",
-            account_store('get', 'variant-file', 'param-password'))
-
-    # Reactivate MC
-    account_manager, properties, interfaces = resuscitate_mc(q, bus, mc)
-    account = get_fakecm_account(bus, mc, account_path)
-    account_iface = dbus.Interface(account, cs.ACCOUNT)
-
-    assertEquals({'password': 'secrecy', 'account': 'dontdivert at example.com',
-        'snakes': 23}, account.Properties.Get(cs.ACCOUNT, 'Parameters'))
-
-    # Delete the account
-    assert account_iface.Remove() is None
-    account_event, account_manager_event = q.expect_many(
-        EventPattern('dbus-signal',
-            path=account_path,
-            signal='Removed',
-            interface=cs.ACCOUNT,
-            args=[]
-            ),
-        EventPattern('dbus-signal',
-            path=cs.AM_PATH,
-            signal='AccountRemoved',
-            interface=cs.AM,
-            args=[account_path]
-            ),
-        )
-
-    # Check the account is correctly deleted
-    assert not os.path.exists(old_key_file_name)
-    assert not os.path.exists(newer_key_file_name)
-    assert not os.path.exists(new_variant_file_name)
-
-    # Tell MC to die, again
-    tell_mc_to_die(q, bus)
-
-    low_prio_variant_file_name = os.path.join(
-            os.environ['XDG_DATA_DIRS'].split(':')[0],
-            'telepathy', 'mission-control',
-            'fakecm-fakeprotocol-dontdivert_40example_2ecom0.account')
-    os.makedirs(os.path.dirname(low_prio_variant_file_name), 0700)
-
-    # This is deliberately a lower-priority location
-    open(low_prio_variant_file_name, 'w').write(
-"""{
-'manager': <'fakecm'>,
-'protocol': <'fakeprotocol'>,
-'DisplayName': <'New and improved account'>,
-'AutomaticPresence': <(uint32 2, 'available', '')>,
-'KeyFileParameters': <{
-    'account': 'dontdivert at example.com',
-    'password': 'password_in_variant_file',
-    'snakes': '42'
-    }>
-}
-""")
-
-    # This version of this account will be used
-    open(new_variant_file_name.replace('.account', 'priority.account'),
-            'w').write("""{
-'manager': <'fakecm'>,
-'protocol': <'fakeprotocol'>,
-'DisplayName': <'Visible'>,
-'AutomaticPresence': <(uint32 2, 'available', '')>,
-'KeyFileParameters': <{'account': 'dontdivert at example.com',
-    'password': 'password_in_variant_file'}>
-}
-""")
-    # This one won't, because it's "masked" by the higher-priority one
-    open(low_prio_variant_file_name.replace('.account', 'priority.account'),
-            'w').write("""{
-'manager': <'fakecm'>,
-'protocol': <'fakeprotocol'>,
-'DisplayName': <'Hidden'>,
-'Nickname': <'Hidden'>,
-'AutomaticPresence': <(uint32 2, 'available', '')>,
-'KeyFileParameters': <{'account': 'dontdivert at example.com',
-    'password': 'password_in_variant_file'}>
-}
-""")
-
-    # This empty file is considered to "mask" the lower-priority one
-    open(new_variant_file_name.replace('.account', 'masked.account'),
-            'w').write('')
-    open(low_prio_variant_file_name.replace('.account', 'masked.account'),
-            'w').write("""{
-'manager': <'fakecm'>,
-'protocol': <'fakeprotocol'>,
-'AutomaticPresence': <(uint32 2, 'available', '')>,
-'KeyFileParameters': <{'account': 'dontdivert at example.com',
-    'password': 'password_in_variant_file'}>
-}
-""")
-
-    account_manager, properties, interfaces = resuscitate_mc(q, bus, mc)
-    assertContains(account_path, properties['ValidAccounts'])
-    account = get_fakecm_account(bus, mc, account_path)
-    account_iface = dbus.Interface(account, cs.ACCOUNT)
-
-    assertEquals(42,
-            account.Properties.Get(cs.ACCOUNT, 'Parameters')['snakes'])
-    assertEquals(dbus.UInt32,
-            type(account.Properties.Get(cs.ACCOUNT, 'Parameters')['snakes']))
-
-    # Files in lower-priority XDG locations aren't copied until something
-    # actually changes, and they aren't deleted.
-    assert not os.path.exists(new_variant_file_name)
-    assert os.path.exists(low_prio_variant_file_name)
-
-    # Delete the password (only), like Empathy 3.0-3.4 do when migrating
-    account_iface.UpdateParameters({}, ['password'])
-    q.expect('dbus-signal',
-            path=account_path,
-            signal='AccountPropertyChanged',
-            interface=cs.ACCOUNT,
-            predicate=(lambda e:
-                'Parameters' in e.args[0]),
-            )
-
-    # test that "masking" works
-    assertDoesNotContain(account_path + "masked", properties['ValidAccounts'])
-    assertDoesNotContain(account_path + "masked",
-            properties['InvalidAccounts'])
-
-    # test that priority works
-    assertContains(account_path + "priority", properties['ValidAccounts'])
-    priority_account = get_fakecm_account(bus, mc, account_path + "priority")
-    assertEquals('', priority_account.Properties.Get(cs.ACCOUNT, 'Nickname'))
-    assertEquals('Visible',
-            priority_account.Properties.Get(cs.ACCOUNT, 'DisplayName'))
-
-    # test what happens when we delete an account that has a lower-priority
-    # "other self"
-    assert priority_account.Remove() is None
-
-    # Tell MC to die yet again
-    tell_mc_to_die(q, bus)
-
-    # Check the account has copied (not moved! XDG_DATA_DIRS are,
-    # conceptually, read-only) from the old to the new name
-    assert not os.path.exists(old_key_file_name)
-    assert not os.path.exists(newer_key_file_name)
-    assert os.path.exists(low_prio_variant_file_name)
-    assert os.path.exists(new_variant_file_name)
-    assert open(new_variant_file_name.replace('.account', 'masked.account'),
-        'r').read() == ''
-    assert open(new_variant_file_name.replace('.account', 'priority.account'),
-        'r').read() == ''
-
-    pwd = account_store('get', 'variant-file', 'param-password')
-    assertEquals(None, pwd)
-
-if __name__ == '__main__':
-    ctl_dir = os.environ['MC_ACCOUNT_DIR']
-    try:
-        os.mkdir(ctl_dir, 0700)
-    except OSError:
-        pass
-    exec_test(test, {}, timeout=10, use_fake_accounts_service=False)
diff --git a/tests/twisted/account-storage/load-keyfiles.py b/tests/twisted/account-storage/load-keyfiles.py
new file mode 100644
index 0000000..35280db
--- /dev/null
+++ b/tests/twisted/account-storage/load-keyfiles.py
@@ -0,0 +1,202 @@
+# Test for "stringified GVariant per account" storage backend introduced in
+# Mission Control 5.16, when loading pre-prepared files
+#
+# Copyright (C) 2009-2010 Nokia Corporation
+# Copyright (C) 2009-2014 Collabora Ltd.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+
+import errno
+import os
+import os.path
+
+import dbus
+
+from servicetest import (
+    assertEquals, assertContains, assertDoesNotContain,
+    )
+from mctest import (
+    MC, exec_test, get_fakecm_account, connect_to_mc,
+    SimulatedConnectionManager,
+    )
+import constants as cs
+
+def test(q, bus, mc):
+    simulated_cm = SimulatedConnectionManager(q, bus)
+
+    ctl_dir = os.environ['MC_ACCOUNT_DIR']
+    old_key_file_name = os.path.join(ctl_dir, 'accounts.cfg')
+    newer_key_file_name = os.path.join(os.environ['XDG_DATA_HOME'],
+            'telepathy', 'mission-control', 'accounts.cfg')
+
+    # We do several scenarios in one MC run, to speed up testing a bit.
+    scenarios = ('low', 'priority', 'masked')
+
+    variant_file_names = {}
+    low_prio_variant_file_names = {}
+    account_paths = {}
+    tails = {}
+
+    for s in scenarios:
+        variant_file_names[s] = os.path.join(os.environ['XDG_DATA_HOME'],
+                'telepathy', 'mission-control',
+                'fakecm-fakeprotocol-dontdivert%s_40example_2ecom0.account'
+                    % s)
+        tails[s] = ('fakecm/fakeprotocol/dontdivert%s_40example_2ecom0' % s)
+        account_paths[s] = cs.ACCOUNT_PATH_PREFIX + tails[s]
+        low_prio_variant_file_names[s] = os.path.join(
+                os.environ['XDG_DATA_DIRS'].split(':')[0],
+                'telepathy', 'mission-control',
+                'fakecm-fakeprotocol-dontdivert%s_40example_2ecom0.account' %
+                    s)
+
+        try:
+            os.makedirs(os.path.dirname(variant_file_names[s]), 0700)
+        except OSError as e:
+            if e.errno != errno.EEXIST:
+                raise
+
+        try:
+            os.makedirs(os.path.dirname(low_prio_variant_file_names[s]), 0700)
+        except OSError as e:
+            if e.errno != errno.EEXIST:
+                raise
+
+    # This is deliberately a lower-priority location
+    open(low_prio_variant_file_names['low'], 'w').write(
+"""{
+'manager': <'fakecm'>,
+'protocol': <'fakeprotocol'>,
+'DisplayName': <'Account in a low-priority location'>,
+'AutomaticPresence': <(uint32 2, 'available', '')>,
+'KeyFileParameters': <{
+    'account': 'dontdivertlow at example.com',
+    'password': 'password_in_variant_file',
+    'snakes': '42'
+    }>
+}
+""")
+
+    # This version of this account will be used
+    open(variant_file_names['priority'], 'w').write("""{
+'manager': <'fakecm'>,
+'protocol': <'fakeprotocol'>,
+'DisplayName': <'Visible'>,
+'AutomaticPresence': <(uint32 2, 'available', '')>,
+'KeyFileParameters': <{'account': 'dontdivertpriority at example.com',
+    'password': 'password_in_variant_file',
+    'snakes': '42'
+    }>
+}
+""")
+    # This one won't, because it's "masked" by the higher-priority one
+    open(low_prio_variant_file_names['priority'], 'w').write("""{
+'manager': <'fakecm'>,
+'protocol': <'fakeprotocol'>,
+'DisplayName': <'Hidden'>,
+'Nickname': <'Hidden'>,
+'AutomaticPresence': <(uint32 2, 'available', '')>,
+'KeyFileParameters': <{'account': 'dontdivertpriority at example.com',
+    'password': 'password_in_variant_file',
+    'snakes': '42'
+    }>
+}
+""")
+
+    # This empty file is considered to "mask" the lower-priority one
+    open(variant_file_names['masked'], 'w').write('')
+    open(low_prio_variant_file_names['masked'], 'w').write("""{
+'manager': <'fakecm'>,
+'protocol': <'fakeprotocol'>,
+'AutomaticPresence': <(uint32 2, 'available', '')>,
+'KeyFileParameters': <{'account': 'dontdivert at example.com',
+    'password': 'password_in_variant_file',
+    'snakes': '42'
+    }>
+}
+""")
+
+    mc = MC(q, bus)
+    account_manager, properties, interfaces = connect_to_mc(q, bus, mc)
+
+    for s in scenarios:
+        if s == 'masked':
+            assertDoesNotContain(account_paths[s], properties['ValidAccounts'])
+        else:
+            assertContains(account_paths[s], properties['ValidAccounts'])
+
+        assertDoesNotContain(account_paths[s], properties['InvalidAccounts'])
+
+    accounts = {}
+    account_ifaces = {}
+
+    for s in scenarios:
+        if s != 'masked':
+            accounts[s] = get_fakecm_account(bus, mc, account_paths[s])
+            account_ifaces[s] = dbus.Interface(accounts[s], cs.ACCOUNT)
+
+            assertEquals(42, accounts[s].Properties.Get(cs.ACCOUNT,
+                'Parameters')['snakes'])
+            assertEquals(dbus.UInt32,
+                    type(accounts[s].Properties.Get(cs.ACCOUNT,
+                        'Parameters')['snakes']))
+
+        # Files in lower-priority XDG locations aren't copied until something
+        # actually changes, and they aren't deleted.
+
+        if s == 'low':
+            assert os.path.exists(low_prio_variant_file_names[s])
+
+    # Delete the password (only), like Empathy 3.0-3.4 do when migrating.
+    # This results in the higher-priority file being written out.
+    account_ifaces['low'].UpdateParameters({}, ['password'])
+    q.expect('dbus-signal',
+            path=account_paths['low'],
+            signal='AccountPropertyChanged',
+            interface=cs.ACCOUNT,
+            predicate=(lambda e:
+                'Parameters' in e.args[0]),
+            )
+    # Check the account has copied (not moved! XDG_DATA_DIRS are,
+    # conceptually, read-only) 'low' from the old to the new name
+    assert not os.path.exists(old_key_file_name)
+    assert not os.path.exists(newer_key_file_name)
+    assert os.path.exists(low_prio_variant_file_names['low'])
+    assert os.path.exists(variant_file_names['low'])
+
+    # test that priority works
+    assertContains(account_paths["priority"], properties['ValidAccounts'])
+    assertEquals('',
+            accounts['priority'].Properties.Get(cs.ACCOUNT, 'Nickname'))
+    assertEquals('Visible',
+            accounts['priority'].Properties.Get(cs.ACCOUNT, 'DisplayName'))
+
+    # test what happens when we delete an account that has a lower-priority
+    # "other self": it becomes masked
+    assert accounts['priority'].Remove() is None
+    assert not os.path.exists(old_key_file_name)
+    assert not os.path.exists(newer_key_file_name)
+    assert os.path.exists(low_prio_variant_file_names['priority'])
+    assert os.path.exists(variant_file_names['priority'])
+    assert open(variant_file_names['priority'], 'r').read() == ''
+    assertContains('password_in_variant_file',
+            open(low_prio_variant_file_names['priority'], 'r').read())
+
+    # The masked account is still masked
+    assert open(variant_file_names['masked'], 'r').read() == ''
+
+if __name__ == '__main__':
+    exec_test(test, {}, preload_mc=False, use_fake_accounts_service=False)

-- 
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