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
de12f7d9
Commit
de12f7d9
authored
Feb 24, 2023
by
Romain Courteaud
🐸
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_accounting: testSlapOSAccountingAlarm: update test
parent
35e78a4b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
163 deletions
+21
-163
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingAlarm.py
.../portal_components/test.erp5.testSlapOSAccountingAlarm.py
+21
-163
No files found.
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingAlarm.py
View file @
de12f7d9
...
...
@@ -879,6 +879,7 @@ class TestSlapOSManageBuildingCalculatingDeliveryAlarm(SlapOSTestCaseMixin):
def
_test
(
self
,
state
,
message
):
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
()
...
...
@@ -964,18 +965,19 @@ class TestSlapOSManageBuildingCalculatingDeliveryAlarm(SlapOSTestCaseMixin):
self
.
_test_Delivery_manageBuildingCalculatingDelivery
(
'diverged'
,
True
)
class
TestSlapOSConfirmedDeliveryMixin
:
def
_test
(
self
,
simulation_state
,
causality_state
,
specialise
,
positive
,
def
_test
(
self
,
simulation_state
,
causality_state
,
ledger
,
positive
,
delivery_date
=
DateTime
(
'2012/04/22'
),
accounting_date
=
DateTime
(
'2012/04/28'
)):
@
simulateByTitlewMark
(
self
.
script
)
def
_real
(
self
,
simulation_state
,
causality_state
,
specialise
,
positive
,
def
_real
(
self
,
simulation_state
,
causality_state
,
ledger
,
positive
,
delivery_date
,
accounting_date
):
not_visited
=
'Not visited by %s'
%
self
.
script
visited
=
'Visited by %s'
%
self
.
script
module
=
self
.
portal
.
getDefaultModule
(
portal_type
=
self
.
portal_type
)
delivery
=
module
.
newContent
(
title
=
not_visited
,
start_date
=
delivery_date
,
portal_type
=
self
.
portal_type
,
specialise
=
specialise
)
ledger
=
ledger
,
portal_type
=
self
.
portal_type
)
_jumpToStateFor
=
self
.
portal
.
portal_workflow
.
_jumpToStateFor
_jumpToStateFor
(
delivery
,
simulation_state
)
_jumpToStateFor
(
delivery
,
causality_state
)
...
...
@@ -989,30 +991,32 @@ class TestSlapOSConfirmedDeliveryMixin:
self
.
assertEqual
(
visited
,
delivery
.
getTitle
())
else
:
self
.
assertEqual
(
not_visited
,
delivery
.
getTitle
())
_real
(
self
,
simulation_state
,
causality_state
,
specialise
,
positive
,
_real
(
self
,
simulation_state
,
causality_state
,
ledger
,
positive
,
delivery_date
,
accounting_date
)
def
test_typical
(
self
):
self
.
_test
(
'confirmed'
,
'solved'
,
AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL
,
True
)
'automated'
,
True
)
def
test_bad_specialise
(
self
):
def
test_bad_ledger
(
self
):
self
.
portal
.
testromain
()
self
.
_test
(
'confirmed'
,
'solved'
,
None
,
False
)
def
test_bad_simulation_state
(
self
):
self
.
_test
(
'started'
,
'solved'
,
AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL
,
False
)
'automated'
,
False
)
def
test_bad_causality_state
(
self
):
self
.
_test
(
'confirmed'
,
'calculating'
,
AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL
,
False
)
'automated'
,
False
)
@
withAbort
def
_test_script
(
self
,
simulation_state
,
causality_state
,
specialise
,
def
_test_script
(
self
,
simulation_state
,
causality_state
,
ledger
,
destination_state
,
consistency_failure
=
False
):
module
=
self
.
portal
.
getDefaultModule
(
portal_type
=
self
.
portal_type
)
delivery
=
module
.
newContent
(
portal_type
=
self
.
portal_type
,
specialise
=
specialise
,
start_date
=
DateTime
())
ledger
=
ledger
,
start_date
=
DateTime
())
_jumpToStateFor
=
self
.
portal
.
portal_workflow
.
_jumpToStateFor
_jumpToStateFor
(
delivery
,
simulation_state
)
_jumpToStateFor
(
delivery
,
causality_state
)
...
...
@@ -1033,175 +1037,27 @@ class TestSlapOSConfirmedDeliveryMixin:
def
test_script_typical
(
self
):
self
.
_test_script
(
'confirmed'
,
'solved'
,
AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL
,
'automated'
,
self
.
destination_state
)
def
test_script_bad_
specialise
(
self
):
def
test_script_bad_
ledger
(
self
):
self
.
_test_script
(
'confirmed'
,
'solved'
,
None
,
'confirmed'
)
def
test_script_bad_simulation_state
(
self
):
self
.
_test_script
(
'started'
,
'solved'
,
AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL
,
'automated'
,
'started'
)
def
test_script_bad_causality_state
(
self
):
self
.
_test_script
(
'confirmed'
,
'building'
,
AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL
,
'automated'
,
'confirmed'
)
def
test_script_bad_consistency
(
self
):
self
.
_test_script
(
'confirmed'
,
'solved'
,
AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL
,
'automated'
,
'confirmed'
,
True
)
class
TestSlapOSStartConfirmedAggregatedSalePackingListAlarm
(
SlapOSTestCaseMixin
,
TestSlapOSConfirmedDeliveryMixin
):
destination_state
=
'started'
script
=
'Delivery_startConfirmedAggregatedSalePackingList'
portal_type
=
'Sale Packing List'
alarm
=
'slapos_start_confirmed_aggregated_sale_packing_list'
def
test_previous_month
(
self
):
self
.
_test
(
'confirmed'
,
'solved'
,
AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL
,
True
,
delivery_date
=
DateTime
(
"2012/03/22"
),
accounting_date
=
DateTime
(
'2012/04/28'
))
def
test_next_month
(
self
):
self
.
_test
(
'confirmed'
,
'solved'
,
AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL
,
False
,
delivery_date
=
DateTime
(
"2012/05/22"
),
accounting_date
=
DateTime
(
'2012/04/28'
))
def
test_same_month_early
(
self
):
self
.
_test
(
'confirmed'
,
'solved'
,
AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL
,
False
,
delivery_date
=
DateTime
(
"2012/04/22"
),
accounting_date
=
DateTime
(
'2012/04/23'
))
def
test_start_date_isnt_resetted
(
self
):
delivery
=
self
.
portal
.
sale_packing_list_module
.
newContent
(
portal_type
=
"Sale Packing List"
,
start_date
=
DateTime
(
"2012/04/22"
),
specialise
=
AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL
,
source
=
self
.
expected_slapos_organisation
,
source_section
=
self
.
expected_slapos_organisation
,
destination
=
self
.
expected_slapos_organisation
,
destination_section
=
self
.
expected_slapos_organisation
,
destination_decision
=
self
.
expected_slapos_organisation
,
price_currency
=
'currency_module/EUR'
,
)
delivery
.
newContent
(
portal_type
=
"Sale Packing List Line"
,
resource
=
'service_module/slapos_instance_setup'
,
quantity
=
0
,
price
=
0
,
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
delivery
,
'solved'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
delivery
,
'confirmed'
)
delivery
.
Delivery_startConfirmedAggregatedSalePackingList
()
self
.
assertNotEqual
(
delivery
.
getStartDate
(),
DateTime
().
earliestTime
())
self
.
assertNotEqual
(
delivery
.
getStopDate
(),
DateTime
().
earliestTime
())
self
.
assertEqual
(
delivery
.
getSimulationState
(),
'started'
)
class
TestSlapOSDeliverStartedAggregatedSalePackingListAlarm
(
SlapOSTestCaseMixin
):
destination_state
=
'delivered'
script
=
'Delivery_deliverStartedAggregatedSalePackingList'
portal_type
=
'Sale Packing List'
alarm
=
'slapos_deliver_started_aggregated_sale_packing_list'
def
_test
(
self
,
simulation_state
,
causality_state
,
specialise
,
positive
,
delivery_date
=
DateTime
(
'2012/04/22'
),
accounting_date
=
DateTime
(
'2012/04/28'
)):
@
simulateByTitlewMark
(
self
.
script
)
def
_real
(
self
,
simulation_state
,
causality_state
,
specialise
,
positive
,
delivery_date
,
accounting_date
):
not_visited
=
'Not visited by %s'
%
self
.
script
visited
=
'Visited by %s'
%
self
.
script
module
=
self
.
portal
.
getDefaultModule
(
portal_type
=
self
.
portal_type
)
delivery
=
module
.
newContent
(
title
=
not_visited
,
start_date
=
delivery_date
,
portal_type
=
self
.
portal_type
,
specialise
=
specialise
)
_jumpToStateFor
=
self
.
portal
.
portal_workflow
.
_jumpToStateFor
_jumpToStateFor
(
delivery
,
simulation_state
)
_jumpToStateFor
(
delivery
,
causality_state
)
self
.
tic
()
alarm
=
getattr
(
self
.
portal
.
portal_alarms
,
self
.
alarm
)
alarm
.
activeSense
(
params
=
dict
(
accounting_date
=
accounting_date
))
self
.
tic
()
if
positive
:
self
.
assertEqual
(
visited
,
delivery
.
getTitle
())
else
:
self
.
assertEqual
(
not_visited
,
delivery
.
getTitle
())
_real
(
self
,
simulation_state
,
causality_state
,
specialise
,
positive
,
delivery_date
,
accounting_date
)
def
test_typical
(
self
):
self
.
_test
(
'started'
,
'solved'
,
AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL
,
True
)
def
test_bad_specialise
(
self
):
self
.
_test
(
'started'
,
'solved'
,
None
,
False
)
def
test_bad_simulation_state
(
self
):
self
.
_test
(
'confirmed'
,
'solved'
,
AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL
,
False
)
def
test_bad_causality_state
(
self
):
self
.
_test
(
'started'
,
'calculating'
,
AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL
,
False
)
@
withAbort
def
_test_script
(
self
,
simulation_state
,
causality_state
,
specialise
,
destination_state
,
consistency_failure
=
False
):
module
=
self
.
portal
.
getDefaultModule
(
portal_type
=
self
.
portal_type
)
delivery
=
module
.
newContent
(
portal_type
=
self
.
portal_type
,
specialise
=
specialise
,
start_date
=
DateTime
())
_jumpToStateFor
=
self
.
portal
.
portal_workflow
.
_jumpToStateFor
_jumpToStateFor
(
delivery
,
simulation_state
)
_jumpToStateFor
(
delivery
,
causality_state
)
def
checkConsistency
(
*
args
,
**
kwargs
):
if
consistency_failure
:
return
[
'bad'
]
else
:
return
[]
try
:
from
Products.ERP5Type.Core.Folder
import
Folder
Folder
.
original_checkConsistency
=
Folder
.
checkConsistency
Folder
.
checkConsistency
=
checkConsistency
getattr
(
delivery
,
self
.
script
)()
finally
:
Folder
.
checkConsistency
=
Folder
.
original_checkConsistency
delattr
(
Folder
,
'original_checkConsistency'
)
self
.
assertEqual
(
destination_state
,
delivery
.
getSimulationState
())
def
test_script_typical
(
self
):
self
.
_test_script
(
'started'
,
'solved'
,
AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL
,
self
.
destination_state
)
def
test_script_bad_specialise
(
self
):
self
.
_test_script
(
'started'
,
'solved'
,
None
,
'started'
)
def
test_script_bad_simulation_state
(
self
):
self
.
_test_script
(
'confirmed'
,
'solved'
,
AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL
,
'confirmed'
)
def
test_script_bad_causality_state
(
self
):
self
.
_test_script
(
'started'
,
'building'
,
AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL
,
'started'
)
def
test_script_bad_consistency
(
self
):
self
.
_test_script
(
'started'
,
'solved'
,
AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL
,
'started'
,
True
)
class
TestSlapOSStopConfirmedAggregatedSaleInvoiceTransactionAlarm
(
SlapOSTestCaseMixin
,
TestSlapOSConfirmedDeliveryMixin
):
...
...
@@ -1215,6 +1071,7 @@ class TestSlapOSUpdateOpenSaleOrderPeriod(SlapOSTestCaseMixin):
def
createOpenOrder
(
self
):
open_order
=
self
.
portal
.
open_sale_order_module
.
newContent
(
portal_type
=
"Open Sale Order"
,
ledger
=
'automated'
,
title
=
self
.
generateNewSoftwareTitle
(),
reference
=
"TESTHS-%s"
%
self
.
generateNewId
(),
)
...
...
@@ -1297,6 +1154,7 @@ class TestSlapOSReindexOpenSaleOrder(SlapOSTestCaseMixin):
def
createOpenOrder
(
self
):
return
self
.
portal
.
open_sale_order_module
.
newContent
(
portal_type
=
"Open Sale Order"
,
ledger
=
'automated'
,
title
=
self
.
generateNewSoftwareTitle
(),
reference
=
"TESTHS-%s"
%
self
.
generateNewId
(),
)
...
...
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