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
Arnaud Véron
slapos.core
Commits
7918f6c7
Commit
7918f6c7
authored
Nov 27, 2020
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_accounting:Include tests for Entity_statSlapOSOutstandingAmount
parent
7d6609b9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
114 additions
and
6 deletions
+114
-6
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_contract/Entity_statSlapOSOutstandingAmount.py
...ins/slapos_contract/Entity_statSlapOSOutstandingAmount.py
+0
-4
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_contract/Entity_statSlapOSOutstandingAmount.xml
...ns/slapos_contract/Entity_statSlapOSOutstandingAmount.xml
+1
-1
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSContractSkins.py
...em/portal_components/test.erp5.testSlapOSContractSkins.py
+113
-1
No files found.
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_contract/Entity_statSlapOSOutstandingAmount.py
View file @
7918f6c7
portal
=
context
.
getPortalObject
()
portal
=
context
.
getPortalObject
()
from
DateTime
import
DateTime
from
DateTime
import
DateTime
at_date
=
None
if
at_date
in
kw
:
at_date
=
kw
[
"at_date"
]
if
contract
is
None
:
if
contract
is
None
:
contract
=
portal
.
portal_catalog
.
getResultValue
(
contract
=
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
"Cloud Contract"
,
portal_type
=
"Cloud Contract"
,
...
...
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_contract/Entity_statSlapOSOutstandingAmount.xml
View file @
7918f6c7
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
contract=None, **kw
</string>
</value>
<value>
<string>
contract=None,
at_date=None,
**kw
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
id
</string>
</key>
<key>
<string>
id
</string>
</key>
...
...
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSContractSkins.py
View file @
7918f6c7
# Copyright (c) 2013 Nexedi SA and Contributors. All Rights Reserved.
# Copyright (c) 2013 Nexedi SA and Contributors. All Rights Reserved.
from
erp5.component.test.SlapOSTestCaseMixin
import
SlapOSTestCaseMixinWithAbort
from
erp5.component.test.SlapOSTestCaseMixin
import
SlapOSTestCaseMixinWithAbort
,
simulate
from
DateTime
import
DateTime
from
zExceptions
import
Unauthorized
from
zExceptions
import
Unauthorized
...
@@ -306,3 +307,114 @@ class TestSlapOSPerson_isAllowedToAllocate(SlapOSTestCaseMixinWithAbort):
...
@@ -306,3 +307,114 @@ class TestSlapOSPerson_isAllowedToAllocate(SlapOSTestCaseMixinWithAbort):
# If Contract is disabled, anyone can allocate
# If Contract is disabled, anyone can allocate
self
.
assertEqual
(
result
,
True
)
self
.
assertEqual
(
result
,
True
)
class
TestSlapOSEntity_statSlapOSOutstandingAmount
(
SlapOSTestCaseMixinWithAbort
):
def
createPerson
(
self
):
new_id
=
self
.
generateNewId
()
return
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
title
=
"Person %s"
%
new_id
,
reference
=
"TESTPERS-%s"
%
new_id
,
)
def
createCloudContract
(
self
):
new_id
=
self
.
generateNewId
()
return
self
.
portal
.
cloud_contract_module
.
newContent
(
portal_type
=
'Cloud Contract'
,
title
=
"Contract %s"
%
new_id
,
reference
=
"TESTCONTRACT-%s"
%
new_id
,
)
@
simulate
(
"Entity_statOutstandingAmount"
,
"*args, **kwargs"
,
"return 'simulated_result'"
)
def
test_outstanding_amount_missing_cloud_contract
(
self
):
person
=
self
.
createPerson
()
self
.
assertEqual
(
'simulated_result'
,
person
.
Entity_statSlapOSOutstandingAmount
())
@
simulate
(
"Entity_statOutstandingAmount"
,
"*args, **kwargs"
,
"return None"
)
def
test_outstanding_with_cloud_contract_but_no_amount
(
self
):
person
=
self
.
createPerson
()
cloud_contract
=
self
.
createCloudContract
()
cloud_contract
.
setDestinationSection
(
person
.
getRelativeUrl
())
cloud_contract
.
validate
()
# Provide contract w/o indexation
self
.
assertEqual
(
None
,
person
.
Entity_statSlapOSOutstandingAmount
(
contract
=
cloud_contract
))
self
.
tic
()
# Provide contract w/o indexation
self
.
assertEqual
(
None
,
person
.
Entity_statSlapOSOutstandingAmount
())
@
simulate
(
"Entity_statOutstandingAmount"
,
"*args, **kwargs"
,
"return kwargs.get('at_date', 195.0)"
)
def
test_outstanding_with_cloud_contract_but_no_line
(
self
):
person
=
self
.
createPerson
()
cloud_contract
=
self
.
createCloudContract
()
cloud_contract
.
setDestinationSection
(
person
.
getRelativeUrl
())
cloud_contract
.
validate
()
self
.
tic
()
# Without Lines the result uses at_date
at_date
=
DateTime
()
self
.
assertEqual
(
at_date
,
person
.
Entity_statSlapOSOutstandingAmount
(
at_date
=
at_date
))
@
simulate
(
"Entity_statOutstandingAmount"
,
"at_date=None, resource_uid=None"
,
"""
from DateTime import DateTime
assert at_date in (None, DateTime().earliestTime()-1)
if at_date == DateTime().earliestTime()-1:
return -999
if resource_uid in (None, context.currency_module.EUR.getUid()):
return 195.0
else:
return 0"""
)
def
test_outstanding_with_cloud_contract_with_linein_euro
(
self
):
person
=
self
.
createPerson
()
cloud_contract
=
self
.
createCloudContract
()
cloud_contract
.
setDestinationSection
(
person
.
getRelativeUrl
())
cloud_contract
.
validate
()
line
=
cloud_contract
.
newContent
(
price_currency_value
=
self
.
portal
.
currency_module
.
CNY
,
maximum_invoice_credit
=
10.0
)
self
.
tic
()
# Without Lines the result uses at_date
self
.
assertEqual
(
195.0
,
person
.
Entity_statSlapOSOutstandingAmount
())
line
.
edit
(
price_currency_value
=
self
.
portal
.
currency_module
.
EUR
,
)
# Without Lines the result uses at_date
self
.
assertEqual
(
185.0
,
person
.
Entity_statSlapOSOutstandingAmount
())
line
.
setMaximumInvoiceCredit
(
200
)
# Without Lines the result uses at_date
self
.
assertEqual
(
195.0
,
person
.
Entity_statSlapOSOutstandingAmount
())
# We need at least one day
cloud_contract
.
setMaximumInvoiceDelay
(
1
)
self
.
pinDateTime
(
DateTime
().
earliestTime
())
self
.
addCleanup
(
self
.
unpinDateTime
)
# Without Lines the result uses at_date
self
.
assertEqual
(
-
999
,
person
.
Entity_statSlapOSOutstandingAmount
())
self
.
unpinDateTime
()
\ 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