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
e609084b
Commit
e609084b
authored
Nov 06, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cover SlapOSHostingSubscriptionConstraint
parent
da350440
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
108 additions
and
4 deletions
+108
-4
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSCoreConstraint.py
...slapos_cloud/TestTemplateItem/testSlapOSCoreConstraint.py
+107
-3
master/bt5/slapos_cloud/bt/revision
master/bt5/slapos_cloud/bt/revision
+1
-1
No files found.
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSCoreConstraint.py
View file @
e609084b
...
...
@@ -12,8 +12,9 @@ def getMessageList(o):
return
[
str
(
q
.
getMessage
())
for
q
in
o
.
checkConsistency
()]
class
TestSlapOSConstraintMixin
(
testSlapOSMixin
):
def
_test_property_existence
(
self
,
property_id
,
consistency_message
):
self
.
software_instance
.
edit
(
**
{
property_id
:
'A'
})
def
_test_property_existence
(
self
,
property_id
,
consistency_message
,
value
=
'A'
):
self
.
software_instance
.
edit
(
**
{
property_id
:
value
})
# fetch basic list of consistency messages
current_message_list
=
getMessageList
(
self
.
software_instance
)
...
...
@@ -29,7 +30,7 @@ class TestSlapOSConstraintMixin(testSlapOSMixin):
self
.
software_instance
.
edit
(
**
{
property_id
:
''
})
self
.
assertTrue
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
software_instance
.
edit
(
**
{
property_id
:
'A'
})
self
.
software_instance
.
edit
(
**
{
property_id
:
value
})
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
getMessageList
(
self
.
software_instance
))
...
...
@@ -341,3 +342,106 @@ class TestSlapOSSlaveInstanceConstraint(TestSlapOSConstraintMixin):
def
test_setup_packing_list
(
self
):
raise
NotImplementedError
(
'It requires not migrated resources'
)
class
TestSlapOSHostingSubscriptionConstraint
(
TestSlapOSConstraintMixin
):
def
afterSetUp
(
self
):
self
.
software_instance
=
self
.
portal
.
hosting_subscription_module
.
newContent
(
portal_type
=
'Hosting Subscription'
)
def
beforeTearDown
(
self
):
transaction
.
abort
()
def
test_property_existence_reference
(
self
):
self
.
_test_property_existence
(
'reference'
,
'Property existence error for property reference, this document'
' has no such property or the property has never been set'
)
def
test_property_existence_title
(
self
):
self
.
_test_property_existence
(
'title'
,
'Property existence error for property title, this document'
' has no such property or the property has never been set'
)
def
test_property_existence_source_reference
(
self
):
property_id
=
'source_reference'
consistency_message
=
'Property existence error for property '
\
'source_reference, this document has no such property or the property '
\
'has never been set'
# not required in draft state
self
.
software_instance
.
edit
(
**
{
property_id
:
None
})
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
software_instance
.
edit
(
**
{
property_id
:
''
})
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
'start_requested'
)
self
.
_test_property_existence
(
property_id
,
consistency_message
)
def
test_property_existence_root_slave
(
self
):
property_id
=
'root_slave'
consistency_message
=
'Property existence error for property '
\
'root_slave, this document has no such property or the property '
\
'has never been set'
# not required in draft state
self
.
software_instance
.
edit
(
**
{
property_id
:
None
})
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
software_instance
.
edit
(
**
{
property_id
:
''
})
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
'start_requested'
)
self
.
_test_property_existence
(
property_id
,
consistency_message
,
value
=
True
)
def
test_property_existence_url_string
(
self
):
property_id
=
'url_string'
consistency_message
=
'Property existence error for property '
\
'url_string, this document has no such property or the property '
\
'has never been set'
# not required in draft state
self
.
software_instance
.
edit
(
**
{
property_id
:
None
})
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
software_instance
.
edit
(
**
{
property_id
:
''
})
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
'start_requested'
)
self
.
_test_property_existence
(
property_id
,
consistency_message
)
def
test_predecessor_related
(
self
):
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
'start_requested'
)
software_instance2
=
self
.
portal
.
software_instance_module
.
newContent
(
portal_type
=
'Software Instance'
)
software_instance3
=
self
.
portal
.
software_instance_module
.
newContent
(
portal_type
=
'Software Instance'
)
self
.
software_instance
.
setPredecessor
(
software_instance2
.
getRelativeUrl
())
# fetch basic list of consistency messages
current_message_list
=
getMessageList
(
self
.
software_instance
)
consistency_message
=
"Arity Error for Relation ['predecessor'], arity is "
\
"equal to 0 but should be at least 1"
# test the test: no expected message found
self
.
assertFalse
(
consistency_message
in
current_message_list
)
# 0 is bad
self
.
software_instance
.
setPredecessor
(
None
)
self
.
assertTrue
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
# Note: There is (nonsense) constraint
# SlaposHostingSubscriptionConstraint/predecessor_constraint which
# defines minimum as 0, thats why this test will fail
# one is good
self
.
software_instance
.
edit
(
predecessor
=
software_instance2
.
getRelativeUrl
())
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
getMessageList
(
self
.
software_instance
))
# more then one is good
self
.
software_instance
.
edit
(
predecessor_list
=
[
software_instance2
.
getRelativeUrl
(),
software_instance3
.
getRelativeUrl
()])
self
.
assertFalse
(
consistency_message
in
getMessageList
(
self
.
software_instance
))
self
.
assertSameSet
(
current_message_list
,
getMessageList
(
self
.
software_instance
))
master/bt5/slapos_cloud/bt/revision
View file @
e609084b
216
\ No newline at end of file
217
\ 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