[Zope-CVS] CVS: Packages/Moztop/moztop/content/lib/tests - test_dav.html:1.2

Stephan Richter srichter@cbu.edu
Tue, 1 Apr 2003 08:02:08 -0500


Update of /cvs-repository/Packages/Moztop/moztop/content/lib/tests
In directory cvs.zope.org:/tmp/cvs-serv9378/moztop/content/lib/tests

Modified Files:
	test_dav.html 
Log Message:
More tests and bug fixes.


=== Packages/Moztop/moztop/content/lib/tests/test_dav.html 1.1 => 1.2 ===
--- Packages/Moztop/moztop/content/lib/tests/test_dav.html:1.1	Sun Mar 30 14:45:15 2003
+++ Packages/Moztop/moztop/content/lib/tests/test_dav.html	Tue Apr  1 08:02:07 2003
@@ -13,8 +13,20 @@
 
   - DavLockToken: constructor, set/getHref, createXML
 
+  - DavTimeout: constructor, getValue, getType, setTimeout, createXML
+
+  - DavCollection: createXML
+
   - DavHref: constructor, set/getURL, createXML
 
+  - DavLink: getSources, addSource, getDestinations, addDestination, createXML
+
+  - DavLockScope: constructor, set/getScope, isExclusive, isShared, createXML
+
+  - DavLockType: constructor, set/getType, isWrite, createXML
+
+  - DavSupportedLock: getEntries, addEntry, createXML
+
 
 TODO
 
@@ -22,12 +34,24 @@
 
   - DavLockToken: parseXML
 
+  - DavTimeout: parseXML
+
+  - DavCollection: parseXML
+
   - DavHref: parseXML
 
+  - DavLink: parseXML
+
+  - DavLockScope: parseXML
+
+  - DavLockType: parseXML
+
+  - DavSupportedLock: parseXML
 */
 
 var serializer = new XMLSerializer();
 
