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
f5a1573a
Commit
f5a1573a
authored
Sep 08, 2023
by
Romain Courteaud
🐸
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_crm: fixup slapos_crm_create_regularisation_request tests
parent
89d0ba45
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
106 additions
and
114 deletions
+106
-114
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/Alarm_createRegularisationRequest.py
...tal_skins/slapos_crm/Alarm_createRegularisationRequest.py
+12
-17
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMAlarm.py
...ateItem/portal_components/test.erp5.testSlapOSCRMAlarm.py
+94
-97
No files found.
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/Alarm_createRegularisationRequest.py
View file @
f5a1573a
...
...
@@ -3,28 +3,23 @@ portal = context.getPortalObject()
person_uid_list
=
[]
for
(
_
,
brain
)
in
enumerate
(
portal
.
portal_simulation
.
getInventoryList
(
simulation_state
=
(
'stopped'
,
'delivered'
),
parent_payment_mode_uid
=
[
portal
.
portal_categories
.
payment_mode
.
payzen
.
getUid
(),
portal
.
portal_categories
.
payment_mode
.
wechat
.
getUid
()],
group_by_mirror_section
=
True
,
portal_type
=
portal
.
getPortalAccountingMovementTypeList
(),
node_uid
=
[
x
.
uid
for
x
in
context
.
Base_getReceivableAccountList
()],
grouping_reference
=
None
)):
parent__ledger__uid
=
portal
.
portal_categories
.
ledger
.
automated
.
getUid
(),
grouping_reference
=
None
)):
payment_request_uid
=
brain
.
payment_request_uid
if
not
payment_request_uid
:
payment_request_uid
=
brain
.
getObject
().
getExplanationUid
()
payment_request
=
portal
.
portal_catalog
.
getObject
(
uid
=
payment_request_uid
)
section_uid
=
payment_request
.
getDestinationSectionUid
(
portal_type
=
"Person"
)
section_uid
=
brain
.
getDestinationSectionUid
(
portal_type
=
"Person"
)
if
section_uid
is
not
None
:
person_uid_list
.
append
(
section_uid
)
portal
.
portal_catalog
.
searchAndActivate
(
portal_type
=
"Person"
,
validation_state
=
"validated"
,
uid
=
person_uid_list
,
method_id
=
'Person_checkToCreateRegularisationRequest'
,
activate_kw
=
{
'tag'
:
tag
}
)
if
person_uid_list
:
portal
.
portal_catalog
.
searchAndActivate
(
portal_type
=
"Person"
,
validation_state
=
"validated"
,
uid
=
person_uid_list
,
method_id
=
'Person_checkToCreateRegularisationRequest'
,
activate_kw
=
{
'tag'
:
tag
}
)
context
.
activate
(
after_tag
=
tag
).
getId
()
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMAlarm.py
View file @
f5a1573a
...
...
@@ -24,144 +24,144 @@ from erp5.component.test.SlapOSTestCaseMixin import \
SlapOSTestCaseMixin
,
SlapOSTestCaseMixinWithAbort
from
DateTime
import
DateTime
class
TestSlapOSCRMCreateRegularisationRequest
(
SlapOSTestCaseMixin
):
def
createFinalInvoice
(
self
,
person
):
template
=
self
.
portal
.
restrictedTraverse
(
self
.
portal
.
portal_preferences
.
getPreferredDefaultPrePaymentSubscriptionInvoiceTemplate
())
current_invoice
=
template
.
Base_createCloneDocument
(
batch_mode
=
1
)
current_invoice
.
edit
(
destination_value
=
person
,
class
TestSlapOSCRMCreateRegularisationRequestAlarm
(
SlapOSTestCaseMixin
):
def
createFinalInvoice
(
self
,
person
,
grouping_reference
=
None
,
ledger
=
"automated"
,
source
=
"account_module/receivable"
,
is_stopped
=
True
):
current_invoice
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
"Sale Invoice Transaction"
,
destination_section_value
=
person
,
destination_decision_value
=
person
,
start_date
=
DateTime
(
'2019/10/20'
),
stop_date
=
DateTime
(
'2019/10/20'
),
title
=
'Fake Invoice for Demo User Functional'
,
price_currency
=
"currency_module/EUR"
,
reference
=
'1'
)
cell
=
current_invoice
[
"1"
][
"movement_0"
]
cell
.
edit
(
quantity
=
1
)
cell
.
setPrice
(
1
)
resource
=
"currency_module/EUR"
,
reference
=
'1'
,
ledger
=
ledger
)
current_invoice
.
receivable
.
edit
(
source
=
source
,
quantity
=
1
,
price
=
1
,
grouping_reference
=
grouping_reference
)
current_invoice
.
plan
()
current_invoice
.
confirm
()
current_invoice
.
startBuilding
()
current_invoice
.
reindexObject
()
current_invoice
.
stop
()
if
is_stopped
:
current_invoice
.
stop
()
self
.
tic
()
current_invoice
.
Delivery_manageBuildingCalculatingDelivery
()
self
.
tic
()
applied_rule
=
current_invoice
.
getCausalityRelated
(
portal_type
=
"Applied Rule"
)
for
sm
in
self
.
portal
.
portal_catalog
(
portal_type
=
'Simulation Movement'
,
simulation_state
=
[
'draft'
,
'planned'
,
None
],
left_join_list
=
[
'delivery_uid'
],
delivery_uid
=
None
,
path
=
"%%%s%%"
%
applied_rule
):
if
sm
.
getDelivery
()
is
not
None
:
continue
root_applied_rule
=
sm
.
getRootAppliedRule
()
root_applied_rule_path
=
root_applied_rule
.
getPath
()
sm
.
getCausalityValue
(
portal_type
=
'Business Link'
).
build
(
path
=
'%s/%%'
%
root_applied_rule_path
)
return
current_invoice
def
test_createRegularisationRequest_expected_person
(
self
):
#################################################################
# slapos_crm_create_regularisation_request
#################################################################
def
test_Person_checkToCreateRegularisationRequest_alarm_expectedPerson
(
self
):
new_id
=
self
.
generateNewId
()
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
title
=
"Test person %s"
%
new_id
)
person
.
validate
()
self
.
createFinalInvoice
(
person
)
self
.
tic
()
alarm
=
self
.
portal
.
portal_alarms
.
\
slapos_crm_create_regularisation_request
self
.
_test_alarm
(
alarm
,
person
,
"Person_checkToCreateRegularisationRequest"
)
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_crm_create_regularisation_request
,
person
,
'Person_checkToCreateRegularisationRequest'
)
def
test_
createRegularisationRequest_not_valida
ted
(
self
):
def
test_
Person_checkToCreateRegularisationRequest_alarm_star
ted
(
self
):
new_id
=
self
.
generateNewId
()
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
title
=
"Test person %s"
%
new_id
)
person
.
validate
()
self
.
createFinalInvoice
(
person
)
person
.
invalidate
()
self
.
createFinalInvoice
(
person
,
is_stopped
=
False
)
self
.
tic
()
alarm
=
self
.
portal
.
portal_alarms
.
\
slapos_crm_create_regularisation_request
self
.
_test_alarm_not_visited
(
alarm
,
person
,
"Person_checkToCreateRegularisationRequest"
)
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_crm_create_regularisation_request
,
person
,
'Person_checkToCreateRegularisationRequest'
)
def
test_
createRegularisationRequest_payment_stopp
ed
(
self
):
def
test_
Person_checkToCreateRegularisationRequest_alarm_letter
ed
(
self
):
new_id
=
self
.
generateNewId
()
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
title
=
"Test person %s"
%
new_id
)
person
.
validate
()
current_invoice
=
self
.
createFinalInvoice
(
person
)
payment_template
=
self
.
portal
.
restrictedTraverse
(
self
.
portal
.
portal_preferences
.
getPreferredDefaultPrePaymentTemplate
())
payment
=
payment_template
.
Base_createCloneDocument
(
batch_mode
=
1
)
for
line
in
payment
.
contentValues
():
if
line
.
getSource
()
==
"account_module/payment_to_encash"
:
line
.
setQuantity
(
-
1
)
elif
line
.
getSource
()
==
"account_module/receivable"
:
line
.
setQuantity
(
1
)
payment
.
confirm
()
payment
.
start
()
payment
.
setCausalityValue
(
current_invoice
)
payment
.
setDestinationSectionValue
(
person
)
payment
.
stop
()
self
.
createFinalInvoice
(
person
,
grouping_reference
=
"foobar"
)
self
.
tic
()
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_crm_create_regularisation_request
,
person
,
'Person_checkToCreateRegularisationRequest'
)
def
test_Person_checkToCreateRegularisationRequest_alarm_noLedger
(
self
):
new_id
=
self
.
generateNewId
()
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
title
=
"Test person %s"
%
new_id
)
person
.
validate
()
self
.
createFinalInvoice
(
person
,
ledger
=
None
)
self
.
tic
()
alarm
=
self
.
portal
.
portal_alarms
.
\
slapos_crm_create_regularisation_request
self
.
_test_alarm_not_visited
(
alarm
,
person
,
"Person_checkToCreateRegularisationRequest"
)
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_crm_create_regularisation_request
,
person
,
'Person_checkToCreateRegularisationRequest'
)
def
test_
createRegularisationRequest_payment_started
(
self
):
def
test_
Person_checkToCreateRegularisationRequest_alarm_noReceivable
(
self
):
new_id
=
self
.
generateNewId
()
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
title
=
"Test person %s"
%
new_id
)
person
.
validate
()
self
.
createFinalInvoice
(
person
,
source
=
"account_module/bank"
)
self
.
tic
()
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_crm_create_regularisation_request
,
person
,
'Person_checkToCreateRegularisationRequest'
)
current_invoice
=
self
.
createFinalInvoice
(
person
)
payment_template
=
self
.
portal
.
restrictedTraverse
(
self
.
portal
.
portal_preferences
.
getPreferredDefaultPrePaymentTemplate
())
payment
=
payment_template
.
Base_createCloneDocument
(
batch_mode
=
1
)
for
line
in
payment
.
contentValues
():
if
line
.
getSource
()
==
"account_module/payment_to_encash"
:
line
.
setQuantity
(
-
1
)
elif
line
.
getSource
()
==
"account_module/receivable"
:
line
.
setQuantity
(
1
)
payment
.
confirm
()
payment
.
start
()
payment
.
setCausalityValue
(
current_invoice
)
payment
.
setDestinationSectionValue
(
person
)
def
test_Person_checkToCreateRegularisationRequest_alarm_notValidatedPerson
(
self
):
new_id
=
self
.
generateNewId
()
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
title
=
"Test person %s"
%
new_id
)
person
.
validate
()
person
.
invalidate
(
)
self
.
createFinalInvoice
(
person
)
self
.
tic
(
)
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_crm_create_regularisation_request
,
person
,
'Person_checkToCreateRegularisationRequest'
)
def
test_Person_checkToCreateRegularisationRequest_alarm_noInvoice
(
self
):
new_id
=
self
.
generateNewId
()
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
title
=
"Test person %s"
%
new_id
)
person
.
validate
()
self
.
tic
()
alarm
=
self
.
portal
.
portal_alarms
.
\
slapos_crm_create_regularisation_request
self
.
_test_alarm
(
alarm
,
person
,
"Person_checkToCreateRegularisationRequest"
)
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_crm_create_regularisation_request
,
person
,
'Person_checkToCreateRegularisationRequest'
)
# XXX couscous
class
TestSlapOSCrmInvalidateSuspendedRegularisationRequest
(
SlapOSTestCaseMixinWithAbort
):
...
...
@@ -488,7 +488,7 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort)
def
_test_alarm_check_compute_node_state_selected
(
self
,
allocation_scope
,
monitor_scope
=
None
):
self
.
_makeComputeNode
()
self
.
_makeComputeNode
(
self
.
addProject
()
)
self
.
compute_node
.
edit
(
allocation_scope
=
allocation_scope
)
self
.
tic
()
if
monitor_scope
is
not
None
:
...
...
@@ -557,16 +557,13 @@ class TestSlapOSCrmMonitoringCheckComputeNodeSoftwareInstallation(SlapOSTestCase
self
.
_makeComputeNode
(
self
.
addProject
())
self
.
compute_node
.
edit
(
allocation_scope
=
allocation_scope
)
self
.
tic
()
if
monitor_scope
is
not
None
:
self
.
compute_node
.
edit
(
monitor_scope
=
monitor_scope
)
self
.
tic
()
alarm
=
self
.
portal
.
portal_alarms
.
\
slapos_crm_check_software_installation_state
self
.
_test_alarm_not_visited
(
alarm
,
self
.
compute_node
,
"ComputeNode_checkSoftwareInstallationState"
)
def
_test_alarm_run_on_close
(
self
,
allocation_scope
,
):
self
.
_makeComputeNode
()
def
_test_alarm_run_on_close
(
self
,
allocation_scope
):
self
.
_makeComputeNode
(
self
.
addProject
()
)
self
.
compute_node
.
edit
(
allocation_scope
=
allocation_scope
)
self
.
tic
()
...
...
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