Commit be28664e authored by 's avatar

added some basic conformance tests

parent 139e1102
import unittest
import Testing
import Zope2
Zope2.startup()
import os, sys
import unittest
import time
from cStringIO import StringIO
......@@ -47,11 +48,11 @@ def aputrequest(file, content_type):
class DummyCache:
def __init__(self):
self.clear()
def ZCache_set(self, ob, data, view_name='', keywords=None,
mtime_func=None):
self.set = (ob, data)
def ZCache_get(self, ob, data, view_name='', keywords=None,
mtime_func=None):
self.get = ob
......@@ -69,14 +70,14 @@ class DummyCache:
def setStreamIterator(self, si):
self.si = si
ADummyCache=DummyCache()
class DummyCacheManager(SimpleItem):
def ZCacheManager_getCache(self):
return ADummyCache
class FileTests(unittest.TestCase):
data = open(filedata, 'rb').read()
content_type = 'application/octet-stream'
......@@ -152,7 +153,7 @@ class FileTests(unittest.TestCase):
self.assertEqual(self.file.content_type, 'text/plain')
self.failUnless(ADummyCache.invalidated)
self.failUnless(ADummyCache.set)
def testManageEditWithoutFileData(self):
self.file.manage_edit('foobar', 'text/plain')
self.assertEqual(self.file.title, 'foobar')
......@@ -242,6 +243,16 @@ class FileTests(unittest.TestCase):
self.assertEqual(len(results), 1)
self.assertEqual(results[0][1], self.file)
def test_z2interfaces(self):
from Interface.Verify import verifyClass
from OFS.Image import File
from webdav.WriteLockInterface import WriteLockInterface
from ZPublisher.HTTPRangeSupport import HTTPRangeInterface
verifyClass(HTTPRangeInterface, File)
verifyClass(WriteLockInterface, File)
class ImageTests(FileTests):
data = open(filedata, 'rb').read()
content_type = 'image/gif'
......@@ -255,7 +266,7 @@ class ImageTests(FileTests):
self.assertEqual(self.file.height, 16)
self.failUnless(ADummyCache.invalidated)
self.failUnless(ADummyCache.set)
def testStr(self):
self.assertEqual(str(self.file),
('<img src="http://foo/file" alt="" title="" height="16" width="16" />'))
......@@ -266,12 +277,20 @@ class ImageTests(FileTests):
def testViewImageOrFile(self):
pass # dtml method,screw it
def test_z2interfaces(self):
from Interface.Verify import verifyClass
from OFS.Image import Image
from webdav.WriteLockInterface import WriteLockInterface
verifyClass(WriteLockInterface, Image)
def test_suite():
suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite( FileTests ) )
suite.addTest( unittest.makeSuite( ImageTests ))
return suite
return unittest.TestSuite((
unittest.makeSuite(FileTests),
unittest.makeSuite(ImageTests),
))
if __name__ == "__main__":
unittest.main()
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
import unittest
class TestFolder(unittest.TestCase):
def test_z2interfaces(self):
from Interface.Verify import verifyClass
from OFS.Folder import Folder
from webdav.WriteLockInterface import WriteLockInterface
verifyClass(WriteLockInterface, Folder)
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(TestFolder),
))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
from unittest import TestCase, TestSuite, makeSuite, main
import unittest
import Testing
import Zope2
Zope2.startup()
from Interface.Verify import verifyClass
from OFS.CopySupport import CopySource
from OFS.ObjectManager import ObjectManager
from OFS.OrderSupport import OrderSupport
class DummyObject(CopySource):
def __init__(self, id, meta_type):
......@@ -22,15 +21,17 @@ class DummyObject(CopySource):
def wl_isLocked(self):
return 0
class OrderedObjectManager(OrderSupport, ObjectManager):
# disable permission verification
def _verifyObjectPaste(self, object, validate_src=1):
return
class TestOrderSupport(TestCase):
class TestOrderSupport(unittest.TestCase):
def _makeOne(self):
from OFS.OrderSupport import OrderSupport
class OrderedObjectManager(OrderSupport, ObjectManager):
# disable permission verification
def _verifyObjectPaste(self, object, validate_src=1):
return
f = OrderedObjectManager()
f._objects = ( {'id':'o1', 'meta_type':'mt1'}
, {'id':'o2', 'meta_type':'mt2'}
......@@ -159,14 +160,18 @@ class TestOrderSupport(TestCase):
f.setDefaultSorting('position', True)
self.failUnlessEqual( f.tpValues(), [f.o4, f.o3, f.o2] )
def test_interface(self):
def test_z2interfaces(self):
from Interface.Verify import verifyClass
from OFS.IOrderSupport import IOrderedContainer
from OFS.OrderSupport import OrderSupport
verifyClass(IOrderedContainer, OrderSupport)
def test_suite():
return TestSuite( ( makeSuite(TestOrderSupport), ) )
return unittest.TestSuite((
unittest.makeSuite(TestOrderSupport),
))
if __name__ == '__main__':
main(defaultTest='test_suite')
unittest.main(defaultTest='test_suite')
from unittest import TestCase, TestSuite, makeSuite, main
import unittest
import Testing
import Zope2
Zope2.startup()
from Interface.Verify import verifyClass
from OFS.OrderedFolder import OrderedFolder
class TestOrderedFolder(unittest.TestCase):
class TestOrderedFolder(TestCase):
def test_interface(self):
def test_z2interfaces(self):
from Interface.Verify import verifyClass
from OFS.IOrderSupport import IOrderedContainer
from OFS.OrderedFolder import OrderedFolder
from webdav.WriteLockInterface import WriteLockInterface
verifyClass(IOrderedContainer, OrderedFolder)
......@@ -19,7 +14,9 @@ class TestOrderedFolder(TestCase):
def test_suite():
return TestSuite( ( makeSuite(TestOrderedFolder), ) )
return unittest.TestSuite((
unittest.makeSuite(TestOrderedFolder),
))
if __name__ == '__main__':
main(defaultTest='test_suite')
unittest.main(defaultTest='test_suite')
#
# This file is necessary to make this directory a package.
import unittest
class TestEtagSupport(unittest.TestCase):
def test_z2interfaces(self):
from Interface.Verify import verifyClass
from webdav.EtagSupport import EtagBaseInterface
from webdav.EtagSupport import EtagSupport
verifyClass(EtagBaseInterface, EtagSupport)
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(TestEtagSupport),
))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
import unittest
class TestLockItem(unittest.TestCase):
def test_z2interfaces(self):
from Interface.Verify import verifyClass
from webdav.LockItem import LockItem
from webdav.WriteLockInterface import LockItemInterface
verifyClass(LockItemInterface, LockItem)
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(TestLockItem),
))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
import unittest
class TestLockNullResource(unittest.TestCase):
def test_z2interfaces(self):
from Interface.Verify import verifyClass
from webdav.NullResource import LockNullResource
from webdav.WriteLockInterface import WriteLockInterface
verifyClass(WriteLockInterface, LockNullResource)
class TestNullResource(unittest.TestCase):
def test_z2interfaces(self):
from Interface.Verify import verifyClass
from webdav.NullResource import NullResource
from webdav.WriteLockInterface import WriteLockInterface
verifyClass(WriteLockInterface, NullResource)
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(TestLockNullResource),
unittest.makeSuite(TestNullResource),
))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment