Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
104
Merge Requests
104
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos
Commits
c5630292
Commit
c5630292
authored
Dec 26, 2011
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement Sale Packing List checking.
parent
aa637673
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
48 deletions
+77
-48
master/product/Vifib/tests/testVifibInstanceHostingRelatedDocument.py
...ct/Vifib/tests/testVifibInstanceHostingRelatedDocument.py
+68
-43
master/product/Vifib/tests/testVifibOpenOrderSimulation.py
master/product/Vifib/tests/testVifibOpenOrderSimulation.py
+9
-5
No files found.
master/product/Vifib/tests/testVifibInstanceHostingRelatedDocument.py
View file @
c5630292
import
unittest
from
Products.ERP5Type.tests.Sequence
import
SequenceList
from
testVifibSlapWebService
import
TestVifibSlapWebServiceMixin
from
Products.ERP5Type.DateUtils
import
getClosestDate
from
DateTime
import
DateTime
from
testVifibOpenOrderSimulation
import
generateTimeFrameList
class
TestVifibInstanceHostingRelatedDocument
(
TestVifibSlapWebServiceMixin
):
...
...
@@ -8,49 +11,70 @@ class TestVifibInstanceHostingRelatedDocument(TestVifibSlapWebServiceMixin):
self
.
portal
.
portal_alarms
.
vifib_trigger_build
.
activeSense
()
def
stepCheckSubscriptionSalePackingListCoverage
(
self
,
sequence
,
**
kw
):
raise
NotImplementedError
(
"Shall check that 12 SPLs are build to cover the whole year."
)
# check one more sale packing list is generated
# and only one sale packing list line is inside
sale_packing_list
=
sequence
[
'current_sale_packing_list'
]
sale_packing_list_line_list
=
\
sale_packing_list
.
contentValues
(
portal_type
=
"Sale Packing List Line"
)
self
.
assertEquals
(
1
,
len
(
sale_packing_list_line_list
))
sale_packing_list_line
=
sale_packing_list_line_list
[
0
]
# check sale packing list related property
self
.
assertEquals
(
"organisation_module/vifib_internet"
,
sale_packing_list
.
getSource
())
self
.
assertEquals
(
"organisation_module/vifib_internet"
,
sale_packing_list
.
getSourceSection
())
self
.
assertEquals
(
"person_module/test_vifib_customer"
,
sale_packing_list
.
getDestination
())
self
.
assertEquals
(
"person_module/test_vifib_customer"
,
sale_packing_list
.
getDestinationSection
())
self
.
assertEquals
(
"currency_module/EUR"
,
sale_packing_list
.
getPriceCurrency
())
# check sale packing list line related property
self
.
assertEquals
(
"service_module/vifib_instance_subscription"
,
sale_packing_list_line
.
getResource
())
self
.
assertEquals
(
1
,
sale_packing_list_line
.
getQuantity
())
self
.
assertEquals
(
"unit/piece"
,
sale_packing_list_line
.
getQuantityUnit
())
self
.
assertEquals
(
1
,
sale_packing_list_line
.
getPrice
())
# fetch open order, open order line and subscription
person
=
self
.
portal
.
person_module
[
'test_vifib_customer'
]
open_order
=
\
person
.
getDestinationDecisionRelatedValue
(
portal_type
=
"Open Sale Order"
)
open_order_line
=
\
open_order
.
contentValues
(
portal_type
=
"Open Sale Order Line"
)[
0
]
# check related property
self
.
assertEquals
(
open_order_line
.
getSpecialise
(),
sale_packing_list
.
getSpecialise
())
hosting_subscription
=
self
.
portal
.
portal_catalog
.
getResultValue
(
uid
=
sequence
[
'hosting_subscription_uid'
])
delivery_list
=
self
.
portal
.
portal_catalog
(
portal_type
=
'Sale Packing List'
,
causality_relative_url
=
hosting_subscription
.
getRelativeUrl
(),
sort_on
=
((
'delivery.start_date'
,
'desc'
),)
)
# is whole year covered?
self
.
assertEqual
(
12
,
len
(
delivery_list
))
# generate the expected time frames
now
=
DateTime
()
start_date
=
\
getClosestDate
(
target_date
=
now
,
precision
=
'day'
,
before
=
1
)
# Calculate the list of time frames
expected_time_frame_list
=
generateTimeFrameList
(
start_date
)
idx
=
0
for
delivery
in
delivery_list
:
expected_start_date
=
expected_time_frame_list
[
idx
]
expected_stop_date
=
expected_time_frame_list
[
idx
+
1
]
self
.
assertEqual
(
expected_start_date
,
delivery
.
getStartDate
())
self
.
assertEqual
(
expected_stop_date
,
delivery
.
getStopDate
())
self
.
assertEqual
(
hosting_subscription
.
getRelativeUrl
(),
delivery
.
getCausality
())
delivery_line_list
=
\
delivery
.
contentValues
(
portal_type
=
"Sale Packing List Line"
)
self
.
assertEquals
(
1
,
len
(
delivery_line_list
))
delivery_line
=
delivery_line_list
[
0
]
self
.
assertEquals
(
"organisation_module/vifib_internet"
,
delivery
.
getSource
())
self
.
assertEquals
(
"organisation_module/vifib_internet"
,
delivery
.
getSourceSection
())
self
.
assertEquals
(
"person_module/test_vifib_customer"
,
delivery
.
getDestination
())
self
.
assertEquals
(
"person_module/test_vifib_customer"
,
delivery
.
getDestinationSection
())
self
.
assertEquals
(
"currency_module/EUR"
,
delivery
.
getPriceCurrency
())
# check sale packing list line related property
self
.
assertEquals
(
"service_module/vifib_instance_subscription"
,
delivery_line
.
getResource
())
self
.
assertEquals
(
1
,
delivery_line
.
getQuantity
())
self
.
assertEquals
(
"unit/piece"
,
delivery_line
.
getQuantityUnit
())
self
.
assertEquals
(
1
,
delivery_line
.
getPrice
())
# fetch open order, open order line and subscription
person
=
self
.
portal
.
person_module
[
'test_vifib_customer'
]
open_order
=
\
person
.
getDestinationDecisionRelatedValue
(
portal_type
=
"Open Sale Order"
)
open_order_line
=
\
open_order
.
contentValues
(
portal_type
=
"Open Sale Order Line"
)[
0
]
# check related property
self
.
assertEquals
(
open_order_line
.
getSpecialise
(),
delivery
.
getSpecialise
())
idx
+=
1
def
stepCheckOneMoreDocumentList
(
self
,
sequence
,
**
kw
):
hosting_subscription
=
self
.
portal
.
portal_catalog
\
...
...
@@ -117,6 +141,7 @@ class TestVifibInstanceHostingRelatedDocument(TestVifibSlapWebServiceMixin):
"""
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
raise
NotImplementedError
(
'Cover various cases of triggering build'
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
...
...
master/product/Vifib/tests/testVifibOpenOrderSimulation.py
View file @
c5630292
...
...
@@ -5,6 +5,14 @@ from testVifibSlapWebService import TestVifibSlapWebServiceMixin
from
DateTime.DateTime
import
DateTime
def
generateTimeFrameList
(
start_date
):
expected_time_frame_list
=
[
start_date
]
current
=
\
getClosestDate
(
target_date
=
start_date
,
precision
=
'month'
,
before
=
0
)
for
m
in
range
(
0
,
12
):
expected_time_frame_list
.
append
(
addToDate
(
current
,
month
=
m
))
return
expected_time_frame_list
class
TestVifibOpenOrderSimulation
(
TestVifibSlapWebServiceMixin
):
def
stepCheckSimulationMovement
(
self
,
sequence
,
**
kw
):
...
...
@@ -76,11 +84,7 @@ class TestVifibOpenOrderSimulation(TestVifibSlapWebServiceMixin):
0.0
,
open_order_line
.
getStopDate
().
second
())
# Calculate the list of time frames
expected_time_frame_list
=
[
start_date
]
current
=
\
getClosestDate
(
target_date
=
start_date
,
precision
=
'month'
,
before
=
0
)
for
m
in
range
(
0
,
12
):
expected_time_frame_list
.
append
(
addToDate
(
current
,
month
=
m
))
expected_time_frame_list
=
generateTimeFrameList
(
start_date
)
# test the test: have we generated 12th next months coverage?
self
.
assertEqual
(
13
,
len
(
expected_time_frame_list
))
...
...
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