Commit 23e45342 authored by Xiaowu Zhang's avatar Xiaowu Zhang

testField: modify datetimefield's test since it don't use sub form anymore

parent 2f8a4781
...@@ -938,8 +938,6 @@ class TestFieldValueCache(ERP5TypeTestCase): ...@@ -938,8 +938,6 @@ class TestFieldValueCache(ERP5TypeTestCase):
addField(DateTimeField('datetime_field')) addField(DateTimeField('datetime_field'))
form.datetime_field._p_oid = makeDummyOid() form.datetime_field._p_oid = makeDummyOid()
form.datetime_field._edit(dict(input_style='list')) form.datetime_field._edit(dict(input_style='list'))
for i in form.datetime_field.sub_form.fields.values():
i._p_oid = makeDummyOid()
def test_method_field(self): def test_method_field(self):
field = self.root.form.field field = self.root.form.field
...@@ -985,40 +983,22 @@ class TestFieldValueCache(ERP5TypeTestCase): ...@@ -985,40 +983,22 @@ class TestFieldValueCache(ERP5TypeTestCase):
def test_datetime_field(self): def test_datetime_field(self):
field_value_cache.clear() field_value_cache.clear()
# make sure that boundmethod must not be cached.
year_field = self.root.form.datetime_field.sub_form.get_field('year', include_disabled=1)
self.assertEqual(True, type(year_field.overrides['items']) is BoundMethod)
cache_size = len(field_value_cache) cache_size = len(field_value_cache)
year_field.get_value('items') #since datetimefield do not use sub form in initialization
#start_datetime and end_datetime will not be cached
# See Formulator/StandardFields.py(line:174) self.assertEqual(False, ('Form.get_value',
# there are two get_value, start_datetime and end_datetime
cache_size += 2
# make sure that boundmethod is not cached(cache size does not change)
self.assertEqual(True, ('Form.get_value',
self.root.form.datetime_field._p_oid, self.root.form.datetime_field._p_oid,
self.root.form.datetime_field._p_oid, self.root.form.datetime_field._p_oid,
'start_datetime' 'start_datetime'
) in field_value_cache) ) in field_value_cache)
self.assertEqual(True, ('Form.get_value', self.assertEqual(False, ('Form.get_value',
self.root.form.datetime_field._p_oid, self.root.form.datetime_field._p_oid,
self.root.form.datetime_field._p_oid, self.root.form.datetime_field._p_oid,
'end_datetime' 'end_datetime'
) in field_value_cache) ) in field_value_cache)
self.assertEqual(False, ('Form.get_value', #ensure len is not changed
year_field._p_oid,
year_field._p_oid,
'items'
) in field_value_cache)
self.assertEqual(cache_size, len(field_value_cache)) self.assertEqual(cache_size, len(field_value_cache))
year_field.get_value('size')
year_field.get_value('default')
self.assertEqual(cache_size+2, len(field_value_cache))
def makeDummyOid(): def makeDummyOid():
import time, random import time, random
return '%s%s' % (time.time(), random.random()) return '%s%s' % (time.time(), random.random())
......
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