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

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