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
Hardik Juneja
slapos.core
Commits
0885ba5f
Commit
0885ba5f
authored
Oct 27, 2014
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[slapos_hypermedia] Add Instance_getHateoasRelatedHostingSubscription.
parent
934020fd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
284 additions
and
1 deletion
+284
-1
master/bt5/slapos_hypermedia/ActionTemplateItem/portal_types/Software%20Instance/get_hateoas_related_hosting_subscription.xml
...e%20Instance/get_hateoas_related_hosting_subscription.xml
+85
-0
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Instance_getHateoasRelatedHostingSubscription.xml
...ermedia/Instance_getHateoasRelatedHostingSubscription.xml
+108
-0
master/bt5/slapos_hypermedia/TestTemplateItem/testSlapOSHypermediaSkins.py
..._hypermedia/TestTemplateItem/testSlapOSHypermediaSkins.py
+89
-0
master/bt5/slapos_hypermedia/bt/template_action_path_list
master/bt5/slapos_hypermedia/bt/template_action_path_list
+2
-1
No files found.
master/bt5/slapos_hypermedia/ActionTemplateItem/portal_types/Software%20Instance/get_hateoas_related_hosting_subscription.xml
0 → 100644
View file @
0885ba5f
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ActionInformation"
module=
"Products.CMFCore.ActionInformation"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
categories
</string>
</key>
<value>
<tuple>
<string>
action_type/object_slap
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
category
</string>
</key>
<value>
<string>
object_slap
</string>
</value>
</item>
<item>
<key>
<string>
condition
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
icon
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
get_hateoas_related_hosting_subscription
</string>
</value>
</item>
<item>
<key>
<string>
permissions
</string>
</key>
<value>
<tuple>
<string>
View
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Action Information
</string>
</value>
</item>
<item>
<key>
<string>
priority
</string>
</key>
<value>
<float>
2.0
</float>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
getHateoasRelatedHostingSubscription
</string>
</value>
</item>
<item>
<key>
<string>
visible
</string>
</key>
<value>
<int>
1
</int>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"Expression"
module=
"Products.CMFCore.Expression"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
text
</string>
</key>
<value>
<string>
string:${object_url}/Instance_getHateoasRelatedHostingSubscription
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Instance_getHateoasRelatedHostingSubscription.xml
0 → 100644
View file @
0885ba5f
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
from zExceptions import Unauthorized\n
from AccessControl import getSecurityManager\n
if REQUEST is None:\n
raise Unauthorized\n
\n
response = REQUEST.RESPONSE\n
mime_type = \'application/hal+json\'\n
\n
if REQUEST.other[\'method\'] != "GET":\n
response.setStatus(405)\n
return ""\n
elif mime_type != context.Base_handleAcceptHeader([mime_type]):\n
response.setStatus(406)\n
return ""\n
elif context.getPortalType() not in ["Software Instance", "Slave Instance"]:\n
response.setStatus(403)\n
return ""\n
\n
if context.getSlapState() == "stop_requested":\n
state = \'stopped\'\n
elif context.getSlapState() == "start_requested":\n
state = \'started\'\n
else:\n
state = \'destroyed\'\n
\n
import json\n
result_dict = {\n
\'_links\': {\n
"self": { "href": context.Base_getRequestUrl() },\n
"index": {\n
"href": "urn:jio:get:%s/ERP5Document_getHateoas" % context.getRelativeUrl(),\n
"title": "Software Instance",\n
},\n
\'action_object_jump\': {\n
"href": "%s/ERP5Document_getHateoas" % context.getSpecialiseValue().getAbsoluteUrl(),\n
"title": "Hosting Subscription",\n
}\n
},\n
}\n
\n
response.setHeader(\'Content-Type\', mime_type)\n
return json.dumps(result_dict, indent=2)\n
</string>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
REQUEST=None
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Instance_getHateoasRelatedHostingSubscription
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_hypermedia/TestTemplateItem/testSlapOSHypermediaSkins.py
View file @
0885ba5f
...
@@ -792,6 +792,95 @@ class TestSlapOSInstance_getHateoasNews(TestSlapOSHypermediaMixin):
...
@@ -792,6 +792,95 @@ class TestSlapOSInstance_getHateoasNews(TestSlapOSHypermediaMixin):
},
},
},
indent
=
2
)))
},
indent
=
2
)))
class
TestSlapOSInstance_getHateoasRelatedHostingSubscription
(
TestSlapOSHypermediaMixin
):
def
_makeInstance
(
self
):
instance
=
self
.
portal
.
software_instance_module
\
.
template_software_instance
.
Base_createCloneDocument
(
batch_mode
=
1
)
instance
.
edit
(
title
=
self
.
generateNewSoftwareTitle
(),
reference
=
"TESTHS-%s"
%
self
.
generateNewId
(),
software_type
=
self
.
generateNewSoftwareType
(),
url_string
=
self
.
generateNewSoftwareReleaseUrl
(),
instance_xml
=
self
.
generateSafeXml
(),
sla_xml
=
self
.
generateSafeXml
(),
connection_xml
=
self
.
generateSafeXml
(),
)
self
.
tic
()
return
instance
@
changeSkin
(
'Hal'
)
def
test_getHateoasRelatedHostingSubscription_REQUEST_mandatory
(
self
):
self
.
assertRaises
(
Unauthorized
,
self
.
portal
.
Instance_getHateoasRelatedHostingSubscription
)
@
simulate
(
'Base_getRequestHeader'
,
'*args, **kwargs'
,
'return "application/vnd+bar"'
)
@
changeSkin
(
'Hal'
)
def
test_getHateoasRelatedHostingSubscription_wrong_ACCEPT
(
self
):
instance
=
self
.
_makeInstance
()
fake_request
=
do_fake_request
(
"GET"
)
result
=
instance
.
Instance_getHateoasRelatedHostingSubscription
(
REQUEST
=
fake_request
)
self
.
assertEquals
(
fake_request
.
RESPONSE
.
status
,
406
)
self
.
assertEquals
(
result
,
""
)
@
simulate
(
'Base_getRequestHeader'
,
'*args, **kwargs'
,
'return "application/hal+json"'
)
@
changeSkin
(
'Hal'
)
def
test_getHateoasRelatedHostingSubscription_bad_method
(
self
):
instance
=
self
.
_makeInstance
()
fake_request
=
do_fake_request
(
"POST"
)
result
=
instance
.
Instance_getHateoasRelatedHostingSubscription
(
REQUEST
=
fake_request
)
self
.
assertEquals
(
fake_request
.
RESPONSE
.
status
,
405
)
self
.
assertEquals
(
result
,
""
)
@
simulate
(
'Base_getRequestHeader'
,
'*args, **kwargs'
,
'return "application/hal+json"'
)
@
changeSkin
(
'Hal'
)
def
test_getHateoasRelatedHostingSubscription_not_instance_context
(
self
):
fake_request
=
do_fake_request
(
"GET"
)
result
=
self
.
portal
.
Instance_getHateoasRelatedHostingSubscription
(
REQUEST
=
fake_request
)
self
.
assertEquals
(
fake_request
.
RESPONSE
.
status
,
403
)
self
.
assertEquals
(
result
,
""
)
@
simulate
(
'Base_getRequestUrl'
,
'*args, **kwargs'
,
'return "http://example.org/bar"'
)
@
simulate
(
'Base_getRequestHeader'
,
'*args, **kwargs'
,
'return "application/hal+json"'
)
@
changeSkin
(
'Hal'
)
def
test_getHateoasRelatedHostingSubscription_result
(
self
):
subscription
=
self
.
_makeHostingSubscription
()
instance
=
self
.
_makeInstance
()
instance
.
edit
(
specialise_value
=
subscription
)
self
.
tic
()
fake_request
=
do_fake_request
(
"GET"
)
result
=
instance
.
Instance_getHateoasRelatedHostingSubscription
(
REQUEST
=
fake_request
)
self
.
assertEquals
(
fake_request
.
RESPONSE
.
status
,
200
)
self
.
assertEquals
(
fake_request
.
RESPONSE
.
getHeader
(
'Content-Type'
),
"application/hal+json"
)
self
.
assertEquals
(
json
.
loads
(
result
),
json
.
loads
(
json
.
dumps
({
'_links'
:
{
"self"
:
{
"href"
:
"http://example.org/bar"
},
"index"
:
{
"href"
:
"urn:jio:get:%s/ERP5Document_getHateoas"
%
\
instance
.
getRelativeUrl
(),
"title"
:
"Software Instance"
},
"action_object_jump"
:
{
'href'
:
"%s/ERP5Document_getHateoas"
%
subscription
.
getAbsoluteUrl
(),
'title'
:
"Hosting Subscription"
}
},
},
indent
=
2
)))
class
TestSlapOSInstance_getHateoasInformation
(
TestSlapOSHypermediaMixin
):
class
TestSlapOSInstance_getHateoasInformation
(
TestSlapOSHypermediaMixin
):
...
...
master/bt5/slapos_hypermedia/bt/template_action_path_list
View file @
0885ba5f
...
@@ -7,4 +7,5 @@ Person | get_hateoas_information
...
@@ -7,4 +7,5 @@ Person | get_hateoas_information
Person | request_hateoas_hosting_subscription
Person | request_hateoas_hosting_subscription
Software Installation | get_hateoas_information
Software Installation | get_hateoas_information
Software Instance | get_hateoas_information
Software Instance | get_hateoas_information
Software Instance | get_hateoas_news
Software Instance | get_hateoas_news
\ No newline at end of file
Software Instance | get_hateoas_related_hosting_subscription
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