def test_can_render_markup_for_all_stylesheets(self): foo_script = StyleSheet('/foo.css') bar_script = StyleSheet('/bar.css') stylesheets = StyleSheets() stylesheets.add(foo_script) stylesheets.add(bar_script) assert_equals(unicode(foo_script)+unicode(bar_script), stylesheets.render())
def test_can_replace_stylesheet_with_key(self): foo_script = StyleSheet('/foo.css', key='foo') bar_script = StyleSheet('/bar.css', key='foo') stylesheets = StyleSheets() stylesheets.add(foo_script) stylesheets.replace_stylesheet_with_key(bar_script) assert_length(1, stylesheets) assert_contains(bar_script, stylesheets.stylesheets)
def __before__(self, *args, **kwargs): """This method is called before your action is. It should be used for setting up variables/objects, restricting access to other actions, or other tasks which should be executed before the action is called. NOTE: If this method is wrapped in an ActionProtector, all methods of the class will be protected it. See :meth:`__init__`. """ registry = request.environ['paste.registry'] setup_global_translator(registry=registry) response.scripts = Scripts() response.stylesheets = StyleSheets() response.feed_links = [] response.facebook = None response.warnings = [] request.perm = request.environ['mediadrop.perm'] action_method = getattr(self, kwargs['action'], None) # The expose decorator sets the exposed attribute on controller # actions. If the method does not exist or is not exposed, raise # an HTTPNotFound exception. if not getattr(action_method, 'exposed', False): abort(status_code=404)
def test_does_not_add_duplicate_stylesheets(self): stylesheets = StyleSheets() stylesheets.add(StyleSheet('/foo.css')) stylesheets.add(StyleSheet('/foo.css')) assert_length(1, stylesheets)
def test_can_multiple_stylesheets(self): scripts = StyleSheets() scripts.add_all(StyleSheet('/foo.css'), StyleSheet('/bar.css')) assert_length(2, scripts)
def test_can_add_a_stylesheet(self): stylesheets = StyleSheets() stylesheets.add(StyleSheet('/foo.css')) assert_length(1, stylesheets)
def test_can_add_stylesheets_during_instantiation(self): stylesheets = StyleSheets(StyleSheet('/foo.css'), StyleSheet('/bar.css')) assert_length(2, stylesheets)