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
Labels
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Rafael Monnerat
slapos.core
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
import
unittest
from
Products.ERP5Type.tests.Sequence
import
SequenceList
from
Products.ERP5Type.tests.Sequence
import
SequenceList
from
testVifibSlapWebService
import
TestVifibSlapWebServiceMixin
from
testVifibSlapWebService
import
TestVifibSlapWebServiceMixin
from
Products.ERP5Type.DateUtils
import
getClosestDate
from
DateTime
import
DateTime
from
testVifibOpenOrderSimulation
import
generateTimeFrameList
class
TestVifibInstanceHostingRelatedDocument
(
TestVifibSlapWebServiceMixin
):
class
TestVifibInstanceHostingRelatedDocument
(
TestVifibSlapWebServiceMixin
):
...
@@ -8,49 +11,70 @@ class TestVifibInstanceHostingRelatedDocument(TestVifibSlapWebServiceMixin):
...
@@ -8,49 +11,70 @@ class TestVifibInstanceHostingRelatedDocument(TestVifibSlapWebServiceMixin):
self
.
portal
.
portal_alarms
.
vifib_trigger_build
.
activeSense
()
self
.
portal
.
portal_alarms
.
vifib_trigger_build
.
activeSense
()
def
stepCheckSubscriptionSalePackingListCoverage
(
self
,
sequence
,
**
kw
):
def
stepCheckSubscriptionSalePackingListCoverage
(
self
,
sequence
,
**
kw
):
raise
NotImplementedError
(
hosting_subscription
=
self
.
portal
.
portal_catalog
.
getResultValue
(
"Shall check that 12 SPLs are build to cover the whole year."
)
uid
=
sequence
[
'hosting_subscription_uid'
])
# check one more sale packing list is generated
delivery_list
=
self
.
portal
.
portal_catalog
(
# and only one sale packing list line is inside
portal_type
=
'Sale Packing List'
,
sale_packing_list
=
sequence
[
'current_sale_packing_list'
]
causality_relative_url
=
hosting_subscription
.
getRelativeUrl
(),
sale_packing_list_line_list
=
\
sort_on
=
((
'delivery.start_date'
,
'desc'
),)
sale_packing_list
.
contentValues
(
portal_type
=
"Sale Packing List Line"
)
)
self
.
assertEquals
(
1
,
len
(
sale_packing_list_line_list
))
# is whole year covered?
sale_packing_list_line
=
sale_packing_list_line_list
[
0
]
self
.
assertEqual
(
12
,
len
(
delivery_list
))
# check sale packing list related property
# generate the expected time frames
self
.
assertEquals
(
"organisation_module/vifib_internet"
,
now
=
DateTime
()
sale_packing_list
.
getSource
())
start_date
=
\
self
.
assertEquals
(
"organisation_module/vifib_internet"
,
getClosestDate
(
target_date
=
now
,
precision
=
'day'
,
before
=
1
)
sale_packing_list
.
getSourceSection
())
self
.
assertEquals
(
"person_module/test_vifib_customer"
,
# Calculate the list of time frames
sale_packing_list
.
getDestination
())
expected_time_frame_list
=
generateTimeFrameList
(
start_date
)
self
.
assertEquals
(
"person_module/test_vifib_customer"
,
sale_packing_list
.
getDestinationSection
())
idx
=
0
self
.
assertEquals
(
"currency_module/EUR"
,
for
delivery
in
delivery_list
:
sale_packing_list
.
getPriceCurrency
())
expected_start_date
=
expected_time_frame_list
[
idx
]
expected_stop_date
=
expected_time_frame_list
[
idx
+
1
]
# check sale packing list line related property
self
.
assertEqual
(
expected_start_date
,
delivery
.
getStartDate
())
self
.
assertEquals
(
"service_module/vifib_instance_subscription"
,
self
.
assertEqual
(
expected_stop_date
,
delivery
.
getStopDate
())
sale_packing_list_line
.
getResource
())
self
.
assertEquals
(
1
,
self
.
assertEqual
(
hosting_subscription
.
getRelativeUrl
(),
sale_packing_list_line
.
getQuantity
())
delivery
.
getCausality
())
self
.
assertEquals
(
"unit/piece"
,
delivery_line_list
=
\
sale_packing_list_line
.
getQuantityUnit
())
delivery
.
contentValues
(
portal_type
=
"Sale Packing List Line"
)
self
.
assertEquals
(
1
,
self
.
assertEquals
(
1
,
len
(
delivery_line_list
))
sale_packing_list_line
.
getPrice
())
delivery_line
=
delivery_line_list
[
0
]
self
.
assertEquals
(
"organisation_module/vifib_internet"
,
# fetch open order, open order line and subscription
delivery
.
getSource
())
person
=
self
.
portal
.
person_module
[
'test_vifib_customer'
]
self
.
assertEquals
(
"organisation_module/vifib_internet"
,
open_order
=
\
delivery
.
getSourceSection
())
person
.
getDestinationDecisionRelatedValue
(
portal_type
=
"Open Sale Order"
)
self
.
assertEquals
(
"person_module/test_vifib_customer"
,
open_order_line
=
\
delivery
.
getDestination
())
open_order
.
contentValues
(
portal_type
=
"Open Sale Order Line"
)[
0
]
self
.
assertEquals
(
"person_module/test_vifib_customer"
,
delivery
.
getDestinationSection
())
# check related property
self
.
assertEquals
(
"currency_module/EUR"
,
self
.
assertEquals
(
open_order_line
.
getSpecialise
(),
delivery
.
getPriceCurrency
())
sale_packing_list
.
getSpecialise
())
# 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
):
def
stepCheckOneMoreDocumentList
(
self
,
sequence
,
**
kw
):
hosting_subscription
=
self
.
portal
.
portal_catalog
\
hosting_subscription
=
self
.
portal
.
portal_catalog
\
...
@@ -117,6 +141,7 @@ class TestVifibInstanceHostingRelatedDocument(TestVifibSlapWebServiceMixin):
...
@@ -117,6 +141,7 @@ class TestVifibInstanceHostingRelatedDocument(TestVifibSlapWebServiceMixin):
"""
"""
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
sequence_list
.
play
(
self
)
raise
NotImplementedError
(
'Cover various cases of triggering build'
)
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
...
...
master/product/Vifib/tests/testVifibOpenOrderSimulation.py
View file @
c5630292
...
@@ -5,6 +5,14 @@ from testVifibSlapWebService import TestVifibSlapWebServiceMixin
...
@@ -5,6 +5,14 @@ from testVifibSlapWebService import TestVifibSlapWebServiceMixin
from
DateTime.DateTime
import
DateTime
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
):
class
TestVifibOpenOrderSimulation
(
TestVifibSlapWebServiceMixin
):
def
stepCheckSimulationMovement
(
self
,
sequence
,
**
kw
):
def
stepCheckSimulationMovement
(
self
,
sequence
,
**
kw
):
...
@@ -76,11 +84,7 @@ class TestVifibOpenOrderSimulation(TestVifibSlapWebServiceMixin):
...
@@ -76,11 +84,7 @@ class TestVifibOpenOrderSimulation(TestVifibSlapWebServiceMixin):
0.0
,
open_order_line
.
getStopDate
().
second
())
0.0
,
open_order_line
.
getStopDate
().
second
())
# Calculate the list of time frames
# Calculate the list of time frames
expected_time_frame_list
=
[
start_date
]
expected_time_frame_list
=
generateTimeFrameList
(
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
))
# test the test: have we generated 12th next months coverage?
# test the test: have we generated 12th next months coverage?
self
.
assertEqual
(
13
,
len
(
expected_time_frame_list
))
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