Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ivan Tyagov
slapos.core
Commits
3f239154
Commit
3f239154
authored
Nov 14, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve code reusability.
parent
40a3cc36
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
118 additions
and
108 deletions
+118
-108
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSCloudConstraint.py
...lapos_cloud/TestTemplateItem/testSlapOSCloudConstraint.py
+117
-107
master/bt5/slapos_cloud/bt/revision
master/bt5/slapos_cloud/bt/revision
+1
-1
No files found.
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSCloudConstraint.py
View file @
3f239154
...
@@ -8,31 +8,32 @@ from Products.SlapOS.tests.testSlapOSMixin import \
...
@@ -8,31 +8,32 @@ from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
testSlapOSMixin
import
transaction
import
transaction
def
getMessageList
(
o
):
class
TestSlapOSConstraintMixin
(
testSlapOSMixin
):
@
staticmethod
def
getMessageList
(
o
):
return
[
str
(
q
.
getMessage
())
for
q
in
o
.
checkConsistency
()]
return
[
str
(
q
.
getMessage
())
for
q
in
o
.
checkConsistency
()]
class
TestSlapOSConstraintMixin
(
testSlapOSMixin
):
def
_test_property_existence
(
self
,
obj
,
property_id
,
consistency_message
,
def
_test_property_existence
(
self
,
property_id
,
consistency_message
,
value
=
'A'
):
value
=
'A'
):
self
.
software_instance
.
edit
(
**
{
property_id
:
value
})
obj
.
edit
(
**
{
property_id
:
value
})
# fetch basic list of consistency messages
# fetch basic list of consistency messages
current_message_list
=
getMessageList
(
self
.
software_instance
)
current_message_list
=
self
.
getMessageList
(
obj
)
# test the test: no expected message found
# test the test: no expected message found
self
.
assertFalse
(
consistency_message
in
current_message_list
)
self
.
assertFalse
(
consistency_message
in
current_message_list
)
# required
# required
self
.
software_instance
.
edit
(
**
{
property_id
:
None
})
obj
.
edit
(
**
{
property_id
:
None
})
self
.
assertTrue
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertTrue
(
consistency_message
in
self
.
getMessageList
(
obj
))
self
.
software_instance
.
edit
(
**
{
property_id
:
''
})
obj
.
edit
(
**
{
property_id
:
''
})
self
.
assertTrue
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertTrue
(
consistency_message
in
self
.
getMessageList
(
obj
))
self
.
software_instance
.
edit
(
**
{
property_id
:
value
})
obj
.
edit
(
**
{
property_id
:
value
})
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
obj
))
self
.
assertSameSet
(
current_message_list
,
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
self
.
getMessageList
(
obj
))
class
TestSlapOSComputerPartitionConstraint
(
TestSlapOSConstraintMixin
):
class
TestSlapOSComputerPartitionConstraint
(
TestSlapOSConstraintMixin
):
def
test_non_busy_partition_has_no_related_instance
(
self
):
def
test_non_busy_partition_has_no_related_instance
(
self
):
...
@@ -53,15 +54,15 @@ class TestSlapOSComputerPartitionConstraint(TestSlapOSConstraintMixin):
...
@@ -53,15 +54,15 @@ class TestSlapOSComputerPartitionConstraint(TestSlapOSConstraintMixin):
"arity is equal to 1 but should be between 0 and 0"
"arity is equal to 1 but should be between 0 and 0"
# test the test: no expected message found
# test the test: no expected message found
current_message_list
=
getMessageList
(
partition
)
current_message_list
=
self
.
getMessageList
(
partition
)
self
.
assertFalse
(
consistency_message
in
current_message_list
)
self
.
assertFalse
(
consistency_message
in
current_message_list
)
# check case for Software Instance
# check case for Software Instance
software_instance
.
setAggregate
(
partition
.
getRelativeUrl
())
software_instance
.
setAggregate
(
partition
.
getRelativeUrl
())
software_instance
.
immediateReindexObject
()
software_instance
.
immediateReindexObject
()
self
.
assertTrue
(
consistency_message
in
getMessageList
(
partition
))
self
.
assertTrue
(
consistency_message
in
self
.
getMessageList
(
partition
))
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
partition
,
'busy'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
partition
,
'busy'
)
self
.
assertFalse
(
consistency_message
in
getMessageList
(
partition
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
partition
))
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
partition
,
'free'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
partition
,
'free'
)
software_instance
.
setAggregate
(
None
)
software_instance
.
setAggregate
(
None
)
software_instance
.
immediateReindexObject
()
software_instance
.
immediateReindexObject
()
...
@@ -69,9 +70,9 @@ class TestSlapOSComputerPartitionConstraint(TestSlapOSConstraintMixin):
...
@@ -69,9 +70,9 @@ class TestSlapOSComputerPartitionConstraint(TestSlapOSConstraintMixin):
# check case fo Slave Instance
# check case fo Slave Instance
slave_instance
.
setAggregate
(
partition
.
getRelativeUrl
())
slave_instance
.
setAggregate
(
partition
.
getRelativeUrl
())
slave_instance
.
immediateReindexObject
()
slave_instance
.
immediateReindexObject
()
self
.
assertTrue
(
consistency_message
in
getMessageList
(
partition
))
self
.
assertTrue
(
consistency_message
in
self
.
getMessageList
(
partition
))
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
partition
,
'busy'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
partition
,
'busy'
)
self
.
assertFalse
(
consistency_message
in
getMessageList
(
partition
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
partition
))
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
partition
,
'free'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
partition
,
'free'
)
class
TestSlapOSSoftwareInstanceConstraint
(
TestSlapOSConstraintMixin
):
class
TestSlapOSSoftwareInstanceConstraint
(
TestSlapOSConstraintMixin
):
...
@@ -84,7 +85,7 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
...
@@ -84,7 +85,7 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
def
test_connection_xml
(
self
):
def
test_connection_xml
(
self
):
# fetch basic list of consistency messages
# fetch basic list of consistency messages
current_message_list
=
getMessageList
(
self
.
software_instance
)
current_message_list
=
self
.
getMessageList
(
self
.
software_instance
)
consistency_message
=
"Connection XML is invalid: Start tag expected, '<' not "
\
consistency_message
=
"Connection XML is invalid: Start tag expected, '<' not "
\
"found, line 1, column 1"
"found, line 1, column 1"
...
@@ -95,23 +96,24 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
...
@@ -95,23 +96,24 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
# connection_xml is optional
# connection_xml is optional
self
.
software_instance
.
edit
(
connection_xml
=
None
)
self
.
software_instance
.
edit
(
connection_xml
=
None
)
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
self
.
getMessageList
(
self
.
software_instance
))
self
.
software_instance
.
edit
(
connection_xml
=
''
)
self
.
software_instance
.
edit
(
connection_xml
=
''
)
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
self
.
getMessageList
(
self
.
software_instance
))
# if available shall be correct XML
# if available shall be correct XML
self
.
software_instance
.
edit
(
connection_xml
=
'this is bad xml'
)
self
.
software_instance
.
edit
(
connection_xml
=
'this is bad xml'
)
self
.
assertTrue
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertTrue
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
software_instance
.
edit
(
connection_xml
=
self
.
generateEmptyXml
())
self
.
software_instance
.
edit
(
connection_xml
=
self
.
generateEmptyXml
())
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
self
.
getMessageList
(
self
.
software_instance
))
def
test_property_existence_destination_reference
(
self
):
def
test_property_existence_destination_reference
(
self
):
self
.
_test_property_existence
(
'destination_reference'
,
self
.
_test_property_existence
(
self
.
software_instance
,
'destination_reference'
,
'Property existence error for property destination_reference, this document'
'Property existence error for property destination_reference, this document'
' has no such property or the property has never been set'
)
' has no such property or the property has never been set'
)
...
@@ -122,17 +124,18 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
...
@@ -122,17 +124,18 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
'has never been set'
'has never been set'
# not required in draft state
# not required in draft state
self
.
software_instance
.
edit
(
**
{
property_id
:
None
})
self
.
software_instance
.
edit
(
**
{
property_id
:
None
})
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
software_instance
.
edit
(
**
{
property_id
:
''
})
self
.
software_instance
.
edit
(
**
{
property_id
:
''
})
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
'start_requested'
)
'start_requested'
)
self
.
_test_property_existence
(
property_id
,
consistency_message
)
self
.
_test_property_existence
(
self
.
software_instance
,
property_id
,
consistency_message
)
def
test_property_existence_reference
(
self
):
def
test_property_existence_reference
(
self
):
self
.
_test_property_existence
(
'reference'
,
self
.
_test_property_existence
(
self
.
software_instance
,
'reference'
,
'Property existence error for property reference, this document'
'Property existence error for property reference, this document'
' has no such property or the property has never been set'
)
' has no such property or the property has never been set'
)
...
@@ -141,30 +144,32 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
...
@@ -141,30 +144,32 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
consistency_message
=
'Property existence error for property '
\
consistency_message
=
'Property existence error for property '
\
'ssl_certificate, this document has no such property or the property'
\
'ssl_certificate, this document has no such property or the property'
\
' has never been set'
' has never been set'
self
.
_test_property_existence
(
property_id
,
consistency_message
)
self
.
_test_property_existence
(
self
.
software_instance
,
property_id
,
consistency_message
)
# not required in destroy_requested state
# not required in destroy_requested state
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
'destroy_requested'
)
'destroy_requested'
)
self
.
software_instance
.
edit
(
**
{
property_id
:
None
})
self
.
software_instance
.
edit
(
**
{
property_id
:
None
})
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
software_instance
.
edit
(
**
{
property_id
:
''
})
self
.
software_instance
.
edit
(
**
{
property_id
:
''
})
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
def
test_property_existence_ssl_key
(
self
):
def
test_property_existence_ssl_key
(
self
):
property_id
=
'ssl_key'
property_id
=
'ssl_key'
consistency_message
=
'Property existence error for property '
\
consistency_message
=
'Property existence error for property '
\
'ssl_key, this document has no such property or the property'
\
'ssl_key, this document has no such property or the property'
\
' has never been set'
' has never been set'
self
.
_test_property_existence
(
property_id
,
consistency_message
)
self
.
_test_property_existence
(
self
.
software_instance
,
property_id
,
consistency_message
)
# not required in destroy_requested state
# not required in destroy_requested state
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
'destroy_requested'
)
'destroy_requested'
)
self
.
software_instance
.
edit
(
**
{
property_id
:
None
})
self
.
software_instance
.
edit
(
**
{
property_id
:
None
})
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
software_instance
.
edit
(
**
{
property_id
:
''
})
self
.
software_instance
.
edit
(
**
{
property_id
:
''
})
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
def
test_predecessor_related
(
self
):
def
test_predecessor_related
(
self
):
software_instance2
=
self
.
portal
.
software_instance_module
.
newContent
(
software_instance2
=
self
.
portal
.
software_instance_module
.
newContent
(
...
@@ -173,7 +178,7 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
...
@@ -173,7 +178,7 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
portal_type
=
'Software Instance'
)
portal_type
=
'Software Instance'
)
# fetch basic list of consistency messages
# fetch basic list of consistency messages
current_message_list
=
getMessageList
(
self
.
software_instance
)
current_message_list
=
self
.
getMessageList
(
self
.
software_instance
)
consistency_message
=
"There is more then one related predecessor"
consistency_message
=
"There is more then one related predecessor"
...
@@ -184,23 +189,23 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
...
@@ -184,23 +189,23 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
software_instance2
.
edit
(
predecessor
=
self
.
software_instance
.
getRelativeUrl
())
software_instance2
.
edit
(
predecessor
=
self
.
software_instance
.
getRelativeUrl
())
software_instance3
.
edit
(
predecessor
=
self
.
software_instance
.
getRelativeUrl
())
software_instance3
.
edit
(
predecessor
=
self
.
software_instance
.
getRelativeUrl
())
self
.
tic
()
self
.
tic
()
self
.
assertTrue
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertTrue
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
# one is good
# one is good
software_instance2
.
edit
(
predecessor
=
None
)
software_instance2
.
edit
(
predecessor
=
None
)
self
.
tic
()
self
.
tic
()
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
self
.
getMessageList
(
self
.
software_instance
))
# none is good
# none is good
software_instance3
.
edit
(
predecessor
=
None
)
software_instance3
.
edit
(
predecessor
=
None
)
self
.
tic
()
self
.
tic
()
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
self
.
getMessageList
(
self
.
software_instance
))
def
test_sla_xml
(
self
):
def
test_sla_xml
(
self
):
# fetch basic list of consistency messages
# fetch basic list of consistency messages
current_message_list
=
getMessageList
(
self
.
software_instance
)
current_message_list
=
self
.
getMessageList
(
self
.
software_instance
)
consistency_message
=
"Sla XML is invalid: Start tag expected, '<' not "
\
consistency_message
=
"Sla XML is invalid: Start tag expected, '<' not "
\
"found, line 1, column 1"
"found, line 1, column 1"
...
@@ -211,24 +216,24 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
...
@@ -211,24 +216,24 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
# sla_xml is optional
# sla_xml is optional
self
.
software_instance
.
edit
(
sla_xml
=
None
)
self
.
software_instance
.
edit
(
sla_xml
=
None
)
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
self
.
getMessageList
(
self
.
software_instance
))
self
.
software_instance
.
edit
(
sla_xml
=
''
)
self
.
software_instance
.
edit
(
sla_xml
=
''
)
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
self
.
getMessageList
(
self
.
software_instance
))
# if available shall be correct XML
# if available shall be correct XML
self
.
software_instance
.
edit
(
sla_xml
=
'this is bad xml'
)
self
.
software_instance
.
edit
(
sla_xml
=
'this is bad xml'
)
self
.
assertTrue
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertTrue
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
software_instance
.
edit
(
sla_xml
=
self
.
generateEmptyXml
())
self
.
software_instance
.
edit
(
sla_xml
=
self
.
generateEmptyXml
())
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
self
.
getMessageList
(
self
.
software_instance
))
def
test_text_content
(
self
):
def
test_text_content
(
self
):
# fetch basic list of consistency messages
# fetch basic list of consistency messages
current_message_list
=
getMessageList
(
self
.
software_instance
)
current_message_list
=
self
.
getMessageList
(
self
.
software_instance
)
consistency_message
=
"Instance XML is invalid: Start tag expected, '<' not "
\
consistency_message
=
"Instance XML is invalid: Start tag expected, '<' not "
\
"found, line 1, column 1"
"found, line 1, column 1"
...
@@ -239,20 +244,20 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
...
@@ -239,20 +244,20 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
# text_content is optional
# text_content is optional
self
.
software_instance
.
edit
(
text_content
=
None
)
self
.
software_instance
.
edit
(
text_content
=
None
)
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
self
.
getMessageList
(
self
.
software_instance
))
self
.
software_instance
.
edit
(
text_content
=
''
)
self
.
software_instance
.
edit
(
text_content
=
''
)
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
self
.
getMessageList
(
self
.
software_instance
))
# if available shall be correct XML
# if available shall be correct XML
self
.
software_instance
.
edit
(
text_content
=
'this is bad xml'
)
self
.
software_instance
.
edit
(
text_content
=
'this is bad xml'
)
self
.
assertTrue
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertTrue
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
software_instance
.
edit
(
text_content
=
self
.
generateEmptyXml
())
self
.
software_instance
.
edit
(
text_content
=
self
.
generateEmptyXml
())
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
self
.
getMessageList
(
self
.
software_instance
))
class
TestSlapOSSlaveInstanceConstraint
(
TestSlapOSConstraintMixin
):
class
TestSlapOSSlaveInstanceConstraint
(
TestSlapOSConstraintMixin
):
def
afterSetUp
(
self
):
def
afterSetUp
(
self
):
...
@@ -269,14 +274,15 @@ class TestSlapOSSlaveInstanceConstraint(TestSlapOSConstraintMixin):
...
@@ -269,14 +274,15 @@ class TestSlapOSSlaveInstanceConstraint(TestSlapOSConstraintMixin):
property_id
=
'source_reference'
property_id
=
'source_reference'
# not required in draft state
# not required in draft state
self
.
software_instance
.
edit
(
**
{
property_id
:
None
})
self
.
software_instance
.
edit
(
**
{
property_id
:
None
})
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
software_instance
.
edit
(
**
{
property_id
:
''
})
self
.
software_instance
.
edit
(
**
{
property_id
:
''
})
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
'start_requested'
)
'start_requested'
)
self
.
_test_property_existence
(
property_id
,
consistency_message
)
self
.
_test_property_existence
(
self
.
software_instance
,
property_id
,
consistency_message
)
def
test_property_existence_text_content
(
self
):
def
test_property_existence_text_content
(
self
):
consistency_message
=
'Property existence error for property '
\
consistency_message
=
'Property existence error for property '
\
...
@@ -285,17 +291,18 @@ class TestSlapOSSlaveInstanceConstraint(TestSlapOSConstraintMixin):
...
@@ -285,17 +291,18 @@ class TestSlapOSSlaveInstanceConstraint(TestSlapOSConstraintMixin):
property_id
=
'text_content'
property_id
=
'text_content'
# not required in draft state
# not required in draft state
self
.
software_instance
.
edit
(
**
{
property_id
:
None
})
self
.
software_instance
.
edit
(
**
{
property_id
:
None
})
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
software_instance
.
edit
(
**
{
property_id
:
''
})
self
.
software_instance
.
edit
(
**
{
property_id
:
''
})
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
'start_requested'
)
'start_requested'
)
self
.
_test_property_existence
(
property_id
,
consistency_message
)
self
.
_test_property_existence
(
self
.
software_instance
,
property_id
,
consistency_message
)
def
test_property_existence_reference
(
self
):
def
test_property_existence_reference
(
self
):
self
.
_test_property_existence
(
'reference'
,
self
.
_test_property_existence
(
self
.
software_instance
,
'reference'
,
'Property existence error for property reference, this document'
'Property existence error for property reference, this document'
' has no such property or the property has never been set'
)
' has no such property or the property has never been set'
)
...
@@ -306,7 +313,7 @@ class TestSlapOSSlaveInstanceConstraint(TestSlapOSConstraintMixin):
...
@@ -306,7 +313,7 @@ class TestSlapOSSlaveInstanceConstraint(TestSlapOSConstraintMixin):
portal_type
=
'Slave Instance'
)
portal_type
=
'Slave Instance'
)
# fetch basic list of consistency messages
# fetch basic list of consistency messages
current_message_list
=
getMessageList
(
self
.
software_instance
)
current_message_list
=
self
.
getMessageList
(
self
.
software_instance
)
consistency_message
=
"There is more then one related predecessor"
consistency_message
=
"There is more then one related predecessor"
...
@@ -317,19 +324,19 @@ class TestSlapOSSlaveInstanceConstraint(TestSlapOSConstraintMixin):
...
@@ -317,19 +324,19 @@ class TestSlapOSSlaveInstanceConstraint(TestSlapOSConstraintMixin):
software_instance2
.
edit
(
predecessor
=
self
.
software_instance
.
getRelativeUrl
())
software_instance2
.
edit
(
predecessor
=
self
.
software_instance
.
getRelativeUrl
())
software_instance3
.
edit
(
predecessor
=
self
.
software_instance
.
getRelativeUrl
())
software_instance3
.
edit
(
predecessor
=
self
.
software_instance
.
getRelativeUrl
())
self
.
tic
()
self
.
tic
()
self
.
assertTrue
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertTrue
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
# one is good
# one is good
software_instance2
.
edit
(
predecessor
=
None
)
software_instance2
.
edit
(
predecessor
=
None
)
self
.
tic
()
self
.
tic
()
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
self
.
getMessageList
(
self
.
software_instance
))
# none is good
# none is good
software_instance3
.
edit
(
predecessor
=
None
)
software_instance3
.
edit
(
predecessor
=
None
)
self
.
tic
()
self
.
tic
()
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
self
.
getMessageList
(
self
.
software_instance
))
class
TestSlapOSHostingSubscriptionConstraint
(
TestSlapOSConstraintMixin
):
class
TestSlapOSHostingSubscriptionConstraint
(
TestSlapOSConstraintMixin
):
def
afterSetUp
(
self
):
def
afterSetUp
(
self
):
...
@@ -340,12 +347,12 @@ class TestSlapOSHostingSubscriptionConstraint(TestSlapOSConstraintMixin):
...
@@ -340,12 +347,12 @@ class TestSlapOSHostingSubscriptionConstraint(TestSlapOSConstraintMixin):
transaction
.
abort
()
transaction
.
abort
()
def
test_property_existence_reference
(
self
):
def
test_property_existence_reference
(
self
):
self
.
_test_property_existence
(
'reference'
,
self
.
_test_property_existence
(
self
.
software_instance
,
'reference'
,
'Property existence error for property reference, this document'
'Property existence error for property reference, this document'
' has no such property or the property has never been set'
)
' has no such property or the property has never been set'
)
def
test_property_existence_title
(
self
):
def
test_property_existence_title
(
self
):
self
.
_test_property_existence
(
'title'
,
self
.
_test_property_existence
(
self
.
software_instance
,
'title'
,
'Property existence error for property title, this document'
'Property existence error for property title, this document'
' has no such property or the property has never been set'
)
' has no such property or the property has never been set'
)
...
@@ -356,14 +363,15 @@ class TestSlapOSHostingSubscriptionConstraint(TestSlapOSConstraintMixin):
...
@@ -356,14 +363,15 @@ class TestSlapOSHostingSubscriptionConstraint(TestSlapOSConstraintMixin):
'has never been set'
'has never been set'
# not required in draft state
# not required in draft state
self
.
software_instance
.
edit
(
**
{
property_id
:
None
})
self
.
software_instance
.
edit
(
**
{
property_id
:
None
})
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
software_instance
.
edit
(
**
{
property_id
:
''
})
self
.
software_instance
.
edit
(
**
{
property_id
:
''
})
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
'start_requested'
)
'start_requested'
)
self
.
_test_property_existence
(
property_id
,
consistency_message
)
self
.
_test_property_existence
(
self
.
software_instance
,
property_id
,
consistency_message
)
def
test_property_existence_root_slave
(
self
):
def
test_property_existence_root_slave
(
self
):
property_id
=
'root_slave'
property_id
=
'root_slave'
...
@@ -372,14 +380,15 @@ class TestSlapOSHostingSubscriptionConstraint(TestSlapOSConstraintMixin):
...
@@ -372,14 +380,15 @@ class TestSlapOSHostingSubscriptionConstraint(TestSlapOSConstraintMixin):
'has never been set'
'has never been set'
# not required in draft state
# not required in draft state
self
.
software_instance
.
edit
(
**
{
property_id
:
None
})
self
.
software_instance
.
edit
(
**
{
property_id
:
None
})
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
software_instance
.
edit
(
**
{
property_id
:
''
})
self
.
software_instance
.
edit
(
**
{
property_id
:
''
})
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
'start_requested'
)
'start_requested'
)
self
.
_test_property_existence
(
property_id
,
consistency_message
,
value
=
True
)
self
.
_test_property_existence
(
self
.
software_instance
,
property_id
,
consistency_message
,
value
=
True
)
def
test_property_existence_url_string
(
self
):
def
test_property_existence_url_string
(
self
):
property_id
=
'url_string'
property_id
=
'url_string'
...
@@ -388,31 +397,32 @@ class TestSlapOSHostingSubscriptionConstraint(TestSlapOSConstraintMixin):
...
@@ -388,31 +397,32 @@ class TestSlapOSHostingSubscriptionConstraint(TestSlapOSConstraintMixin):
'has never been set'
'has never been set'
# not required in draft state
# not required in draft state
self
.
software_instance
.
edit
(
**
{
property_id
:
None
})
self
.
software_instance
.
edit
(
**
{
property_id
:
None
})
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
software_instance
.
edit
(
**
{
property_id
:
''
})
self
.
software_instance
.
edit
(
**
{
property_id
:
''
})
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
self
.
software_instance
))
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
'start_requested'
)
'start_requested'
)
self
.
_test_property_existence
(
property_id
,
consistency_message
)
self
.
_test_property_existence
(
self
.
software_instance
,
property_id
,
consistency_message
)
class
TestSlapOSPersonConstraint
(
testSlapOS
Mixin
):
class
TestSlapOSPersonConstraint
(
TestSlapOSConstraint
Mixin
):
def
test_role
(
self
):
def
test_role
(
self
):
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
)
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
)
consistency_message
=
'One role should be defined'
consistency_message
=
'One role should be defined'
self
.
assertTrue
(
consistency_message
in
getMessageList
(
person
))
self
.
assertTrue
(
consistency_message
in
self
.
getMessageList
(
person
))
role_id_list
=
list
(
self
.
portal
.
portal_categories
.
role
.
objectIds
())
role_id_list
=
list
(
self
.
portal
.
portal_categories
.
role
.
objectIds
())
self
.
assertTrue
(
len
(
role_id_list
)
>=
2
)
self
.
assertTrue
(
len
(
role_id_list
)
>=
2
)
person
.
setRole
(
role_id_list
[
0
])
person
.
setRole
(
role_id_list
[
0
])
self
.
assertFalse
(
consistency_message
in
getMessageList
(
person
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
person
))
person
.
setRoleList
(
role_id_list
)
person
.
setRoleList
(
role_id_list
)
self
.
assertTrue
(
consistency_message
in
getMessageList
(
person
))
self
.
assertTrue
(
consistency_message
in
self
.
getMessageList
(
person
))
person
.
setRole
(
role_id_list
[
0
])
person
.
setRole
(
role_id_list
[
0
])
self
.
assertFalse
(
consistency_message
in
getMessageList
(
person
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
person
))
def
test_subordination_state
(
self
):
def
test_subordination_state
(
self
):
organisation
=
self
.
portal
.
organisation_module
.
newContent
(
organisation
=
self
.
portal
.
organisation_module
.
newContent
(
...
@@ -421,67 +431,67 @@ class TestSlapOSPersonConstraint(testSlapOSMixin):
...
@@ -421,67 +431,67 @@ class TestSlapOSPersonConstraint(testSlapOSMixin):
subordination
=
organisation
.
getRelativeUrl
())
subordination
=
organisation
.
getRelativeUrl
())
consistency_message
=
'The Organisation is not validated'
consistency_message
=
'The Organisation is not validated'
self
.
assertTrue
(
consistency_message
in
getMessageList
(
person
))
self
.
assertTrue
(
consistency_message
in
self
.
getMessageList
(
person
))
organisation
.
validate
()
organisation
.
validate
()
self
.
assertFalse
(
consistency_message
in
getMessageList
(
person
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
person
))
def
test_email
(
self
):
def
test_email
(
self
):
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
)
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
)
consistency_message
=
'Person have to contain an Email'
consistency_message
=
'Person have to contain an Email'
self
.
assertTrue
(
consistency_message
in
getMessageList
(
person
))
self
.
assertTrue
(
consistency_message
in
self
.
getMessageList
(
person
))
person
.
newContent
(
portal_type
=
'Email'
)
person
.
newContent
(
portal_type
=
'Email'
)
self
.
assertFalse
(
consistency_message
in
getMessageList
(
person
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
person
))
class
TestSlapOSAssignmentConstraint
(
testSlapOS
Mixin
):
class
TestSlapOSAssignmentConstraint
(
TestSlapOSConstraint
Mixin
):
def
test_parent_person_validated
(
self
):
def
test_parent_person_validated
(
self
):
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
)
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
)
assignment
=
person
.
newContent
(
portal_type
=
'Assignment'
)
assignment
=
person
.
newContent
(
portal_type
=
'Assignment'
)
consistency_message
=
'The person document has to be validated to start '
\
consistency_message
=
'The person document has to be validated to start '
\
'assignment'
'assignment'
self
.
assertTrue
(
consistency_message
in
getMessageList
(
assignment
))
self
.
assertTrue
(
consistency_message
in
self
.
getMessageList
(
assignment
))
person
.
validate
()
person
.
validate
()
self
.
assertFalse
(
consistency_message
in
getMessageList
(
assignment
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
assignment
))
class
TestSlapOSEmailConstraint
(
testSlapOS
Mixin
):
class
TestSlapOSEmailConstraint
(
TestSlapOSConstraint
Mixin
):
def
test_url_string_not_empty
(
self
):
def
test_url_string_not_empty
(
self
):
email
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
email
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
).
newContent
(
portal_type
=
'Email'
)
).
newContent
(
portal_type
=
'Email'
)
consistency_message
=
'Email must be defined'
consistency_message
=
'Email must be defined'
self
.
assertTrue
(
consistency_message
in
getMessageList
(
email
))
self
.
assertTrue
(
consistency_message
in
self
.
getMessageList
(
email
))
email
.
setUrlString
(
self
.
generateNewId
())
email
.
setUrlString
(
self
.
generateNewId
())
self
.
assertFalse
(
consistency_message
in
getMessageList
(
email
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
email
))
class
TestSlapOSComputerConstraint
(
testSlapOS
Mixin
):
class
TestSlapOSComputerConstraint
(
TestSlapOSConstraint
Mixin
):
def
test_title_not_empty
(
self
):
def
test_title_not_empty
(
self
):
computer
=
self
.
portal
.
computer_module
.
newContent
(
portal_type
=
'Computer'
)
computer
=
self
.
portal
.
computer_module
.
newContent
(
portal_type
=
'Computer'
)
consistency_message
=
'Title must be defined'
consistency_message
=
'Title must be defined'
self
.
assertTrue
(
consistency_message
in
getMessageList
(
computer
))
self
.
assertTrue
(
consistency_message
in
self
.
getMessageList
(
computer
))
computer
.
setTitle
(
self
.
generateNewId
())
computer
.
setTitle
(
self
.
generateNewId
())
self
.
assertFalse
(
consistency_message
in
getMessageList
(
computer
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
computer
))
def
test_reference_not_empty
(
self
):
def
test_reference_not_empty
(
self
):
computer
=
self
.
portal
.
computer_module
.
newContent
(
portal_type
=
'Computer'
)
computer
=
self
.
portal
.
computer_module
.
newContent
(
portal_type
=
'Computer'
)
consistency_message
=
'Reference must be defined'
consistency_message
=
'Reference must be defined'
self
.
assertTrue
(
consistency_message
in
getMessageList
(
computer
))
self
.
assertTrue
(
consistency_message
in
self
.
getMessageList
(
computer
))
computer
.
setReference
(
self
.
generateNewId
())
computer
.
setReference
(
self
.
generateNewId
())
self
.
assertFalse
(
consistency_message
in
getMessageList
(
computer
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
computer
))
def
test_reference_unique
(
self
):
def
test_reference_unique
(
self
):
reference
=
self
.
generateNewId
()
reference
=
self
.
generateNewId
()
...
@@ -494,11 +504,11 @@ class TestSlapOSComputerConstraint(testSlapOSMixin):
...
@@ -494,11 +504,11 @@ class TestSlapOSComputerConstraint(testSlapOSMixin):
self
.
tic
()
self
.
tic
()
self
.
assertTrue
(
consistency_message
in
getMessageList
(
computer
))
self
.
assertTrue
(
consistency_message
in
self
.
getMessageList
(
computer
))
self
.
assertTrue
(
consistency_message
in
getMessageList
(
computer_2
))
self
.
assertTrue
(
consistency_message
in
self
.
getMessageList
(
computer_2
))
computer_2
.
setReference
(
reference_2
)
computer_2
.
setReference
(
reference_2
)
self
.
tic
()
self
.
tic
()
self
.
assertFalse
(
consistency_message
in
getMessageList
(
computer
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
computer
))
self
.
assertFalse
(
consistency_message
in
getMessageList
(
computer_2
))
self
.
assertFalse
(
consistency_message
in
self
.
getMessageList
(
computer_2
))
master/bt5/slapos_cloud/bt/revision
View file @
3f239154
238
239
\ No newline at end of file
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment