the filename
the dimensions
diff --git a/tests/test_standard.py b/tests/test_standard.py
index b0e037f9c..d2b059d00 100644
--- a/tests/test_standard.py
+++ b/tests/test_standard.py
@@ -100,3 +100,37 @@ def test_httpimport(self):
url = "http://foo/bar?john=doe"
v = standard.http_import(context,url)
+ def test_date_api(self):
+ from DateTime.DateTime import DateTime
+ self.assertEqual(35, standard.daysBetween((2024,1,1,12,0,0,0,0,0), (2024,2,5,12,0,0,0,0,0)))
+ self.assertEqual(0, standard.daysBetween((2024,1,1,12,0,0,0,0,0), (2024,1,1,12,0,0,0,0,0)))
+ self.assertEqual(-50, standard.daysBetween((2024,1,1,12,0,0,0,0,0), (2023,11,12,12,0,0,0,0,0)))
+ self.assertEqual(1, standard.compareDate((2024,1,1,12,0,0,0,0,0), (2024,2,5,12,0,0,0,0,0)))
+ self.assertEqual(0, standard.compareDate((2024,1,1,12,0,0,0,0,0), (2024,1,1,12,0,0,0,0,0)))
+ self.assertEqual(-1, standard.compareDate((2024,1,1,12,0,0,0,0,0), (2023,11,12,12,0,0,0,0,0)))
+
+ def test_operator_api(self):
+ self.assertEqual(int, standard.operator_gettype(1))
+ self.assertEqual(str, standard.operator_gettype('foo'))
+ self.assertEqual(str, standard.operator_gettype(u'foo'))
+ d = {'john':'doe'}
+ self.assertFalse('foo' in d)
+ self.assertIsNone(d.get('foo'))
+ standard.operator_setitem(d, 'foo', 'bar')
+ self.assertTrue('foo' in d)
+ self.assertEqual('bar', d.get('foo'))
+ self.assertEqual('bar', standard.operator_getitem(d, 'foo'))
+ self.assertEqual('bar', standard.operator_getitem(d, 'Foo'))
+ self.assertEqual('bar', standard.operator_getitem(d, 'FOO'))
+ standard.operator_delitem(d, 'foo')
+ self.assertFalse('foo' in d)
+ self.assertIsNone(d.get('foo'))
+
+ def test_mappings_api(self):
+ l1 = ['A', 'B', 'B', 'C']
+ l2 = ['C', 'D']
+ self.assertListEqual(['C'], standard.intersection_list(l1, l2))
+ self.assertListEqual(['A', 'B', 'B'], standard.difference_list(l1, l2))
+ self.assertListEqual(['A', 'B', 'B', 'C', 'D'], standard.concat_list(l1, l2))
+ self.assertDictEqual({'A':'B','B':'C'}, standard.dict_list(l1))
+ self.assertListEqual(['A', 'B', 'C'], standard.distinct_list(l1))
diff --git a/tests/test_zms.py b/tests/test_zms.py
new file mode 100644
index 000000000..360fbb885
--- /dev/null
+++ b/tests/test_zms.py
@@ -0,0 +1,64 @@
+# encoding: utf-8
+
+from OFS.Folder import Folder
+
+# Product imports.
+from tests.zms_test_util import *
+
+# /Products/zms> python -m unittest discover -s unit_tests
+# /Products/zms> python -m unittest test_zms.ZMSTest
+class ZMSTest(ZMSPortalTestCase):
+
+ temp_title = 'temp-test'
+
+ def setUp(self):
+ super(ZMSTest, self).setUp()
+ print('[setUp] create %s'%self.temp_title)
+ zmscontext = self.context
+ clients = zmscontext.getPortalClients()
+ clients[0].manage_delObjects([clients[0].getCatalogAdapter().id])
+
+
+ def test_portal(self):
+ zmscontext = self.context
+ clients = zmscontext.getPortalClients()
+ self.assertEqual(3, len(clients))
+ for client in clients:
+ self.assertIsNotNone(client.getPortalMaster())
+
+ def test_zcatalog_adapter(self):
+ zmscontext = self.context
+ catalog_adapter = zmscontext.getCatalogAdapter()
+ self.assertIsNotNone(catalog_adapter)
+ # Clients have parent catalog-adapter.
+ clients = zmscontext.getPortalClients()
+ for i in range(len(clients)):
+ client = clients[i]
+ if i == 0:
+ self.assertEqual(catalog_adapter, client.getCatalogAdapter())
+ else:
+ self.assertNotEqual(catalog_adapter, client.getCatalogAdapter())
+
+ def test_metaobj_manager(self):
+ zmscontext = self.context
+ metaobj_manager = zmscontext.getMetaobjManager()
+ self.assertIsNotNone(metaobj_manager)
+ clients = zmscontext.getPortalClients()
+ for i in range(len(clients)):
+ client = clients[i]
+ self.assertEqual(metaobj_manager.getMetaobjIds(), client.getMetaobjManager().getMetaobjIds())
+
+ def test_conf_properties(self):
+ zmscontext = self.context
+ clients = zmscontext.getPortalClients()
+ for i in range(len(clients)):
+ client = clients[i]
+ self.assertIsNone(client.getConfProperty('foo'))
+ zmscontext.setConfProperty('foo','bar')
+ self.assertEqual('bar', client.getConfProperty('foo'))
+ zmscontext.delConfProperty('foo')
+ self.assertIsNone(client.getConfProperty('foo'))
+
+
+ def tearDown(self):
+ print('[tearDown] remove %s'%self.temp_title)
diff --git a/tests/test_zmscontainerobject.py b/tests/test_zmscontainerobject.py
index b78489775..8c628263e 100644
--- a/tests/test_zmscontainerobject.py
+++ b/tests/test_zmscontainerobject.py
@@ -7,8 +7,6 @@
# Product imports.
from tests.zms_test_util import *
-from Products.zms import mock_http
-from Products.zms import zms
# /Products/zms> python -m unittest discover -s unit_tests
# /Products/zms> python -m unittest test_zmscontainerobject.ZMSContainerObjectTest
@@ -17,12 +15,11 @@ class ZMSContainerObjectTest(ZMSTestCase):
temp_title = 'temp-test'
def setUp(self):
- folder = Folder('myzmsx')
- folder.REQUEST = mock_http.MockHTTPRequest({'lang':'eng','preview':'preview'})
- zmscontext = zms.initZMS(folder, 'content', 'titlealt', 'title', 'eng', 'eng', folder.REQUEST)
- self.context = zmscontext
+ super(ZMSContainerObjectTest, self).setUp()
print('[setUp] create %s'%self.temp_title)
- self.folder = zmscontext.manage_addZMSCustom('ZMSFolder',{'title':self.temp_title,'titlealt':self.temp_title},zmscontext.REQUEST)
+ zmscontext = self.context
+ request = zmscontext.REQUEST
+ self.folder = zmscontext.manage_addZMSCustom('ZMSFolder',{'title':self.temp_title,'titlealt':self.temp_title},request)
def test_tree(self):
context = self.context
diff --git a/tests/zms_test_util.py b/tests/zms_test_util.py
index 895ae72b6..982e3bddd 100644
--- a/tests/zms_test_util.py
+++ b/tests/zms_test_util.py
@@ -30,6 +30,27 @@ def writeInfo(self, s):
def writeError(self, s):
self.context.write(logging.ERROR,s)
+
+class ZMSPortalTestCase(ZMSTestCase):
+
+ def setUp(self):
+ super(ZMSPortalTestCase, self).setUp()
+ zmscontext = self.context
+ request = zmscontext.REQUEST
+ home = zmscontext.aq_parent
+ ids = []
+ n = 3
+ for i in range(n):
+ id = 'client%i'%i
+ client = Folder(id)
+ setattr(client, home.id, home)
+ home._setObject(client.id, client)
+ client = getattr(home, client.id)
+ zmsclient = zms.initZMS(client, 'content', id, id, 'eng', 'eng', request)
+ zmsclient.setConfProperty('Portal.Master',home.id)
+ ids.append(id)
+ zmscontext.setConfProperty('Portal.Clients',ids)
+
def addClient(zmscontext, id):
"""
Add ZMS client.