def test_available__profile_must_be_installed_when_defined(self): resource = SCSSFileResource('ftw.theming.tests', 'resources/foo.scss', profile='foo.bar:default') self.assertTrue(resource.available(CONTEXT, REQUEST, ProfileInfoStub('foo.bar:default'))) self.assertFalse(resource.available(CONTEXT, REQUEST, ProfileInfoStub()))
def test_get_source(self): resource = SCSSFileResource('ftw.theming.tests', 'resources/foo.scss') self.assertMultiLineEqual( '\n'.join(('#foo {', ' display: none;', '}')), resource.get_source(CONTEXT, REQUEST)) self.assertEquals(unicode, type(resource.get_source(CONTEXT, REQUEST)), 'Source should be unicode.')
def test_get_cachekey_returns_a_value(self): # The cachekey is based on the modified date of the resource, # which changes and therefore we just test that it is positive. resource = SCSSFileResource('ftw.theming.tests', 'resources/foo.scss') self.assertTrue(resource.get_cachekey(None, None))
def test_available__request_must_match_layer_interface(self): resource = SCSSFileResource('ftw.theming.tests', 'resources/foo.scss', layer=IDefaultBrowserLayer) self.assertTrue(resource.available(CONTEXT, Stub(IDefaultBrowserLayer))) self.assertFalse(resource.available(CONTEXT, Stub()))
def test_available__context_must_match_for_interface(self): resource = SCSSFileResource('ftw.theming.tests', 'resources/foo.scss', for_=INavigationRoot) self.assertTrue(resource.available(Stub(INavigationRoot), REQUEST)) self.assertFalse(resource.available(Stub(), REQUEST))