Commit 3826a2f9 authored by Łukasz Nowak's avatar Łukasz Nowak

Merge remote-tracking branch 'origin/master' into lazy_simulation_causality

parents 8383758b 220efc32
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string>python: here.getDefaultEmail().isDetailed()</string> </value> <value> <string>python:here.hasDefaultEmail() and here.getDefaultEmail().isDetailed()</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
1008 1009
\ No newline at end of file \ No newline at end of file
...@@ -66,19 +66,24 @@ if not reference:\n ...@@ -66,19 +66,24 @@ if not reference:\n
portal = document.getPortalObject()\n portal = document.getPortalObject()\n
portal_catalog = portal.portal_catalog\n portal_catalog = portal.portal_catalog\n
language = document.getLanguage()\n language = document.getLanguage()\n
search_kw = dict(reference=reference,\n
validation_state=validation_state,\n
# exclude current workflow changed document\n
uid=\'NOT %s\' %document.getUid())\n
if not language:\n if not language:\n
# If language is None, we have to check is this document\n # If language is None, we have to check is this document\n
# is language independent. In this case, archival is possible\n # is language independent. In this case, archival is possible\n
# But if a document exists with same reference and defined\n # But if a document exists with same reference and defined\n
# language, we can not do anything\n # language, we can not do anything\n
for old_document in portal_catalog(reference=reference, validation_state=validation_state):\n for old_document in portal_catalog(**search_kw):\n
old_document = old_document.getObject()\n old_document = old_document.getObject()\n
if not old_document.getLanguage():\n if not old_document.getLanguage():\n
old_document.archive()\n old_document.archive()\n
return\n return\n
\n \n
# We can now archive all documents with same reference and language in published state\n # We can now archive all documents with same reference and language in published state\n
for old_document in portal_catalog(reference=reference, language=language, validation_state=validation_state):\n search_kw[\'language\'] = language\n
for old_document in portal_catalog(**search_kw):\n
old_document = old_document.getObject()\n old_document = old_document.getObject()\n
old_document.archive()\n old_document.archive()\n
</string> </value> </string> </value>
......
1262 1263
\ No newline at end of file \ No newline at end of file
...@@ -197,7 +197,7 @@ class BenchmarkResult(object): ...@@ -197,7 +197,7 @@ class BenchmarkResult(object):
result_list.extend(missing_result_n * [-1]) result_list.extend(missing_result_n * [-1])
def exitSuite(self, with_error=False): def exitSuite(self, with_error=False):
elapsed_time = int(time.time() - self._current_use_case_elapsed_time) elapsed_time = time.time() - self._current_use_case_elapsed_time
if with_error: if with_error:
if self._current_suite_dict['expected'] != -1: if self._current_suite_dict['expected'] != -1:
...@@ -217,7 +217,7 @@ class BenchmarkResult(object): ...@@ -217,7 +217,7 @@ class BenchmarkResult(object):
self._current_suite_dict['expected']) self._current_suite_dict['expected'])
self._current_suite_dict['all_use_case_result_list'].append( self._current_suite_dict['all_use_case_result_list'].append(
(self._current_use_case_counter, elapsed_time)) (self._current_use_case_counter, int(elapsed_time)))
if self._current_use_case_counter != 0: if self._current_use_case_counter != 0:
self._current_suite_dict['use_case_stat'].add( self._current_suite_dict['use_case_stat'].add(
......
...@@ -1494,6 +1494,43 @@ class TestCRMMailSend(BaseTestCRM): ...@@ -1494,6 +1494,43 @@ class TestCRMMailSend(BaseTestCRM):
self.assertEquals(new_event.getTitle(), real_title) self.assertEquals(new_event.getTitle(), real_title)
self.assertEquals(new_event.getTextContent(), real_content) self.assertEquals(new_event.getTextContent(), real_content)
def test_cloneTicketAndEventList(self):
"""
All events uses after script and interaciton
workflow add a test for clone
"""
portal = self.portal
event_list = []
destination_list = []
for i in range (0,100):
person = portal.person_module.newContent(
portal_type='Person',
title = 'Person %s' %i)
destination_list.append(person)
campaing = portal.campaign_module.newContent(
portal_type='Campaign',
reference = 'Test')
for i in range(0,3):
event = portal.event_module.newContent(
portal_type='Mail Message',
title = 'Mail %s' %i,
follow_up = campaing.getRelativeUrl())
event.setDestinationList([x.getRelativeUrl() for x in destination_list])
event_list.append(event)
self.stepTic()
# use Ticket_cloneTicketAndEventList
campaing.Ticket_cloneTicketAndEventList()
self.stepTic()
cloned_campaign = [x for x in portal.campaign_module.objectValues() if x!=campaing][0]
cloned_event_list = [x for x in portal.event_module.objectValues() if x.getFollowUpValue()==cloned_campaign]
self.assertEqual(campaing.getTitle(), cloned_campaign.getTitle())
self.assertEqual(campaing.getReference(), cloned_campaign.getReference())
for i in range(0,3):
self.assertSameSet(event_list[i].getDestinationValueList(), cloned_event_list[i].getDestinationValueList())
def test_Base_addEvent(self): def test_Base_addEvent(self):
"""Check Base_addEvent script with a logged in user. """Check Base_addEvent script with a logged in user.
""" """
......
...@@ -2571,6 +2571,51 @@ return 1 ...@@ -2571,6 +2571,51 @@ return 1
self._test_document_publication_workflow('Text', self._test_document_publication_workflow('Text',
'share_alive_action') 'share_alive_action')
def test_document_publication_workflow_archiveVersion(self):
""" Test old versions of a doc are auto archived. """
portal = self.portal
upload_file = makeFileUpload('TEST-en-002.doc')
kw = dict(file=upload_file, synchronous_metadata_discovery=True)
document_002 = self.portal.Base_contribute(**kw)
document_002.publish()
self.stepTic()
document_003 = document_002.Base_createCloneDocument(batch_mode=1)
document_003.setVersion('003')
document_003.publish()
self.stepTic()
self.assertEqual('published', document_003.getValidationState())
self.assertEqual('archived', document_002.getValidationState())
# check if in any case document doesn't archive itself
# (i.e. shared_alive -> published or any other similar chain)
document_004 = document_003.Base_createCloneDocument(batch_mode=1)
document_004.setVersion('004')
document_004.shareAlive()
self.stepTic()
document_004.publish()
self.stepTic()
self.assertEqual('published', document_004.getValidationState())
# check case when no language is used
document_nolang_005 = document_004.Base_createCloneDocument(batch_mode=1)
document_nolang_005.setVersion('TEST-no-lang')
document_nolang_005.setVersion('005')
document_nolang_005.setLanguage(None)
document_nolang_005.publish()
self.stepTic()
self.assertEqual('published', document_nolang_005.getValidationState())
document_nolang_006 = document_nolang_005.Base_createCloneDocument(batch_mode=1)
document_nolang_006.setVersion('006')
document_nolang_006.shareAlive()
self.stepTic()
self.assertEqual('archived', document_nolang_005.getValidationState())
self.assertEqual('shared_alive', document_nolang_006.getValidationState())
class TestDocumentWithSecurity(TestDocumentMixin): class TestDocumentWithSecurity(TestDocumentMixin):
username = 'yusei' username = 'yusei'
...@@ -2710,8 +2755,8 @@ class TestDocumentPerformance(TestDocumentMixin): ...@@ -2710,8 +2755,8 @@ class TestDocumentPerformance(TestDocumentMixin):
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestDocument)) suite.addTest(unittest.makeSuite(TestDocument))
#suite.addTest(unittest.makeSuite(TestDocumentWithSecurity)) suite.addTest(unittest.makeSuite(TestDocumentWithSecurity))
#suite.addTest(unittest.makeSuite(TestDocumentPerformance)) suite.addTest(unittest.makeSuite(TestDocumentPerformance))
return suite return suite
......
...@@ -2,6 +2,9 @@ from persistent import Persistent ...@@ -2,6 +2,9 @@ from persistent import Persistent
class ConflictFreeLog(Persistent): class ConflictFreeLog(Persistent):
"""Scalable conflict-free append-only double-linked list """Scalable conflict-free append-only double-linked list
Wasted ZODB space due to conflicts is roughly proportional to the number of
clients that continuously add items at the same time.
""" """
_prev = _next = None _prev = _next = None
_tail_count = 0 _tail_count = 0
...@@ -70,9 +73,20 @@ class ConflictFreeLog(Persistent): ...@@ -70,9 +73,20 @@ class ConflictFreeLog(Persistent):
break break
def _p_resolveConflict(self, old_state, saved_state, new_state): def _p_resolveConflict(self, old_state, saved_state, new_state):
if old_state.get('_tail_count', 0) == new_state.get('_tail_count', 0): # May be called for the head and its predecessor.
i = len(old_state['_log']) old_tail_count = old_state.get('_tail_count', 0)
else: d = new_state.get('_tail_count', 0) - old_tail_count
if d:
if old_tail_count == saved_state.get('_tail_count', 0):
# We are the first one to rotate. Really rotate.
# Only the head conflicts in this case.
return dict(new_state, _log=saved_state['_log'][d:] + new_state['_log'])
# Another node rotated before us. Revert our rotation.
# Both the head and its predecessor conflict.
i = 0 i = 0
else:
# We didn't rotate. Just add our items to saved head.
# Only the head conflicts.
i = len(old_state['_log'])
saved_state['_log'].extend(new_state['_log'][i:]) saved_state['_log'].extend(new_state['_log'][i:])
return saved_state return saved_state
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