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
c5aafba4
Commit
c5aafba4
authored
Aug 02, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_accounting: test: update titles
parent
f50b8385
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
108 additions
and
99 deletions
+108
-99
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingAlarm.py
.../portal_components/test.erp5.testSlapOSAccountingAlarm.py
+108
-99
No files found.
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingAlarm.py
View file @
c5aafba4
...
...
@@ -29,7 +29,8 @@
import
transaction
from
functools
import
wraps
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
from
erp5.component.test.SlapOSTestCaseMixin
import
SlapOSTestCaseMixin
,
withAbort
from
erp5.component.test.SlapOSTestCaseMixin
import
SlapOSTestCaseMixin
,
withAbort
,
TemporaryAlarmScript
import
os
import
tempfile
...
...
@@ -106,25 +107,26 @@ if context.getTitle() == 'Not visited by %s':
class
TestSlapOSTriggerBuildAlarm
(
SlapOSTestCaseMixin
):
@
simulateByTitlewMark
(
'SimulationMovement_buildSlapOS'
)
def
test_SimulationMovement_withoutDelivery
(
self
):
#################################################################
# slapos_trigger_build
#################################################################
def
test_SimulationMovement_buildSlapOS_alarm_withoutDelivery
(
self
):
applied_rule
=
self
.
portal
.
portal_simulation
.
newContent
(
portal_type
=
'Applied Rule'
)
simulation_movement
=
applied_rule
.
newContent
(
portal_type
=
'Simulation Movement'
,
ledger
=
'automated'
,
title
=
'Not visited by SimulationMovement_buildSlapOS'
)
self
.
tic
()
self
.
portal
.
portal_alarms
.
slapos_trigger_build
.
activeSense
()
self
.
tic
()
self
.
assertEqual
(
'Visited by SimulationMovement_buildSlapOS'
,
simulation_movement
.
getTitle
()
)
with
TemporaryAlarmScript
(
self
.
portal
,
'SimulationMovement_buildSlapOS'
,
"''"
,
attribute
=
'title'
):
self
.
tic
()
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_trigger_build
,
simulation_movement
,
'SimulationMovement_buildSlapOS'
,
attribute
=
'title'
)
@
simulateByTitlewMark
(
'SimulationMovement_buildSlapOS'
)
def
test_SimulationMovement_withDelivery
(
self
):
def
test_SimulationMovement_buildSlapOS_alarm_withDelivery
(
self
):
delivery
=
self
.
portal
.
sale_packing_list_module
.
newContent
(
portal_type
=
'Sale Packing List'
)
delivery_line
=
delivery
.
newContent
(
portal_type
=
'Sale Packing List Line'
)
...
...
@@ -134,18 +136,21 @@ class TestSlapOSTriggerBuildAlarm(SlapOSTestCaseMixin):
portal_type
=
'Simulation Movement'
,
ledger
=
'automated'
,
delivery
=
delivery_line
.
getRelativeUrl
(),
title
=
'
Shall be
visited by SimulationMovement_buildSlapOS'
)
self
.
tic
()
self
.
portal
.
portal_alarms
.
slapos_trigger_build
.
activeSense
()
self
.
tic
()
self
.
assertNotEqual
(
'Not visited by SimulationMovement_buildSlapOS'
,
simulation_movement
.
getTitle
()
)
title
=
'
Not
visited by SimulationMovement_buildSlapOS'
)
with
TemporaryAlarmScript
(
self
.
portal
,
'SimulationMovement_buildSlapOS'
,
"''"
,
attribute
=
'title'
):
self
.
tic
()
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_trigger_build
,
simulation_movement
,
'SimulationMovement_buildSlapOS'
,
attribute
=
'title'
)
#################################################################
# SimulationMovement_buildSlapOS
#################################################################
@
withAbort
def
test_SimulationMovement_buildSlapOS
(
self
):
def
test_SimulationMovement_buildSlapOS
_script_withoutDelivery
(
self
):
build_simulator
=
tempfile
.
mkstemp
()[
1
]
activate_simulator
=
tempfile
.
mkstemp
()[
1
]
...
...
@@ -238,7 +243,7 @@ class TestSlapOSTriggerBuildAlarm(SlapOSTestCaseMixin):
os
.
unlink
(
activate_simulator
)
@
withAbort
def
test_SimulationMovement_buildSlapOS_withDelivery
(
self
):
def
test_SimulationMovement_buildSlapOS_
script_
withDelivery
(
self
):
build_simulator
=
tempfile
.
mkstemp
()[
1
]
activate_simulator
=
tempfile
.
mkstemp
()[
1
]
...
...
@@ -304,33 +309,39 @@ class TestSlapOSTriggerBuildAlarm(SlapOSTestCaseMixin):
os
.
unlink
(
activate_simulator
)
class
TestSlapOSManageBuildingCalculatingDeliveryAlarm
(
SlapOSTestCaseMixin
):
@
simulateByTitlewMark
(
'Delivery_manageBuildingCalculatingDelivery'
)
def
_test
(
self
,
state
,
message
):
#################################################################
# slapos_manage_building_calculating_delivery
#################################################################
def
_test
(
self
,
state
,
test_function
):
delivery
=
self
.
portal
.
sale_packing_list_module
.
newContent
(
title
=
'Not visited by Delivery_manageBuildingCalculatingDelivery'
,
ledger
=
'automated'
,
portal_type
=
'Sale Packing List'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
delivery
,
state
)
self
.
tic
()
self
.
portal
.
portal_alarms
.
slapos_manage_building_calculating_delivery
\
.
activeSense
()
self
.
tic
()
self
.
assertEqual
(
message
,
delivery
.
getTitle
())
with
TemporaryAlarmScript
(
self
.
portal
,
'Delivery_manageBuildingCalculatingDelivery'
,
"''"
,
attribute
=
'title'
):
self
.
tic
()
test_function
(
self
.
portal
.
portal_alarms
.
slapos_manage_building_calculating_delivery
,
delivery
,
'Delivery_manageBuildingCalculatingDelivery'
,
attribute
=
'title'
)
def
test_building
(
self
):
self
.
_test
(
'building'
,
'Visited by Delivery_manageBuildingCalculatingDelivery'
)
def
test_
Delivery_manageBuildingCalculatingDelivery_alarm_
building
(
self
):
self
.
_test
(
'building'
,
self
.
_test_alarm
)
def
test_calculating
(
self
):
self
.
_test
(
'calculating'
,
'Visited by Delivery_manageBuildingCalculatingDelivery'
)
def
test_
Delivery_manageBuildingCalculatingDelivery_alarm_
calculating
(
self
):
self
.
_test
(
'calculating'
,
self
.
_test_alarm
)
def
test_diverged
(
self
):
self
.
_test
(
'diverged'
,
'Not visited by Delivery_manageBuildingCalculatingDelivery'
)
def
test_
Delivery_manageBuildingCalculatingDelivery_alarm_
diverged
(
self
):
self
.
_test
(
'diverged'
,
self
.
_test_alarm_not_visited
)
def
test_solved
(
self
):
self
.
_test
(
'solved'
,
'Not visited by Delivery_manageBuildingCalculatingDelivery'
)
def
test_
Delivery_manageBuildingCalculatingDelivery_alarm_
solved
(
self
):
self
.
_test
(
'solved'
,
self
.
_test_alarm_not_visited
)
#################################################################
# Delivery_manageBuildingCalculatingDelivery
#################################################################
@
withAbort
def
_test_Delivery_manageBuildingCalculatingDelivery
(
self
,
state
,
empty
=
False
):
updateCausalityState_simulator
=
tempfile
.
mkstemp
()[
1
]
...
...
@@ -381,19 +392,28 @@ class TestSlapOSManageBuildingCalculatingDeliveryAlarm(SlapOSTestCaseMixin):
if
os
.
path
.
exists
(
updateSimulation_simulator
):
os
.
unlink
(
updateSimulation_simulator
)
def
test_Delivery_manageBuildingCalculatingDelivery_calculating
(
self
):
def
test_Delivery_manageBuildingCalculatingDelivery_
script_
calculating
(
self
):
self
.
_test_Delivery_manageBuildingCalculatingDelivery
(
'calculating'
)
def
test_Delivery_manageBuildingCalculatingDelivery_building
(
self
):
def
test_Delivery_manageBuildingCalculatingDelivery_
script_
building
(
self
):
self
.
_test_Delivery_manageBuildingCalculatingDelivery
(
'building'
)
def
test_Delivery_manageBuildingCalculatingDelivery_solved
(
self
):
def
test_Delivery_manageBuildingCalculatingDelivery_s
cript_s
olved
(
self
):
self
.
_test_Delivery_manageBuildingCalculatingDelivery
(
'solved'
,
True
)
def
test_Delivery_manageBuildingCalculatingDelivery_diverged
(
self
):
def
test_Delivery_manageBuildingCalculatingDelivery_
script_
diverged
(
self
):
self
.
_test_Delivery_manageBuildingCalculatingDelivery
(
'diverged'
,
True
)
class
TestSlapOSConfirmedDeliveryMixin
:
class
TestSlapOSStopConfirmedAggregatedSaleInvoiceTransactionAlarm
(
SlapOSTestCaseMixin
):
destination_state
=
'stopped'
script
=
'Delivery_stopConfirmedAggregatedSaleInvoiceTransaction'
portal_type
=
'Sale Invoice Transaction'
alarm
=
'slapos_stop_confirmed_aggregated_sale_invoice_transaction'
#################################################################
# slapos_stop_confirmed_aggregated_sale_invoice_transaction
#################################################################
def
_test
(
self
,
simulation_state
,
causality_state
,
ledger
,
positive
,
delivery_date
=
DateTime
(
'2012/04/22'
),
accounting_date
=
DateTime
(
'2012/04/28'
)):
...
...
@@ -423,21 +443,24 @@ class TestSlapOSConfirmedDeliveryMixin:
_real
(
self
,
simulation_state
,
causality_state
,
ledger
,
positive
,
delivery_date
,
accounting_date
)
def
test_typical
(
self
):
def
test_
Delivery_stopConfirmedAggregatedSaleInvoiceTransaction_alarm_
typical
(
self
):
self
.
_test
(
'confirmed'
,
'solved'
,
'automated'
,
True
)
def
test_bad_ledger
(
self
):
def
test_
Delivery_stopConfirmedAggregatedSaleInvoiceTransaction_alarm_
bad_ledger
(
self
):
self
.
_test
(
'confirmed'
,
'solved'
,
None
,
False
)
def
test_bad_simulation_state
(
self
):
def
test_
Delivery_stopConfirmedAggregatedSaleInvoiceTransaction_alarm_
bad_simulation_state
(
self
):
self
.
_test
(
'started'
,
'solved'
,
'automated'
,
False
)
def
test_bad_causality_state
(
self
):
def
test_
Delivery_stopConfirmedAggregatedSaleInvoiceTransaction_alarm_
bad_causality_state
(
self
):
self
.
_test
(
'confirmed'
,
'calculating'
,
'automated'
,
False
)
#################################################################
# Delivery_stopConfirmedAggregatedSaleInvoiceTransaction
#################################################################
@
withAbort
def
_test_script
(
self
,
simulation_state
,
causality_state
,
ledger
,
destination_state
,
consistency_failure
=
False
):
...
...
@@ -463,40 +486,34 @@ class TestSlapOSConfirmedDeliveryMixin:
delattr
(
Folder
,
'original_checkConsistency'
)
self
.
assertEqual
(
destination_state
,
delivery
.
getSimulationState
())
def
test_script_typical
(
self
):
def
test_
Delivery_stopConfirmedAggregatedSaleInvoiceTransaction_
script_typical
(
self
):
self
.
_test_script
(
'confirmed'
,
'solved'
,
'automated'
,
self
.
destination_state
)
def
test_script_bad_ledger
(
self
):
def
test_
Delivery_stopConfirmedAggregatedSaleInvoiceTransaction_
script_bad_ledger
(
self
):
self
.
_test_script
(
'confirmed'
,
'solved'
,
None
,
'confirmed'
)
def
test_script_bad_simulation_state
(
self
):
def
test_
Delivery_stopConfirmedAggregatedSaleInvoiceTransaction_
script_bad_simulation_state
(
self
):
self
.
_test_script
(
'started'
,
'solved'
,
'automated'
,
'started'
)
def
test_script_bad_causality_state
(
self
):
def
test_
Delivery_stopConfirmedAggregatedSaleInvoiceTransaction_
script_bad_causality_state
(
self
):
self
.
_test_script
(
'confirmed'
,
'building'
,
'automated'
,
'confirmed'
)
def
test_script_bad_consistency
(
self
):
def
test_
Delivery_stopConfirmedAggregatedSaleInvoiceTransaction_
script_bad_consistency
(
self
):
self
.
_test_script
(
'confirmed'
,
'solved'
,
'automated'
,
'confirmed'
,
True
)
class
TestSlapOSStopConfirmedAggregatedSaleInvoiceTransactionAlarm
(
SlapOSTestCaseMixin
,
TestSlapOSConfirmedDeliveryMixin
):
destination_state
=
'stopped'
script
=
'Delivery_stopConfirmedAggregatedSaleInvoiceTransaction'
portal_type
=
'Sale Invoice Transaction'
alarm
=
'slapos_stop_confirmed_aggregated_sale_invoice_transaction'
class
TestSlapOSGeneratePackingListFromTioXML
(
SlapOSTestCaseMixin
):
#################################################################
# slapos_accounting_generate_packing_list_from_tioxml
#################################################################
def
createTioXMLFile
(
self
):
document
=
self
.
portal
.
consumption_document_module
.
newContent
(
title
=
self
.
generateNewId
(),
...
...
@@ -504,7 +521,7 @@ class TestSlapOSGeneratePackingListFromTioXML(SlapOSTestCaseMixin):
)
return
document
def
test_alarm
(
self
):
def
test_
ComputerConsumptionTioXMLFile_solveInvoicingGeneration_
alarm
(
self
):
document
=
self
.
createTioXMLFile
()
document
.
submit
()
self
.
tic
()
...
...
@@ -515,7 +532,7 @@ class TestSlapOSGeneratePackingListFromTioXML(SlapOSTestCaseMixin):
self
.
_test_alarm
(
alarm
,
document
,
script_name
)
def
test_alarm_not_submitted
(
self
):
def
test_
ComputerConsumptionTioXMLFile_solveInvoicingGeneration_
alarm_not_submitted
(
self
):
document
=
self
.
createTioXMLFile
()
self
.
tic
()
...
...
@@ -527,7 +544,9 @@ class TestSlapOSGeneratePackingListFromTioXML(SlapOSTestCaseMixin):
class
TestSlapOSCancelSaleTnvoiceTransactionPaiedPaymentListAlarm
(
SlapOSTestCaseMixin
):
#################################################################
# slapos_cancel_sale_invoice_transaction_paied_payment_list
#################################################################
def
_test_payment_is_draft
(
self
,
payment_mode
):
new_id
=
self
.
generateNewId
()
payment_transaction
=
self
.
portal
.
accounting_module
.
newContent
(
...
...
@@ -538,19 +557,16 @@ class TestSlapOSCancelSaleTnvoiceTransactionPaiedPaymentListAlarm(SlapOSTestCase
)
self
.
tic
()
self
.
portal
.
portal_alarms
.
slapos_cancel_sale_invoice_transaction_paied_payment_list
.
activeSense
()
self
.
tic
()
self
.
assertNotEqual
(
'Not visited by PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered'
,
payment_transaction
.
getTitle
())
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_cancel_sale_invoice_transaction_paied_payment_list
,
payment_transaction
,
"PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered"
)
@
simulateByTitlewMark
(
'PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered'
)
def
test_payment_is_draft_payzen
(
self
):
def
test_PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered_alarm_isDraftPayzen
(
self
):
self
.
_test_payment_is_draft
(
payment_mode
=
"payzen"
)
@
simulateByTitlewMark
(
'PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered'
)
def
test_payment_is_draft_wechat
(
self
):
def
test_PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered_alarm_isDraftWeChat
(
self
):
self
.
_test_payment_is_draft
(
payment_mode
=
"wechat"
)
def
_test_payment_is_stopped
(
self
,
payment_mode
):
...
...
@@ -567,22 +583,18 @@ class TestSlapOSCancelSaleTnvoiceTransactionPaiedPaymentListAlarm(SlapOSTestCase
payment_transaction
.
stop
()
self
.
tic
()
self
.
portal
.
portal_alarms
.
slapos_cancel_sale_invoice_transaction_paied_payment_list
.
activeSense
()
self
.
tic
()
self
.
assertNotEqual
(
'Not visited by PaymentTransaction_cancelIfSaleInvoiceTransactionisLettered'
,
payment_transaction
.
getTitle
())
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_cancel_sale_invoice_transaction_paied_payment_list
,
payment_transaction
,
"PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered"
)
@
simulateByTitlewMark
(
'PaymentTransaction_cancelIfSaleInvoiceTransactionisLettered'
)
def
test_payment_is_stopped_payzen
(
self
):
def
test_PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered_alarm_isStoppedPayzen
(
self
):
self
.
_test_payment_is_stopped
(
payment_mode
=
"payzen"
)
@
simulateByTitlewMark
(
'PaymentTransaction_cancelIfSaleInvoiceTransactionisLettered'
)
def
test_payment_is_stopped_wechat
(
self
):
def
test_PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered_alarm_isStoppedWechat
(
self
):
self
.
_test_payment_is_stopped
(
payment_mode
=
"wechat"
)
def
_test_payment_is_started
(
self
,
payment_mode
):
new_id
=
self
.
generateNewId
()
payment_transaction
=
self
.
portal
.
accounting_module
.
newContent
(
...
...
@@ -596,17 +608,14 @@ class TestSlapOSCancelSaleTnvoiceTransactionPaiedPaymentListAlarm(SlapOSTestCase
payment_transaction
.
start
()
self
.
tic
()
self
.
portal
.
portal_alarms
.
slapos_cancel_sale_invoice_transaction_paied_payment_list
.
activeSense
()
self
.
tic
()
self
.
assertNotEqual
(
'Visited by PaymentTransaction_cancelIfSaleInvoiceTransactionisLettered'
,
payment_transaction
.
getTitle
())
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_cancel_sale_invoice_transaction_paied_payment_list
,
payment_transaction
,
"PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered"
)
@
simulateByTitlewMark
(
'PaymentTransaction_cancelIfSaleInvoiceTransactionisLettered'
)
def
test_payment_is_started_payzen
(
self
):
def
test_PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered_alarm_isStartedPayzen
(
self
):
self
.
_test_payment_is_started
(
payment_mode
=
"payzen"
)
@
simulateByTitlewMark
(
'PaymentTransaction_cancelIfSaleInvoiceTransactionisLettered'
)
def
test_payment_is_started_wechat
(
self
):
self
.
_test_payment_is_started
(
payment_mode
=
"wechat"
)
\ No newline at end of file
def
test_PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered_alarm_isStartedWechat
(
self
):
self
.
_test_payment_is_started
(
payment_mode
=
"wechat"
)
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