From 3fff395160b634de7e627140a8f50f8e917a2a91 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 5 Aug 2009 16:44:45 +0000 Subject: [PATCH 1/6] Monotone-Parent: d35569adb5f95d077a2e359cae7af87c6ba720d1 Monotone-Revision: 07373a01b29415522044be3734f2799491696ebc Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-08-05T16:44:45 Monotone-Branch: ca.inverse.sogo --- Tests/webdavlib.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Tests/webdavlib.py b/Tests/webdavlib.py index 3498e9706..a0544f173 100644 --- a/Tests/webdavlib.py +++ b/Tests/webdavlib.py @@ -204,11 +204,10 @@ class _WD_XMLTreeElement: if ns_text is not None: text = text + ns_text - count = len(self.children) - if count > 0: + if len(self.children) > 0: text = text + ">" - for x in range(0, count): - text = text + self.children[x].render() + for child in self.children: + text = text + child.render() text = text + "" else: text = text + "/>" From c8e3996fee3fb3e1eb07c8da3c2b1a0d67c9e1df Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 5 Aug 2009 16:44:50 +0000 Subject: [PATCH 2/6] Monotone-Parent: 07373a01b29415522044be3734f2799491696ebc Monotone-Revision: 7b27fe613fc83b2fb43c0d43ed6052f3e1041b69 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-08-05T16:44:50 Monotone-Branch: ca.inverse.sogo --- Tests/webdav-sync.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/webdav-sync.py b/Tests/webdav-sync.py index 969a181fd..61edbb8a4 100755 --- a/Tests/webdav-sync.py +++ b/Tests/webdav-sync.py @@ -40,9 +40,9 @@ class WebdavSyncTest(unittest.TestCase): # empty collection: # without a token (query1) # with a token (query2) - # non-empty collection: + # (when done, non-empty collection: # without a token (query3) - # with a token (query4) + # with a token (query4)) query1 = webdavlib.WebDAVSyncQuery(resource, None, [ "getetag" ]) self.client.execute(query1) From cf7b984ad7d5d9f2507d8674a13ca1c5fa1e6b88 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 6 Aug 2009 19:18:51 +0000 Subject: [PATCH 3/6] Monotone-Parent: 7b27fe613fc83b2fb43c0d43ed6052f3e1041b69 Monotone-Revision: 977a2fc6635839b5595a2518bac96d0260c9b3da Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-08-06T19:18:51 Monotone-Branch: ca.inverse.sogo --- .mtn-ignore | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.mtn-ignore b/.mtn-ignore index 4ef5dae36..f99c00a9d 100644 --- a/.mtn-ignore +++ b/.mtn-ignore @@ -2,7 +2,15 @@ config.make shared_debug_obj obj imgs-.* +diff +.*\.bak$ +.*\.diff$ .*\.d$ +.*\.log$ +.*\.ifb$ +.*\.ics +.*\.vcf$ +.*\.old$ .*\.SOGo$ .*\.sax$ SoObjects/SOGo/SOGo.framework @@ -11,3 +19,4 @@ SOPE/NGCards/samples/CardElement.m SOPE/NGCards/samples/CardGroup.m SOPE/NGCards/samples/CardVersitRenderer.m SOPE/NGCards/samples/NGCardsSaxHandler.m +Tests/testconfig.py From dbc6bd1a8cf2b2026b0d7c1558ebd97a617c46ac Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 6 Aug 2009 19:21:10 +0000 Subject: [PATCH 4/6] Monotone-Parent: f0967567767bc3e201a892b9a9fc17de9c47f0a1 Monotone-Revision: 223a4ad09a33c8b2083c58b7e512c78200d305ec Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-08-06T19:21:10 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 7 +++++++ Tests/webdavlib.py | 40 ++++++++++++++++++++++++++++++---------- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 617ec7527..feff6ff76 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-08-06 Wolfgang Sourdeau + + * Tests/webdavlib.py (WebDAVClient._prepare_headers): we don't set + the "content-length" header if the body is None. + (HTTPSimpleQuery.render): method must take a "self" parameter. + (WebDAVCalendarMultiget.__init__): added transaction class. + 2009-08-06 Francis Lachapelle * UI/PreferencesUI/UIxPreferences.m ([UIxPreferences diff --git a/Tests/webdavlib.py b/Tests/webdavlib.py index a0544f173..548d2b3b8 100644 --- a/Tests/webdavlib.py +++ b/Tests/webdavlib.py @@ -18,8 +18,9 @@ class WebDAVClient: def _prepare_headers(self, query, body): headers = { "User-Agent": "Mozilla/5.0", - "content-length": len(body), "authorization": "Basic %s" % self.simpleauth_hash } + if body is not None: + headers["content-length"] = len(body) if query.__dict__.has_key("query") and query.depth is not None: headers["depth"] = query.depth if query.__dict__.has_key("content_type"): @@ -45,17 +46,9 @@ class HTTPSimpleQuery: self.start = -1 self.duration = -1 - def render(): + def render(self): return None -class HTTPGET(HTTPSimpleQuery): - method = "GET" - -class HTTPQuery(HTTPSimpleQuery): - def __init__(self, url, content_type): - HTTPSimpleQuery.__init__(self, url) - self.content_type = content_type - def set_response(self, http_response): headers = {} for rk, rv in http_response.getheaders(): @@ -66,6 +59,14 @@ class HTTPQuery(HTTPSimpleQuery): "version": http_response.version, "body": http_response.read() } +class HTTPGET(HTTPSimpleQuery): + method = "GET" + +class HTTPQuery(HTTPSimpleQuery): + def __init__(self, url, content_type): + HTTPSimpleQuery.__init__(self, url) + self.content_type = content_type + class HTTPPUT(HTTPQuery): method = "PUT" @@ -76,6 +77,9 @@ class HTTPPUT(HTTPQuery): def render(self): return self.content +class HTTPPOST(HTTPPUT): + method = "POST" + class WebDAVQuery(HTTPQuery): method = None @@ -138,6 +142,22 @@ class WebDAVPROPFIND(WebDAVQuery): prop_tag = self.render_tag(prop) props.append(_WD_XMLTreeElement(prop_tag)) +class WebDAVCalendarMultiget(WebDAVREPORT): + def __init__(self, url, properties, hrefs): + WebDAVQuery.__init__(self, url) + multiget_tag = self.ns_mgr.register("calendar-multiget", "urn:ietf:params:xml:ns:caldav") + self.top_node = _WD_XMLTreeElement(multiget_tag) + props = _WD_XMLTreeElement("prop") + self.top_node.append(props) + for prop in properties: + prop_tag = self.render_tag(prop) + props.append(_WD_XMLTreeElement(prop_tag)) + + for href in hrefs: + href_node = _WD_XMLTreeElement("href") + self.top_node.append(href_node) + href_node.append(_WD_XMLTreeTextNode(href)) + class WebDAVSyncQuery(WebDAVREPORT): def __init__(self, url, token, properties): WebDAVQuery.__init__(self, url) From 9627dd6eaaa02fe4ed4b96f0acc3c85cbef2f1f7 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 6 Aug 2009 19:21:49 +0000 Subject: [PATCH 5/6] Monotone-Parent: 223a4ad09a33c8b2083c58b7e512c78200d305ec Monotone-Revision: f473906a9eeabc3d7969b78d83ccdeee34b2fb7a Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-08-06T19:21:49 Monotone-Branch: ca.inverse.sogo --- Tests/{webdav-sync.py => webdavsync.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Tests/{webdav-sync.py => webdavsync.py} (100%) diff --git a/Tests/webdav-sync.py b/Tests/webdavsync.py similarity index 100% rename from Tests/webdav-sync.py rename to Tests/webdavsync.py From 888d078d522213b8d256c8a9b637cc283f0b1f65 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 6 Aug 2009 19:27:40 +0000 Subject: [PATCH 6/6] Monotone-Parent: f473906a9eeabc3d7969b78d83ccdeee34b2fb7a Monotone-Revision: f14da511e49cf36d5c6f6a7d9fe1aed0eeda1c79 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-08-06T19:27:40 Monotone-Branch: ca.inverse.sogo --- Tests/README | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/Tests/README b/Tests/README index fefa3f773..96e95c28b 100644 --- a/Tests/README +++ b/Tests/README @@ -12,8 +12,39 @@ runnable scripts webdav-sync.py -other ------ +other scripts +------------- propfind.py - a sample implementation of a PROPFIND request using webdavlib +* developers +------------ + +- Test methods are always prefixed with "test". Sometimes, it's easier to +track down a problem by enabling only one test at a time. One possible method +is to replace "def test" with "def xtest" and replace it back when the +problems are solved. + +- Test failures start with "FAIL:". Those are the ones that indicate possible + bugs in the application, if the test is well written. + For example like this: + +====================================================================== +FAIL: 'modify' PUBLIC, 'view all' PRIVATE, 'view d&t' confidential +---------------------------------------------------------------------- +Traceback (most recent call last): + File "./davacl.py", line 75, in testModifyPublicViewAllPrivateViewDConfidential + self._testRights({ "pu": "m", "pr": "v", "co": "d" }) + File "./davacl.py", line 119, in _testRights + self._testCreate(rights) + File "./davacl.py", line 165, in _testCreate + exp_code) + File "./davacl.py", line 107, in _putEvent + % (exp_status, put.response["status"])) +AssertionError: event creation/modification: expected status code '403' (received '201') + +- Test errors start with "ERRORS" and most likely indicate a bug in the test + code itself. + +- Always set a doc string on the test methods, especially for complex test + cases