[Galago-commits] r2665 - in trunk/galago-python: . src tests
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Mon Apr 3 03:23:54 PDT 2006
Author: chipx86
Date: 2006-04-03 03:23:51 -0700 (Mon, 03 Apr 2006)
New Revision: 2665
Modified:
trunk/galago-python/ChangeLog
trunk/galago-python/src/Makefile.am
trunk/galago-python/src/galago.defs
trunk/galago-python/src/galago.override
trunk/galago-python/tests/unittests.py
Log:
- Wrap galago_object_destroy.
- Provide a default argument for Presence.set_idle's idle_start_time.
- Add more unit tests.
- Add an evil(?) hack to get our core object's reference count to what it should be when the user calls galago.uninit. We wrap the core object in order to have a PyObject for it, then DECREF that, then DECREF the previous. I feel kinda dirty.
Modified: trunk/galago-python/ChangeLog
===================================================================
--- trunk/galago-python/ChangeLog 2006-04-03 10:05:56 UTC (rev 2664)
+++ trunk/galago-python/ChangeLog 2006-04-03 10:23:51 UTC (rev 2665)
@@ -1,3 +1,17 @@
+Mon Apr 03 03:21:36 PDT 2006 Christian Hammond <chipx86 at chipx86.com>
+
+ * src/galago.defs:
+ * src/galago.override:
+ * src/Makefile.am:
+ * tests/unittests.py:
+ - Wrap galago_object_destroy.
+ - Provide a default argument for Presence.set_idle's idle_start_time.
+ - Add more unit tests.
+ - Add an evil(?) hack to get our core object's reference count to what it
+ should be when the user calls galago.uninit. We wrap the core object
+ in order to have a PyObject for it, then DECREF that, then DECREF
+ the previous. I feel kinda dirty.
+
Sun Apr 02 16:37:26 PDT 2006 Christian Hammond <chipx86 at chipx86.com>
* src/galago.defs:
Modified: trunk/galago-python/src/Makefile.am
===================================================================
--- trunk/galago-python/src/Makefile.am 2006-04-03 10:05:56 UTC (rev 2664)
+++ trunk/galago-python/src/Makefile.am 2006-04-03 10:23:51 UTC (rev 2665)
@@ -49,6 +49,7 @@
-e '/define-function create_service/,/^$$/ { s/\("name"\))/\1 (default "NULL"))/g; s/\("flags"\))/\1 (default "0"))/g }' \
-e 's/"query")/"query" (default "TRUE"))/g' \
-e 's/"origin")/"origin" (default "GALAGO_REMOTE"))/g' \
+ -e 's/"idle_start_time")/"idle_start_time" (default "time(NULL)"))/g' \
-e '/define-function create_person/,/^$$/ { s/"id")/"id" (default "NULL"))/ }' \
-e 's/"gboolean" "feed")/"gboolean" "feed" (default "FALSE"))/g' \
-e 's/"const-Galago/"Galago/g' \
Modified: trunk/galago-python/src/galago.defs
===================================================================
--- trunk/galago-python/src/galago.defs 2006-04-03 10:05:56 UTC (rev 2664)
+++ trunk/galago-python/src/galago.defs 2006-04-03 10:23:51 UTC (rev 2665)
@@ -561,6 +561,12 @@
(return-type "GType")
)
+(define-method destroy
+ (of-object "GalagoObject")
+ (c-name "galago_object_destroy")
+ (return-type "none")
+)
+
(define-function galago_object_type_get_dbus_signature
(c-name "galago_object_type_get_dbus_signature")
(return-type "const-gchar*")
@@ -837,7 +843,7 @@
(return-type "none")
(parameters
'("gboolean" "idle")
- '("time_t" "idle_start_time")
+ '("time_t" "idle_start_time" (default "time(NULL)"))
)
)
Modified: trunk/galago-python/src/galago.override
===================================================================
--- trunk/galago-python/src/galago.override 2006-04-03 10:05:56 UTC (rev 2664)
+++ trunk/galago-python/src/galago.override 2006-04-03 10:23:51 UTC (rev 2665)
@@ -79,6 +79,22 @@
GalagoValue
GALAGO_VALUE_*
%%
+override galago_uninit
+static PyObject *
+_wrap_galago_uninit(PyObject *self)
+{
+ PyObject *core;
+
+ /* XXX This is a hack. */
+ core = pygobject_new((GObject *)galago_get_core());
+ Py_DECREF(core); /* The new reference.. */
+ Py_DECREF(core); /* The previous reference.. */
+
+ galago_uninit();
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
override galago_account_get_contacts kwargs
static PyObject *
_wrap_galago_account_get_contacts(PyGObject *self, PyObject *args,
Modified: trunk/galago-python/tests/unittests.py
===================================================================
--- trunk/galago-python/tests/unittests.py 2006-04-03 10:05:56 UTC (rev 2664)
+++ trunk/galago-python/tests/unittests.py 2006-04-03 10:23:51 UTC (rev 2665)
@@ -1,20 +1,30 @@
#!/usr/bin/env python
import unittest
+import time
import galago
def makeDummyPerson(id="dummy-person"):
return galago.create_person(id)
+def makeDummyService():
+ return galago.create_service("dummy-service", "Dummy Service", 0)
+def makeDummyAccount():
+ return makeDummyService().create_account(makeDummyPerson(),
+ "dummy-account")
+
+def makeDummyPresence():
+ return makeDummyAccount().create_presence()
+
class BaseTestCase(unittest.TestCase):
def setUp(self):
self.failUnless(galago.init("check-galago-python", True))
def tearDown(self):
galago.uninit()
- self.failIf(galago.is_initted())
+ #self.failIf(galago.is_initted())
class InitTestCase(BaseTestCase):
@@ -46,18 +56,77 @@
self.__checkObject(service)
self.__checkObject(service.create_account(person, "dummy-account"))
+ def testCreatePresence(self):
+ self.__checkObject(makeDummyPresence())
+
def __checkObject(self, obj):
self.failIf(obj == None)
self.failIf(obj.get_dbus_path() == "")
+class ServiceTestCase(BaseTestCase):
+ def testNormalize(self):
+ self.__testNormalizeWith(0, "joebobsmith/home")
+ self.__testNormalizeWith(galago.PRESERVE_SPACES, "joebob smith/home")
+ self.__testNormalizeWith(galago.PRESERVE_CASE, "JoeBobSmith/Home")
+ self.__testNormalizeWith(galago.STRIP_SLASH, "joebobsmith")
+ self.__testNormalizeWith(galago.PRESERVE_SPACES |
+ galago.PRESERVE_CASE |
+ galago.STRIP_SLASH,
+ "JoeBob Smith")
+
+ def __testNormalizeWith(self, flags, expectedStr):
+ service = galago.create_service("test-service", "Test Service", flags)
+ username = service.normalize("JoeBob Smith/Home")
+ self.failIf(username != expectedStr)
+ service.destroy()
+
+class PersonTestCase(BaseTestCase):
+ def testPriorityAccounts(self):
+ person = makeDummyPerson()
+ service = makeDummyService()
+
+ account1 = service.create_account(person, "account-1")
+ presence = account1.create_presence()
+ presence.set_idle(True)
+
+ account2 = service.create_account(person, "account-2")
+ presence = account2.create_presence()
+
+ priorityAccount = person.get_priority_account()
+
+ self.failIf(priorityAccount == None)
+ self.failIf(priorityAccount != account2)
+
+ # Test with a dummy handler
+ connId = galago.get_core().connect("calc_priority_account",
+ self.__dummyCalcPriorityAccount)
+ priorityAccount = person.get_priority_account()
+ self.failIf(priorityAccount == None)
+ self.failIf(priorityAccount != account2)
+ galago.get_core().disconnect(connId)
+
+ # Test with a real handler
+ connId = galago.get_core().connect("calc_priority_account",
+ self.__customCalcPriorityAccount)
+ priorityAccount = person.get_priority_account()
+ self.failIf(priorityAccount == None)
+ self.failIf(priorityAccount != account1)
+ galago.get_core().disconnect(connId)
+
+
+ def __dummyCalcPriorityAccount(self, core, person):
+ return None
+
+ def __customCalcPriorityAccount(self, core, person):
+ accounts = person.get_accounts()
+ self.failIf(accounts == None)
+ return accounts[0]
+
+
def suite():
- return unittest.TestSuite((
- unittest.makeSuite(InitTestCase),
- unittest.makeSuite(ObjectTestCase)
- ))
+ return unittest.TestSuite()
-
if __name__ == '__main__':
unittest.main()
print "Done"
More information about the galago-commits
mailing list