+/*
 function testDavDepthConstructor() {
     var d = new DavDepth('0');
     assertEquals("Test Depth Constructor with passed value.",
@@ -129,6 +153,109 @@
 }
 
 
+function testDavTimeoutConstructor() {
+    var t = new DavTimeout();
+    assertEquals(DAV_TIMETYPE_SECOND, t.type);
+    assertEquals(0, t.value);
+    var t = new DavTimeout(DAV_TIMETYPE_SECOND);
+    assertEquals(DAV_TIMETYPE_SECOND, t.type);
+    assertEquals(0, t.value);
+    var t = new DavTimeout(DAV_TIMETYPE_SECOND, 4000);
+    assertEquals(DAV_TIMETYPE_SECOND, t.type);
+    assertEquals(4000, t.value);
+    var t = new DavTimeout(DAV_TIMETYPE_INFINITE);
+    assertEquals(DAV_TIMETYPE_INFINITE, t.type);
+    assertEquals(null, t.value);
+    var t = new DavTimeout(DAV_TIMETYPE_INFINITE, 'foo');
+    assertEquals(DAV_TIMETYPE_INFINITE, t.type);
+    assertEquals(null, t.value);
+    var t = new DavTimeout(DAV_TIMETYPE_EXTEND);
+    assertEquals(DAV_TIMETYPE_EXTEND, t.type);
+    assertEquals('', t.value);
+    var t = new DavTimeout(DAV_TIMETYPE_EXTEND, 'foo');
+    assertEquals(DAV_TIMETYPE_EXTEND, t.type);
+    assertEquals('foo', t.value);
+}
+
+
+function testDavTimeoutGettersSetters() {
+    var t = new DavTimeout(DAV_TIMETYPE_SECOND, 4000);
+    assertEquals(DAV_TIMETYPE_SECOND, t.getType());
+    assertEquals(4000, t.getValue());
+
+    t.setTimeout(DAV_TIMETYPE_SECOND);
+    assertEquals(DAV_TIMETYPE_SECOND, t.type);
+    assertEquals(0, t.value);
+
+    t.setTimeout(DAV_TIMETYPE_SECOND, 4000);
+    assertEquals(DAV_TIMETYPE_SECOND, t.type);
+    assertEquals(4000, t.value);
+
+    t.setTimeout(DAV_TIMETYPE_INFINITE);
+    assertEquals(DAV_TIMETYPE_INFINITE, t.type);
+    assertEquals(null, t.value);
+
+    t.setTimeout(DAV_TIMETYPE_INFINITE, 'foo');
+    assertEquals(DAV_TIMETYPE_INFINITE, t.type);
+    assertEquals(null, t.value);
+
+    t.setTimeout(DAV_TIMETYPE_EXTEND);
+    assertEquals(DAV_TIMETYPE_EXTEND, t.type);
+    assertEquals('', t.value);
+
+    t.setTimeout(DAV_TIMETYPE_EXTEND, 'foo');
+    assertEquals(DAV_TIMETYPE_EXTEND, t.type);
+    assertEquals('foo', t.value);
+}
+
+
+function _XXX_testDavTimeoutParseXML() {
+    throw 'IncompleteTest';
+}
+
+function testDavTimeoutCreateXML() {
+    var t = new DavTimeout();
+    var doc = document.implementation.createDocument("DAV:", "D:test",
+						     null);
+    var node = doc.documentElement;
+    t.createXML(node, doc);
+    assertEquals('<a0:timeout xmlns:a0="DAV:">Second-0</a0:timeout>',
+		 serializer.serializeToString(node));
+
+    var t = new DavTimeout(DAV_TIMETYPE_INFINITE);
+    var doc = document.implementation.createDocument("DAV:", "D:test",
+						     null);
+    var node = doc.documentElement;
+    t.createXML(node, doc);
+    assertEquals('<a0:timeout xmlns:a0="DAV:">Infinite</a0:timeout>',
+		 serializer.serializeToString(node));
+
+    var t = new DavTimeout(DAV_TIMETYPE_EXTEND, ' foo');
+    var doc = document.implementation.createDocument("DAV:", "D:test",
+						     null);
+    var node = doc.documentElement;
+    t.createXML(node, doc);
+    assertEquals('<a0:timeout xmlns:a0="DAV:">Extend foo</a0:timeout>',
+		 serializer.serializeToString(node));
+
+}
+
+
+function _XXX_testDavCollectionParseXML() {
+    throw 'IncompleteTest';
+}
+
+function testDavCollectionCreateXML() {
+    var t = new DavCollection();
+    var doc = document.implementation.createDocument("DAV:", "D:test",
+						     null);
+    var node = doc.documentElement;
+    t.createXML(node, doc);
+    assertEquals('<a0:collection xmlns:a0="DAV:"/>',
+		 serializer.serializeToString(node));
+}
+
+
 function testDavHrefConstructor() {
     var href = new DavHref('http://test.com/test.html');
     assertEquals("Test Href Constructor with passed href value.",
@@ -162,6 +289,266 @@
     assertEquals(
 	"Test DavHref serializeXML() function.",
 	'<a0:href xmlns:a0="DAV:">http://test.com/t.html</a0:href>',
+	serializer.serializeToString(node));
+}
+
+
+function testDavLinkConstructor() {
+    var link = new DavLink();
+    assertEquals(0, link.sources.length);
+    assertEquals(0, link.destinations.length);
+}
+
+
+function testDavLinkGetAddSource() {
+    var link = new DavLink();
+    var src1 = DavSrc('http://test.com/test1.html')
+    var src2 = DavSrc('http://test.com/test2.html')
+    link.sources = [src1]
+    assertEquals(src1, link.getSources()[0]);
+    link.addSource(src2);
+    assertEquals(src1, link.getSources()[0]);
+    assertEquals(src2, link.getSources()[1]);
+}
+
+
+function testDavLinkGetAddDestination() {
+    var link = new DavLink();
+    var dst1 = DavDst('http://test.com/test1.html')
+    var dst2 = DavDst('http://test.com/test2.html')
+    link.destinations = [dst1]
+    assertEquals(dst1, link.getDestinations()[0]);
+    link.addSource(dst2);
+    assertEquals(dst1, link.getDestinations()[0]);
+    assertEquals(dst2, link.getDestinations()[1]);
+}
+
+
+function _XXX_testDavLinkParseXML() {
+    throw 'IncompleteTest';
+}
+
+
+function testDavLinkCreateXML() {
+    var link = new DavLink();
+    link.sources[0] = new DavSrc('test1.html'); 
+    link.sources[1] = new DavSrc('test2.html');
+    link.destinations[0] = new DavDst('test3.html');
+    link.destinations[1] = new DavDst('test4.html');
+    var doc = document.implementation.createDocument("DAV:", "D:test",
+						     null);
+    var node = doc.documentElement;
+    link.createXML(node, doc);
+    assertEquals(
+	'<a0:link xmlns:a0="DAV:"><a0:src>test1.html</a0:src>' +
+	'<a0:src>test2.html</a0:src><a0:dst>test3.html</a0:dst>' +
+	'<a0:dst>test4.html</a0:dst></a0:link>',
+	serializer.serializeToString(node));
+}
+
+
+function testDavDstConstructor() {
+    var dst = new DavDst('http://test.com/test.html');
+    assertEquals('http://test.com/test.html', dst.url);
+    var dst = new DavDst();
+    assertEquals(null, dst.url);
+}
+
+
+function testDavDstGetSetURL() {
+    var dst = new DavDst('http://test.com/test.html');
+    assertEquals('http://test.com/test.html', dst.getURL());
+    dst.setURL('http://test.com/test1.html');
+    assertEquals('http://test.com/test1.html', dst.url);
+}
+
+
+function _XXX_testDavDstParseXML() {
+    throw 'IncompleteTest';
+}
+
+function testDavDstCreateXML() {
+    var dst = new DavDst('http://test.com/t.html');
+    var doc = document.implementation.createDocument("DAV:", "D:test",
+						     null);
+    var node = doc.documentElement;
+    dst.createXML(node, doc);
+    assertEquals('<a0:dst xmlns:a0="DAV:">http://test.com/t.html</a0:dst>',
+		 serializer.serializeToString(node));
+}
+
+
+function testDavSrcConstructor() {
+    var src = new DavSrc('http://test.com/test.html');
+    assertEquals('http://test.com/test.html', src.url);
+    var src = new DavSrc();
+    assertEquals(null, src.url);
+}
+
+
+function testDavSrcGetSetURL() {
+    var src = new DavSrc('http://test.com/test.html');
+    assertEquals('http://test.com/test.html', src.getURL());
+    src.setURL('http://test.com/test1.html');
+    assertEquals('http://test.com/test1.html', src.url);
+}
+
+
+function _XXX_testDavSrcParseXML() {
+    throw 'IncompleteTest';
+}
+
+function testDavSrcCreateXML() {
+    var src = new DavSrc('http://test.com/t.html');
+    var doc = document.implementation.createDocument("DAV:", "D:test",
+						     null);
+    var node = doc.documentElement;
+    src.createXML(node, doc);
+    assertEquals('<a0:src xmlns:a0="DAV:">http://test.com/t.html</a0:src>',
+		 serializer.serializeToString(node));
+}
+
+
+function testDavLockScopeConstructor() {
+    var s = new DavLockScope();
+    assertEquals(DAV_SHARED_LOCKSCOPE, s.scope);
+    var s = new DavLockScope(DAV_EXCLUSIVE_LOCKSCOPE);
+    assertEquals(DAV_EXCLUSIVE_LOCKSCOPE, s.scope);
+}
+
+
+function testDavLockScopeGetSetScope() {
+    var s = new DavLockScope(DAV_EXCLUSIVE_LOCKSCOPE);
+    assertEquals(DAV_EXCLUSIVE_LOCKSCOPE, s.getScope());
+    s.setScope(DAV_SHARED_LOCKSCOPE)
+    assertEquals(DAV_SHARED_LOCKSCOPE, s.scope);
+    try {
+	s.setScope('foo');
+    }
+    catch(error) {
+	assertEquals("The value 'foo' is not a valid scope. Use one " +
+		     "of the following values instead: shared, exclusive", 
+		     error.serialize());
+    }
+}
+
+function testDavIsSharedExclusive() {
+    var s = new DavLockScope(DAV_EXCLUSIVE_LOCKSCOPE);
+    assertEquals(true, s.isExclusive());
+    assertEquals(false, s.isShared());
+
+    var s = new DavLockScope(DAV_SHARED_LOCKSCOPE);
+    assertEquals(false, s.isExclusive());
+    assertEquals(true, s.isShared());
+
+}
+
+function _XXX_testDavLockScopeParseXML() {
+    throw 'IncompleteTest';
+}
+
+function testDavLockScopeCreateXML() {
+    var s = new DavLockScope(DAV_SHARED_LOCKSCOPE);
+    var doc = document.implementation.createDocument("DAV:", "D:test",
+						     null);
+    var node = doc.documentElement;
+    s.createXML(node, doc);
+    assertEquals('<a0:lockscope xmlns:a0="DAV:"><a0:shared/></a0:lockscope>',
+		 serializer.serializeToString(node));
+}
+
+
+function testDavLockScopeConstants() {
+    assertEquals("shared", DAV_SHARED_LOCKSCOPE);
+    assertEquals("exclusive", DAV_EXCLUSIVE_LOCKSCOPE);
+}
+
+
+function testDavLockTypeConstructor() {
+    var t = new DavLockType();
+    assertEquals(DAV_WRITE_LOCKTYPE, t.type);
+    var t = new DavLockType(DAV_WRITE_LOCKTYPE);
+    assertEquals(DAV_WRITE_LOCKTYPE, t.type);
+}
+
+
+function testDavLockTypeGetSetType() {
+    var t = new DavLockType();
+    t.type = 'foo';
+    assertEquals('foo', t.getType());
+    t.setType(DAV_WRITE_LOCKTYPE)
+    assertEquals(DAV_WRITE_LOCKTYPE, t.type);
+    try {
+	t.setType('foo');
+    }
+    catch(error) {
+	assertEquals("The lock type 'foo' is not a valid type. Use one " +
+		     "of the following values instead: write", 
+		     error.serialize());
+    }
+}
+
+function testDavIsWrite() {
+    var s = new DavLockType(DAV_WRITE_LOCKTYPE);
+    assertEquals(true, s.isWrite());
+    s.type = 'foo'
+    assertEquals(false, s.isWrite());
+}
+
+function _XXX_testDavLockTypeParseXML() {
+    throw 'IncompleteTest';
+}
+
+function testDavLockTypeCreateXML() {
+    var s = new DavLockType();
+    var doc = document.implementation.createDocument("DAV:", "D:test",
+						     null);
+    var node = doc.documentElement;
+    s.createXML(node, doc);
+    assertEquals('<a0:locktype xmlns:a0="DAV:"><a0:write/></a0:locktype>',
+		 serializer.serializeToString(node));
+}
+
+
+function testDavLockTypeConstants() {
+    assertEquals("write", DAV_WRITE_LOCKTYPE);
+}
+*/
+
+function testDavSupportedLockConstructor() {
+    var lock = new DavSupportedLock();
+    assertEquals(0, lock.entries.length);
+}
+
+
+function testDavSupportedLockGetAddEntry() {
+    var lock = new DavSupportedLock();
+    var entry1 = new DavLockEntry();
+    var entry2 = new DavLockEntry();
+    lock.entries = [entry1];
+    assertEquals(entry1, lock.getEntries()[0]);
+    lock.addEntry(entry2);
+    assertEquals(entry1, lock.getEntries()[0]);
+    assertEquals(entry2, lock.getEntries()[1]);
+}
+
+
+function _XXX_testDavSupportedLockParseXML() {
+    throw 'IncompleteTest';
+}
+
+
+function testDavSupportedLockCreateXML() {
+    var lock = new DavSupportedLock();
+    lock.entries[0] = new DavLockEntry(); 
+    var doc = document.implementation.createDocument("DAV:", "D:test",
+						     null);
+    var node = doc.documentElement;
+    lock.createXML(node, doc);
+    assertEquals(
+	'<a0:supportedlock xmlns:a0="DAV:"><a0:lockentry><a0:lockscope>' +
+	'<a0:shared/></a0:lockscope><a0:locktype><a0:write/>' +
+	'</a0:locktype></a0:lockentry></a0:supportedlock>',
 	serializer.serializeToString(node));
 }