slapos_hypermedia: use ERP5Site_reindexSkinList and (more) changeSkin in tests.

parent 926a0b4e
...@@ -46,6 +46,11 @@ class TestSlapOSHypermediaPersonScenario(testSlapOSMixin): ...@@ -46,6 +46,11 @@ class TestSlapOSHypermediaPersonScenario(testSlapOSMixin):
def test(self): def test(self):
erp5_person = self._makeUser() erp5_person = self._makeUser()
self.tic()
self.portal.changeSkin('Hal')
self.portal.ERP5Site_reindexSkinList()
self.tic()
authorization = 'Basic %s' % base64.b64encode( authorization = 'Basic %s' % base64.b64encode(
"%s:%s" % (erp5_person.getReference(), erp5_person.getReference())) "%s:%s" % (erp5_person.getReference(), erp5_person.getReference()))
content_type = "application/hal+json" content_type = "application/hal+json"
...@@ -406,6 +411,9 @@ class TestSlapOSHypermediaInstanceScenario(testSlapOSMixin): ...@@ -406,6 +411,9 @@ class TestSlapOSHypermediaInstanceScenario(testSlapOSMixin):
def test(self): def test(self):
self._makeTree() self._makeTree()
instance = self.software_instance instance = self.software_instance
self.portal.changeSkin('Hal')
self.portal.ERP5Site_reindexSkinList()
self.tic()
remote_user = instance.getReference() remote_user = instance.getReference()
content_type = "application/hal+json" content_type = "application/hal+json"
...@@ -615,3 +623,4 @@ class TestSlapOSHypermediaInstanceScenario(testSlapOSMixin): ...@@ -615,3 +623,4 @@ class TestSlapOSHypermediaInstanceScenario(testSlapOSMixin):
self.assertEquals(response.status, 200) self.assertEquals(response.status, 200)
self.assertEquals(response.getheader('Content-Type'), content_type) self.assertEquals(response.getheader('Content-Type'), content_type)
instance_hal = json.loads(response.read()) instance_hal = json.loads(response.read())
...@@ -80,6 +80,7 @@ class ERP5HALJSONStyleSkinsMixin(ERP5TypeTestCase): ...@@ -80,6 +80,7 @@ class ERP5HALJSONStyleSkinsMixin(ERP5TypeTestCase):
class TestBase_getRequestHeader(ERP5HALJSONStyleSkinsMixin): class TestBase_getRequestHeader(ERP5HALJSONStyleSkinsMixin):
def test_getRequestHeader_REQUEST_disallowed(self): def test_getRequestHeader_REQUEST_disallowed(self):
self.changeSkin('Hal')
self.assertRaises( self.assertRaises(
Unauthorized, Unauthorized,
self.portal.Base_getRequestHeader, self.portal.Base_getRequestHeader,
...@@ -87,12 +88,14 @@ class TestBase_getRequestHeader(ERP5HALJSONStyleSkinsMixin): ...@@ -87,12 +88,14 @@ class TestBase_getRequestHeader(ERP5HALJSONStyleSkinsMixin):
REQUEST={}) REQUEST={})
def test_getRequestHeader_key_error(self): def test_getRequestHeader_key_error(self):
self.changeSkin('Hal')
self.assertEquals( self.assertEquals(
self.portal.Base_getRequestHeader('foo'), self.portal.Base_getRequestHeader('foo'),
None None
) )
def test_getRequestHeader_default_value(self): def test_getRequestHeader_default_value(self):
self.changeSkin('Hal')
self.assertEquals( self.assertEquals(
self.portal.Base_getRequestHeader('foo', default='bar'), self.portal.Base_getRequestHeader('foo', default='bar'),
'bar' 'bar'
...@@ -105,6 +108,7 @@ class TestBase_getRequestHeader(ERP5HALJSONStyleSkinsMixin): ...@@ -105,6 +108,7 @@ class TestBase_getRequestHeader(ERP5HALJSONStyleSkinsMixin):
# XXX to be migrated to erp5_hal_json_style bt # XXX to be migrated to erp5_hal_json_style bt
class TestBase_getRequestUrl(ERP5HALJSONStyleSkinsMixin): class TestBase_getRequestUrl(ERP5HALJSONStyleSkinsMixin):
def test_getRequestUrl_REQUEST_disallowed(self): def test_getRequestUrl_REQUEST_disallowed(self):
self.changeSkin('Hal')
self.assertRaises( self.assertRaises(
Unauthorized, Unauthorized,
self.portal.Base_getRequestUrl, self.portal.Base_getRequestUrl,
...@@ -116,6 +120,7 @@ class TestBase_getRequestUrl(ERP5HALJSONStyleSkinsMixin): ...@@ -116,6 +120,7 @@ class TestBase_getRequestUrl(ERP5HALJSONStyleSkinsMixin):
class TestBase_getRequestBody(ERP5HALJSONStyleSkinsMixin): class TestBase_getRequestBody(ERP5HALJSONStyleSkinsMixin):
def test_getRequestBody_REQUEST_disallowed(self): def test_getRequestBody_REQUEST_disallowed(self):
self.changeSkin('Hal')
self.assertRaises( self.assertRaises(
Unauthorized, Unauthorized,
self.portal.Base_getRequestBody, self.portal.Base_getRequestBody,
...@@ -127,6 +132,7 @@ class TestBase_getRequestBody(ERP5HALJSONStyleSkinsMixin): ...@@ -127,6 +132,7 @@ class TestBase_getRequestBody(ERP5HALJSONStyleSkinsMixin):
class TestBase_handleAcceptHeader(ERP5HALJSONStyleSkinsMixin): class TestBase_handleAcceptHeader(ERP5HALJSONStyleSkinsMixin):
def test_handleAcceptHeader_REQUEST_disallowed(self): def test_handleAcceptHeader_REQUEST_disallowed(self):
self.changeSkin('Hal')
self.assertRaises( self.assertRaises(
Unauthorized, Unauthorized,
self.portal.Base_handleAcceptHeader, self.portal.Base_handleAcceptHeader,
...@@ -136,6 +142,7 @@ class TestBase_handleAcceptHeader(ERP5HALJSONStyleSkinsMixin): ...@@ -136,6 +142,7 @@ class TestBase_handleAcceptHeader(ERP5HALJSONStyleSkinsMixin):
@simulate('Base_getRequestHeader', '*args, **kwargs', 'return "*/*"') @simulate('Base_getRequestHeader', '*args, **kwargs', 'return "*/*"')
@changeSkin('Hal') @changeSkin('Hal')
def test_handleAcceptHeader_star_accept(self): def test_handleAcceptHeader_star_accept(self):
self.changeSkin('Hal')
self.assertEquals( self.assertEquals(
self.portal.Base_handleAcceptHeader(['application/vnd+test', self.portal.Base_handleAcceptHeader(['application/vnd+test',
'application/vnd+test2']), 'application/vnd+test2']),
...@@ -146,6 +153,7 @@ class TestBase_handleAcceptHeader(ERP5HALJSONStyleSkinsMixin): ...@@ -146,6 +153,7 @@ class TestBase_handleAcceptHeader(ERP5HALJSONStyleSkinsMixin):
'return "application/vnd+2test"') 'return "application/vnd+2test"')
@changeSkin('Hal') @changeSkin('Hal')
def test_handleAcceptHeader_matching_type(self): def test_handleAcceptHeader_matching_type(self):
self.changeSkin('Hal')
self.assertEquals( self.assertEquals(
self.portal.Base_handleAcceptHeader(['application/vnd+test', self.portal.Base_handleAcceptHeader(['application/vnd+test',
'application/vnd+2test']), 'application/vnd+2test']),
...@@ -156,6 +164,7 @@ class TestBase_handleAcceptHeader(ERP5HALJSONStyleSkinsMixin): ...@@ -156,6 +164,7 @@ class TestBase_handleAcceptHeader(ERP5HALJSONStyleSkinsMixin):
'return "application/vnd+2test"') 'return "application/vnd+2test"')
@changeSkin('Hal') @changeSkin('Hal')
def test_handleAcceptHeader_non_matching_type(self): def test_handleAcceptHeader_non_matching_type(self):
self.changeSkin('Hal')
self.assertEquals( self.assertEquals(
self.portal.Base_handleAcceptHeader(['application/vnd+test']), self.portal.Base_handleAcceptHeader(['application/vnd+test']),
None None
...@@ -1166,3 +1175,4 @@ class TestSlapOSSoftwareInstallation_getHateoasInformation(TestSlapOSHypermediaM ...@@ -1166,3 +1175,4 @@ class TestSlapOSSoftwareInstallation_getHateoasInformation(TestSlapOSHypermediaM
}, },
}, },
}, indent=2))) }, indent=2)))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment