示例#1
0
    def test_set_none(self):

        from cocktail.html.element import Element

        e = Element()
        e.set_meta("desc", "foo")

        # Setting a meta attribute to None removes it from its element
        e.set_meta("desc", None)
        self.assertFalse("id" in e.meta)
示例#2
0
    def test_list(self):

        from cocktail.html.element import Element

        # An element starts with no meta attributes
        e = Element()
        self.assertEqual(e.meta, {})

        # Meta attributes set on the element show on its 'meta' collection
        e.set_meta("desc", "this is a test element")
        e.set_meta("keywords", "foo bar")
        self.assertEqual(e.meta, {
            "desc": "this is a test element",
            "keywords": "foo bar"
        })
示例#3
0
    def test_get_set(self):

        from cocktail.html.element import Element
        e = Element()

        # Meta attributes can be set and read
        e.set_meta("desc", "this is a test element")
        e.set_meta("keywords", "foo bar")
        self.assertEqual(e.get_meta("desc"), "this is a test element")
        self.assertEqual(e.get_meta("keywords"), "foo bar")

        # Meta attributes can be changed
        e.set_meta("keywords", "sprunge")
        self.assertEqual(e.get_meta("keywords"), "sprunge")
示例#4
0
 def add_resources(event):
     child = Element()
     child.set_meta("foo", "bar")
     e.append(child)