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
Titouan Soulard
slapos.core
Commits
a13adb62
Commit
a13adb62
authored
Nov 24, 2017
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_cloud: Update tests for module id generator settings
This test aims to test the constraints
parent
f054122a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
173 deletions
+100
-173
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
...eItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
+0
-172
master/bt5/slapos_configurator/TestTemplateItem/portal_components/test.erp5.testSlapOSConfigurator.py
...tem/portal_components/test.erp5.testSlapOSConfigurator.py
+100
-1
No files found.
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
View file @
a13adb62
...
...
@@ -11,178 +11,6 @@ from DateTime import DateTime
from
Products.ERP5Type.DateUtils
import
addToDate
from
App.Common
import
rfc1123_date
class
TestSlapOSCorePromiseSlapOSModuleIdGeneratorAlarm
(
testSlapOSMixin
):
def
generateNewId
(
self
):
return
self
.
portal
.
portal_ids
.
generateNewId
(
id_group
=
(
'slapos_core_test'
))
def
test_Module_assertIdGenerator
(
self
):
module
=
self
.
portal
.
newContent
(
portal_type
=
'Person Module'
,
id
=
str
(
self
.
generateNewId
()),
id_generator
=
'bad_id_generator'
)
self
.
assertEqual
(
'bad_id_generator'
,
module
.
getIdGenerator
())
# check positive response
self
.
assertTrue
(
module
.
Module_assertIdGenerator
(
'bad_id_generator'
,
False
))
self
.
assertEqual
(
'bad_id_generator'
,
module
.
getIdGenerator
())
self
.
assertTrue
(
module
.
Module_assertIdGenerator
(
'bad_id_generator'
,
True
))
self
.
assertEqual
(
'bad_id_generator'
,
module
.
getIdGenerator
())
# check negative response and that no-op run does not modify
self
.
assertFalse
(
module
.
Module_assertIdGenerator
(
'good_id_generator'
,
False
))
self
.
assertEqual
(
'bad_id_generator'
,
module
.
getIdGenerator
())
# check negative response with fixit request
self
.
assertFalse
(
module
.
Module_assertIdGenerator
(
'good_id_generator'
,
True
))
self
.
assertEqual
(
'good_id_generator'
,
module
.
getIdGenerator
())
self
.
assertTrue
(
module
.
Module_assertIdGenerator
(
'good_id_generator'
,
False
))
self
.
assertEqual
(
'good_id_generator'
,
module
.
getIdGenerator
())
transaction
.
abort
()
def
_simulateModule_assertIdGenerator
(
self
):
script_name
=
'Module_assertIdGenerator'
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
raise
ValueError
(
'Precondition failed: %s exists in custom'
%
script_name
)
createZODBPythonScript
(
self
.
portal
.
portal_skins
.
custom
,
script_name
,
'id_generator, fixit, active_process=None'
,
'# Script body
\
n
'
"""from Products.CMFActivity.ActiveResult import ActiveResult
active_result = ActiveResult()
active_result.edit(
summary='Module_assertIdGenerator simulation',
severity=0,
detail=context.getRelativeUrl())
active_process.postResult(active_result)
"""
)
transaction
.
commit
()
def
_dropModule_assertIdGenerator
(
self
):
script_name
=
'Module_assertIdGenerator'
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
self
.
portal
.
portal_skins
.
custom
.
manage_delObjects
(
script_name
)
transaction
.
commit
()
def
test_alarm
(
self
):
alarm
=
self
.
portal
.
portal_alarms
.
promise_slapos_module_id_generator
previous_active_process
=
self
.
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
'Active Process'
,
causality_uid
=
alarm
.
getUid
(),
sort_on
=
((
'creation_date'
,
'DESC'
),)
)
self
.
_simulateModule_assertIdGenerator
()
try
:
alarm
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropModule_assertIdGenerator
()
active_process
=
self
.
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
'Active Process'
,
causality_uid
=
alarm
.
getUid
(),
sort_on
=
((
'creation_date'
,
'DESC'
),)
)
self
.
assertNotEqual
(
previous_active_process
.
getPath
(),
active_process
.
getPath
())
visited_list
=
sorted
([
q
.
detail
for
q
in
active_process
.
getResultList
()
\
if
q
.
summary
==
'Module_assertIdGenerator simulation'
])
expected_list
=
sorted
([
'access_token_module'
,
'account_module'
,
'accounting_module'
,
'bug_module'
,
'business_configuration_module'
,
'business_process_module'
,
'campaign_module'
,
'component_module'
,
'computer_model_module'
,
'computer_module'
,
'computer_network_module'
,
'consumption_document_module'
,
'credential_recovery_module'
,
'credential_request_module'
,
'credential_update_module'
,
'currency_module'
,
'cloud_contract_module'
,
'data_set_module'
,
'delivery_node_module'
,
'document_ingestion_module'
,
'document_module'
,
'event_module'
,
'external_source_module'
,
'glossary_module'
,
'hosting_subscription_module'
,
'image_module'
,
'implicit_item_movement_module'
,
'internal_order_module'
,
'internal_packing_list_module'
,
'internal_supply_module'
,
'internal_trade_condition_module'
,
'inventory_module'
,
'item_module'
,
'knowledge_pad_module'
,
'meeting_module'
,
'notification_message_module'
,
'open_internal_order_module'
,
'open_purchase_order_module'
,
'open_sale_order_module'
,
'organisation_module'
,
'person_module'
,
'portal_activities'
,
'portal_simulation'
,
'product_module'
,
'project_module'
,
'purchase_order_module'
,
'purchase_packing_list_module'
,
'purchase_supply_module'
,
'purchase_trade_condition_module'
,
'quantity_unit_conversion_module'
,
'query_module'
,
'regularisation_request_module'
,
'requirement_module'
,
'returned_purchase_order_module'
,
'returned_purchase_packing_list_module'
,
'returned_sale_order_module'
,
'returned_sale_packing_list_module'
,
'sale_opportunity_module'
,
'sale_order_module'
,
'sale_packing_list_module'
,
'sale_supply_module'
,
'sale_trade_condition_module'
,
'service_module'
,
'service_report_module'
,
'software_installation_module'
,
'software_instance_module'
,
'software_licence_module'
,
'software_product_module'
,
'software_publication_module'
,
'software_release_module'
,
'support_request_module'
,
'system_event_module'
,
'task_module'
,
'task_report_module'
,
'transformation_module'
,
'trial_request_module'
,
'upgrade_decision_module'
,
'web_page_module'
,
'web_site_module'
,
'workflow_module'
,
])
diff
=
lambda
l1
,
l2
:
[
x
for
x
in
l1
if
x
not
in
l2
]
result
=
""
for
x
in
diff
(
expected_list
,
visited_list
):
result
+=
"- %s
\
n
"
%
x
for
x
in
diff
(
visited_list
,
expected_list
):
result
+=
"+ %s
\
n
"
%
x
self
.
assertSameSet
(
expected_list
,
visited_list
,
result
)
class
TestSlapOSAllocation
(
testSlapOSMixin
):
def
_makeSlaveTree
(
self
,
requested_template_id
=
'template_slave_instance'
):
...
...
master/bt5/slapos_configurator/TestTemplateItem/portal_components/test.erp5.testSlapOSConfigurator.py
View file @
a13adb62
...
...
@@ -16,6 +16,14 @@ class TestSlapOSConfigurator(testSlapOSMixin):
case we trust on promise outcome."""
self
.
assertEquals
(
self
.
portal
.
portal_ids
.
checkConsistency
(),
[])
self
.
portal
.
person_module
.
setIdGenerator
(
"_Id_fake"
)
self
.
assertNotEquals
(
self
.
portal
.
portal_ids
.
checkConsistency
(),
[])
self
.
portal
.
portal_ids
.
fixConsistency
()
self
.
assertEquals
(
self
.
portal
.
portal_ids
.
checkConsistency
(),
[])
self
.
assertEquals
(
self
.
portal
.
person_module
.
getIdGenerator
(),
"_generatePerDayId"
)
def
testConfiguredShacacheWebSite
(
self
):
""" Make sure Shacache WebSite is setuped by Alarm
case we trust on promise outcome."""
...
...
@@ -110,6 +118,97 @@ class TestSlapOSConfigurator(testSlapOSMixin):
self
.
assertEquals
(
os
.
environ
[
'TEST_CA_PATH'
],
self
.
portal
.
portal_certificate_authority
.
certificate_authority_path
)
def
testModuleHasIdGeneratorByDay
(
self
):
""" Ensure the Constraint sets appropriate id generator on all modules.
"""
module_list
=
[
module
.
getId
()
for
module
in
self
.
portal
.
objectValues
()
if
getattr
(
module
,
"getIdGenerator"
,
None
)
is
not
None
and
\
module
.
getIdGenerator
()
==
"_generatePerDayId"
]
self
.
assertSameSet
(
module_list
,
[
'access_token_module'
,
'account_module'
,
'accounting_module'
,
'bug_module'
,
'business_configuration_module'
,
'business_process_module'
,
'campaign_module'
,
'component_module'
,
'computer_model_module'
,
'computer_module'
,
'computer_network_module'
,
'consumption_document_module'
,
'credential_recovery_module'
,
'credential_request_module'
,
'credential_update_module'
,
'currency_module'
,
'cloud_contract_module'
,
'data_set_module'
,
'delivery_node_module'
,
'document_ingestion_module'
,
'document_module'
,
'event_module'
,
'external_source_module'
,
'glossary_module'
,
'hosting_subscription_module'
,
'image_module'
,
'implicit_item_movement_module'
,
'internal_order_module'
,
'internal_packing_list_module'
,
'internal_supply_module'
,
'internal_trade_condition_module'
,
'inventory_module'
,
'item_module'
,
'knowledge_pad_module'
,
'meeting_module'
,
'notification_message_module'
,
'open_internal_order_module'
,
'open_purchase_order_module'
,
'open_sale_order_module'
,
'organisation_module'
,
'person_module'
,
'portal_activities'
,
'portal_simulation'
,
'product_module'
,
'project_module'
,
'purchase_order_module'
,
'purchase_packing_list_module'
,
'purchase_supply_module'
,
'purchase_trade_condition_module'
,
'quantity_unit_conversion_module'
,
'query_module'
,
'regularisation_request_module'
,
'requirement_module'
,
'returned_purchase_order_module'
,
'returned_purchase_packing_list_module'
,
'returned_sale_order_module'
,
'returned_sale_packing_list_module'
,
'sale_opportunity_module'
,
'sale_order_module'
,
'sale_packing_list_module'
,
'sale_supply_module'
,
'sale_trade_condition_module'
,
'service_module'
,
'service_report_module'
,
'software_installation_module'
,
'software_instance_module'
,
'software_licence_module'
,
'software_product_module'
,
'software_publication_module'
,
'software_release_module'
,
'support_request_module'
,
'system_event_module'
,
'task_module'
,
'task_report_module'
,
'transformation_module'
,
'trial_request_module'
,
'upgrade_decision_module'
,
'web_page_module'
,
'web_site_module'
,
'workflow_module'
,
])
def
testConfiguredBusinessTemplateList
(
self
):
""" Make sure Installed business Templates are
what it is expected. """
...
...
@@ -183,7 +282,7 @@ class TestSlapOSConfigurator(testSlapOSMixin):
'erp5_web_renderjs_ui'
,
'erp5_web_service'
,
'slapos_ecoallocation'
,
'slapos_jio'
,
'slapos_jio'
,
'slapos_l10n_zh'
,
'slapos_trial_request'
,
'erp5_bearer_token'
,
...
...
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