[Pkg-telepathy-commits] [telepathy-mission-control-6] 180/280: Add some missing test coverage: IdentifyAccount failing hard

Simon McVittie smcv at debian.org
Thu Mar 27 20:07:21 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 48dff5c37b468eaa927120093a6d872cba0265d7
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Wed Nov 13 17:42:09 2013 +0000

    Add some missing test coverage: IdentifyAccount failing hard
    
    Bug: https://bugs.freedesktop.org/show_bug.cgi?id=27727
---
 tests/twisted/account-manager/bad-cm.py | 11 +++++++++-
 tests/twisted/mctest.py                 | 38 +++++++++++++++++++++++++--------
 2 files changed, 39 insertions(+), 10 deletions(-)

diff --git a/tests/twisted/account-manager/bad-cm.py b/tests/twisted/account-manager/bad-cm.py
index 74277b4..008ac60 100644
--- a/tests/twisted/account-manager/bad-cm.py
+++ b/tests/twisted/account-manager/bad-cm.py
@@ -22,11 +22,12 @@
 import dbus
 
 from servicetest import call_async, assertEquals, assertContains
-from mctest import exec_test, AccountManager
+from mctest import (exec_test, SimulatedConnectionManager, AccountManager)
 import constants as cs
 
 def test(q, bus, mc):
     am = AccountManager(bus)
+    simulated_cm = SimulatedConnectionManager(q, bus)
 
     def call_create(cm='fakecm', protocol='fakeprotocol', parameters=None):
         if parameters is None:
@@ -74,5 +75,13 @@ def test(q, bus, mc):
     assertEquals(cs.INVALID_ARGUMENT, e.name)
     assertContains("password", e.message)
 
+    # Create an account that will fail IdentifyAccount
+    call_create(parameters={ "account": "",
+                             "password": "ohai",
+                           })
+    e = q.expect('dbus-error', method='CreateAccount')
+    assertEquals(cs.INVALID_HANDLE, e.name)
+    assertContains("Invalid account name", e.message)
+
 if __name__ == '__main__':
     exec_test(test, {})
diff --git a/tests/twisted/mctest.py b/tests/twisted/mctest.py
index 35ccec9..2229525 100644
--- a/tests/twisted/mctest.py
+++ b/tests/twisted/mctest.py
@@ -1018,12 +1018,11 @@ class SimulatedConnectionManager(object):
 
         for protocol_name in protocol_names:
             assert '-' not in protocol_name
-            q.add_dbus_method_impl(self.IdentifyAccount,
-                    path=self.object_path + '/' + protocol_name,
-                    interface=cs.PROTOCOL, method='IdentifyAccount')
-            q.add_dbus_method_impl(self.NormalizeContact,
-                    path=self.object_path + '/' + protocol_name,
-                    interface=cs.PROTOCOL, method='NormalizeContact')
+
+        q.add_dbus_method_impl(self.IdentifyAccount,
+                interface=cs.PROTOCOL, method='IdentifyAccount')
+        q.add_dbus_method_impl(self.NormalizeContact,
+                interface=cs.PROTOCOL, method='NormalizeContact')
 
     def release_name(self):
         del self._bus_name_ref
@@ -1132,11 +1131,32 @@ class SimulatedConnectionManager(object):
             }, signature='a{sv}', bus=self.bus)
 
     def IdentifyAccount(self, e):
+        if e.path.startswith(self.object_path + '/'):
+            protocol = e.path[len(self.object_path + '/'):]
+
+            if protocol not in self.protocol_names:
+                self.q.dbus_raise(e.message, cs.DBUS_ERROR_UNKNOWN_METHOD,
+                        'Not my protocol')
+                return
+        else:
+            self.q.dbus_raise(e.message, cs.DBUS_ERROR_UNKNOWN_METHOD,
+                    'Not even my object path')
+            return
+
+        if protocol in ('serializable', 'defaults') and 's' in e.args[0]:
+            ret = e.args[0]['s'].lower()
+            if ret:
+                self.q.dbus_return(e.message, ret, signature='s')
+                return
+
         if 'account' in e.args[0]:
             ret = e.args[0]['account'].lower()
-        else:
-            ret = 'account'
-        self.q.dbus_return(e.message, ret, signature='s')
+            if ret:
+                self.q.dbus_return(e.message, ret, signature='s')
+                return
+
+        self.q.dbus_raise(e.message, cs.INVALID_HANDLE,
+                'Invalid account name %r' % e.args[0].get('account'))
 
     def NormalizeContact(self, e):
         self.q.dbus_return(e.message, e.args[0].lower(), signature='s')

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