Commit 825b35e7 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_erp5: Added test for check if wendelin.core 2 works with the instance

   This is mostly written by Kiril.
parent 2432ef2c
# -*- coding:utf-8 -*-
##############################################################################
#
# Copyright (C) 2021 Nexedi SA and Contributors.
#
# This program is free software: you can Use, Study, Modify and Redistribute
# it under the terms of the GNU General Public License version 3, or (at your
# option) any later version, as published by the Free Software Foundation.
#
# You can also Link and Combine this program with other software covered by
# the terms of any of the Free Software licenses or any of the Open Source
# Initiative approved licenses and Convey the resulting work. Corresponding
# source of such a combination shall include the source code for all other
# software used.
#
# This program is distributed WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options.
#
##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
import transaction
from wendelin.bigarray import array_zodb
# Minimal test to make sure that wendelin.core works at all.
class TestSlapOSWendelinCoreBasic(SlapOSTestCaseMixin):
def test(self):
ZBigArray = array_zodb.ZBigArray
# create the array in temporary "root" placeholder.
# NOTE we need created objects to enter ZODB for real, but
# newContent(temp_object=True) creates an object with ._p_jar=None
zroot = self.portal.newContent()
zroot.zarray = A = ZBigArray(shape=(4,), dtype=int)
self.commit()
self.assertIsNotNone(zroot._p_jar) # zroot enters ZODB
self.assertIsNotNone(A._p_jar) # zarray ----//----
# the array must initially read as all zeros
a = A[:]
self.assertEquals(a, [0,0,0,0])
b = A[:]
self.assertEquals(b, [0,0,0,0])
# we can assign items in a view, and the assignment propagates to another view
a[2] = 1
self.assertEquals(a, [0,0,1,0])
self.assertEquals(b, [0,0,1,0])
# on abort local changes are reverted
transaction.abort()
self.assertEquals(a, [0,0,0,0])
self.assertEquals(b, [0,0,0,0])
# on commit local changes are saved into ZODB
a[1] = 3
b[2] = 4
self.assertEquals(a, [0,3,4,0])
self.assertEquals(b, [0,3,4,0])
self.commit()
transaction.abort() # just in case
c = A[:]
self.assertEquals(a, [0,3,4,0])
self.assertEquals(b, [0,3,4,0])
self.assertEquals(c, [0,3,4,0])
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSlapOSWendelinCoreTwo</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSWendelinCoreTwo</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -7,4 +7,5 @@ test.erp5.testSlapOSERP5DefaultScenario
test.erp5.testSlapOSXHTML
test.erp5.testSlapOSCodingStyle
test.erp5.testSlapOSAuthenticationPolicy
test.erp5.testSlapOSERP5InteractionWorkflow
\ No newline at end of file
test.erp5.testSlapOSERP5InteractionWorkflow
test.erp5.testSlapOSWendelinCoreTwo
\ No newline at end of file
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