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 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/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 diff --git a/Tests/webdavlib.py b/Tests/webdavlib.py index 3498e9706..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) @@ -204,11 +224,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 + "/>" diff --git a/Tests/webdav-sync.py b/Tests/webdavsync.py similarity index 97% rename from Tests/webdav-sync.py rename to Tests/webdavsync.py index 969a181fd..61edbb8a4 100755 --- a/Tests/webdav-sync.py +++ b/Tests/webdavsync.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)