From 395f584db75d71aad550347a3432d7ee9f7b55e2 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 7 Aug 2009 15:40:03 +0000 Subject: [PATCH] Monotone-Parent: 65d93d27a238a5e86f0c7bc9fd3cbc658d5ee681 Monotone-Revision: 6c5c0cfc38476abab3bbd81d781d653717c5be6d Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-08-07T15:40:03 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 6 ++++++ Tests/all.py | 20 +++++++++++++----- Tests/{testconfig.py.in => config.py.in} | 0 Tests/propfind.py | 2 +- Tests/{davacl.py => test-davacl.py} | 24 ++++++++++++++-------- Tests/{webdavsync.py => test-wedavsync.py} | 2 +- 6 files changed, 38 insertions(+), 16 deletions(-) rename Tests/{testconfig.py.in => config.py.in} (100%) rename Tests/{davacl.py => test-davacl.py} (94%) rename Tests/{webdavsync.py => test-wedavsync.py} (97%) diff --git a/ChangeLog b/ChangeLog index 997a7a51c..7c63977f3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-08-07 Wolfgang Sourdeau + + * Tests/all.py: modified to load and run all the test modules + found in the current directory, as long as they are prefixed by + "test-". + 2009-08-06 Wolfgang Sourdeau * Tests/davacl.py: new functional testsuite for DAV acls on diff --git a/Tests/all.py b/Tests/all.py index 853f43476..d691fed50 100755 --- a/Tests/all.py +++ b/Tests/all.py @@ -1,9 +1,19 @@ #!/usr/bin/python -import unittest - -from davacl import * -from webdavsync import * +import os, unittest if __name__ == "__main__": - unittest.main() + loader = unittest.TestLoader() + modules = [] + for mod in os.listdir("."): + if mod.startswith("test-") and mod.endswith(".py"): + modules.append(mod[:-3]) + __import__(mod[:-3]) + + if len(modules) > 0: + print "Test modules: '%s'" % "', '".join(modules) + suite = loader.loadTestsFromNames(modules) + runner = unittest.TextTestRunner() + runner.run(suite) + else: + print "No test available." diff --git a/Tests/testconfig.py.in b/Tests/config.py.in similarity index 100% rename from Tests/testconfig.py.in rename to Tests/config.py.in diff --git a/Tests/propfind.py b/Tests/propfind.py index 28594e251..896b583ec 100755 --- a/Tests/propfind.py +++ b/Tests/propfind.py @@ -1,6 +1,6 @@ #!/usr/bin/python -from testconfig import hostname, port, username, password +from config import hostname, port, username, password import webdavlib diff --git a/Tests/davacl.py b/Tests/test-davacl.py similarity index 94% rename from Tests/davacl.py rename to Tests/test-davacl.py index 8088b1bff..d62b5796c 100755 --- a/Tests/davacl.py +++ b/Tests/test-davacl.py @@ -1,6 +1,6 @@ #!/usr/bin/python -from testconfig import hostname, port, username, password, subscriber_username, subscriber_password +from config import hostname, port, username, password, subscriber_username, subscriber_password import sys import unittest @@ -22,11 +22,11 @@ import time # d: view date and time # m: modify # r: respond -# rights = { "c": create, -# "d": delete, -# "pu": public, -# "pr": private, -# "co": confidential } +# short rights notation: { "c": create, +# "d": delete, +# "pu": public, +# "pr": private, +# "co": confidential } resource = '/SOGo/dav/%s/Calendar/test-dav-acl/' % username @@ -103,7 +103,8 @@ class DAVAclTest(unittest.TestCase): "C": "urn:ietf:params:xml:ns:caldav" }) return xml.xpath.Evaluate(query, None, xpath_context) - def _putEvent(self, client, filename, event_class = "PUBLIC", exp_status = 201): + def _putEvent(self, client, filename, + event_class = "PUBLIC", exp_status = 201): url = "%s%s" % (resource, filename) event = event_template % { "class": event_class, "filename": filename } @@ -179,6 +180,9 @@ class DAVAclTest(unittest.TestCase): else: exp_code = 403 self._deleteEvent(self.subscriber_client, "public.ics", exp_code) + self._deleteEvent(self.subscriber_client, "private.ics", exp_code) + self._deleteEvent(self.subscriber_client, "confidential.ics", + exp_code) def _testEventRight(self, event_class, rights): if rights.has_key(event_class): @@ -210,7 +214,8 @@ class DAVAclTest(unittest.TestCase): return event - def _calendarDataInMultistatus(self, top_node, filename, response_tag = "D:response"): + def _calendarDataInMultistatus(self, top_node, filename, + response_tag = "D:response"): event = None response_nodes = self._xpath_query("/D:multistatus/%s" % response_tag, @@ -310,7 +315,8 @@ class DAVAclTest(unittest.TestCase): "PRODID": "-//Inverse//Event Generator//EN", "SEQUENCE": "0", "TRANSP": "OPAQUE", - "UID": "12345-%s-%s.ics" % (icsClass, icsClass.lower()), + "UID": "12345-%s-%s.ics" % (icsClass, + icsClass.lower()), "SUMMARY": "(%s event)" % icsClass.capitalize(), "DTSTART": "20090805T100000Z", "DTEND": "20090805T140000Z", diff --git a/Tests/webdavsync.py b/Tests/test-wedavsync.py similarity index 97% rename from Tests/webdavsync.py rename to Tests/test-wedavsync.py index 61edbb8a4..f0ccf7200 100755 --- a/Tests/webdavsync.py +++ b/Tests/test-wedavsync.py @@ -1,6 +1,6 @@ #!/usr/bin/python -from testconfig import hostname, port, username, password +from config import hostname, port, username, password import sys import unittest