Esempio n. 1
0
 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())
Esempio n. 2
0
 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())
Esempio n. 3
0
 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)
Esempio n. 4
0
    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)
Esempio n. 5
0
    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)
Esempio n. 6
0
 def test_does_not_add_duplicate_stylesheets(self):
     stylesheets = StyleSheets()
     stylesheets.add(StyleSheet('/foo.css'))
     stylesheets.add(StyleSheet('/foo.css'))
     assert_length(1, stylesheets)
Esempio n. 7
0
 def test_can_multiple_stylesheets(self):
     scripts = StyleSheets()
     scripts.add_all(StyleSheet('/foo.css'), StyleSheet('/bar.css'))
     assert_length(2, scripts)
Esempio n. 8
0
 def test_can_add_a_stylesheet(self):
     stylesheets = StyleSheets()
     stylesheets.add(StyleSheet('/foo.css'))
     assert_length(1, stylesheets)
Esempio n. 9
0
 def test_does_not_add_duplicate_stylesheets(self):
     stylesheets = StyleSheets()
     stylesheets.add(StyleSheet('/foo.css'))
     stylesheets.add(StyleSheet('/foo.css'))
     assert_length(1, stylesheets)
Esempio n. 10
0
 def test_can_add_stylesheets_during_instantiation(self):
     stylesheets = StyleSheets(StyleSheet('/foo.css'),
                               StyleSheet('/bar.css'))
     assert_length(2, stylesheets)
Esempio n. 11
0
 def test_can_multiple_stylesheets(self):
     scripts = StyleSheets()
     scripts.add_all(StyleSheet('/foo.css'), StyleSheet('/bar.css'))
     assert_length(2, scripts)
Esempio n. 12
0
 def test_can_add_a_stylesheet(self):
     stylesheets = StyleSheets()
     stylesheets.add(StyleSheet('/foo.css'))
     assert_length(1, stylesheets)