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
1
Merge Requests
1
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
Romain Courteaud
slapos.core
Commits
38890225
Commit
38890225
authored
Jan 06, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_slap_tool: getSoftwareReleaseListFromSoftwareProduct is related to a project
parent
4a4b83fc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
26 deletions
+24
-26
master/bt5/slapos_slap_tool/TestTemplateItem/portal_components/test.erp5.testSlapOSSlapTool.py
...ateItem/portal_components/test.erp5.testSlapOSSlapTool.py
+9
-21
master/bt5/slapos_slap_tool/ToolComponentTemplateItem/portal_components/tool.erp5.SlapTool.py
...onentTemplateItem/portal_components/tool.erp5.SlapTool.py
+15
-5
No files found.
master/bt5/slapos_slap_tool/TestTemplateItem/portal_components/test.erp5.testSlapOSSlapTool.py
View file @
38890225
...
...
@@ -2408,30 +2408,17 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
def
test_getSoftwareReleaseListFromSoftwareProduct_fromUrl
(
self
):
new_id
=
self
.
generateNewId
()
software_product
=
self
.
_makeSoftwareProduct
(
self
.
project
,
new_id
=
new_id
)
software_product
=
self
.
_makeSoftwareProduct
(
self
.
project
,
new_id
=
new_id
,
url
=
'http://example.org/1.cfg'
)
# 2 published software releases
software_release1
=
s
elf
.
_makeSoftwareRelease
(
software_product
)
software_release2
=
self
.
_makeSoftwareRelease
(
software_product
)
software_release1
=
s
oftware_product
.
contentValues
(
portal_type
=
'Software Product Release Variation'
)[
0
]
software_release2
=
self
.
_makeSoftwareRelease
(
software_product
,
url
=
'http://example.org/2.cfg'
)
# 1 released software release, should not appear
software_release3
=
self
.
_makeSoftwareRelease
(
software_product
)
self
.
assertTrue
(
software_release3
.
getValidationState
()
==
'released'
)
software_release1
.
edit
(
aggregate_value
=
software_product
.
getRelativeUrl
(),
url_string
=
'http://example.org/1.cfg'
)
software_release2
.
edit
(
aggregate_value
=
software_product
.
getRelativeUrl
(),
url_string
=
'http://example.org/2.cfg'
)
software_release3
.
edit
(
aggregate_value
=
software_product
.
getRelativeUrl
(),
url_string
=
'http://example.org/3.cfg'
)
self
.
tic
()
response
=
self
.
portal_slap
.
getSoftwareReleaseListFromSoftwareProduct
(
software_release_url
=
software_release2
.
getUrlString
())
self
.
project
.
getReference
(),
software_release_url
=
software_release2
.
getUrlString
())
# check returned XML
got_xml
=
etree
.
tostring
(
etree
.
fromstring
(
response
),
pretty_print
=
True
,
encoding
=
"UTF-8"
,
xml_declaration
=
True
)
...
...
@@ -2443,7 +2430,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<string>%s</string>
</list>
</marshal>
"""
%
(
software_release
2
.
getUrlString
(),
software_release1
.
getUrlString
())
"""
%
(
software_release
1
.
getUrlString
(),
software_release2
.
getUrlString
())
self
.
assertEqual
(
expected_xml
,
got_xml
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
...
...
@@ -3266,7 +3253,8 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
self
.
assertEqual
(
expected_xml
,
got_xml
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
self
.
assertRequestComputeNodeSimulator
((),
{
'compute_node_title'
:
compute_node_id
,
'project_reference'
:
self
.
project
.
getReference
()})
self
.
assertRequestComputeNodeSimulator
((),
{
'compute_node_title'
:
compute_node_id
,
'project_reference'
:
self
.
project
.
getReference
()})
finally
:
if
os
.
path
.
exists
(
self
.
compute_node_request_compute_node_simulator
):
os
.
unlink
(
self
.
compute_node_request_compute_node_simulator
)
...
...
master/bt5/slapos_slap_tool/ToolComponentTemplateItem/portal_components/tool.erp5.SlapTool.py
View file @
38890225
...
...
@@ -372,7 +372,7 @@ class SlapTool(BaseTool):
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getSoftwareReleaseListFromSoftwareProduct'
)
def
getSoftwareReleaseListFromSoftwareProduct
(
self
,
def
getSoftwareReleaseListFromSoftwareProduct
(
self
,
project_reference
,
software_product_reference
=
None
,
software_release_url
=
None
):
"""
Get the list of all published Software Releases related to one of either:
...
...
@@ -383,12 +383,23 @@ class SlapTool(BaseTool):
If referenced Software Product does not exist, return empty list.
If referenced Software Release does not exist, raise.
"""
project_list
=
self
.
getPortalObject
().
portal_catalog
.
portal_catalog
(
portal_type
=
'Project'
,
reference
=
project_reference
,
validation_state
=
'validated'
,
limit
=
2
)
if
len
(
project_list
)
!=
1
:
raise
NotImplementedError
(
"%i projects '%s'"
%
(
len
(
project_list
),
project_reference
))
project
=
project_list
[
0
]
if
software_product_reference
is
None
:
assert
(
software_release_url
is
not
None
)
software_product_reference
=
self
.
getPortalObject
().
portal_catalog
.
unrestrictedSearchResults
(
portal_type
=
'Software Product Release Variation'
,
parent__follow_up__uid
=
project
.
getUid
(),
url_string
=
software_release_url
)[
0
].
getObject
().
get
Aggregate
Value
().
getReference
()
)[
0
].
getObject
().
get
Parent
Value
().
getReference
()
else
:
# Don't accept both parameters
assert
(
software_release_url
is
None
)
...
...
@@ -396,6 +407,7 @@ class SlapTool(BaseTool):
software_product_list
=
self
.
getPortalObject
().
portal_catalog
.
unrestrictedSearchResults
(
portal_type
=
'Software Product'
,
reference
=
software_product_reference
,
follow_up__uid
=
project
.
getUid
(),
validation_state
=
'published'
)
if
len
(
software_product_list
)
is
0
:
return
dumps
([])
...
...
@@ -419,9 +431,7 @@ class SlapTool(BaseTool):
)
return
dumps
(
[
software_release
.
getUrlString
()
for
software_release
in
software_release_list
if
software_release
.
getValidationState
()
in
\
[
'published'
,
'published_alive'
]])
for
software_release
in
software_release_list
])
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getHateoasUrl'
)
...
...
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