def test_set_value_of_the_attribute(self):
     self.component = ComponentHtml('x', 'y', a='b')
     self.component.set('a', 'c')
     self.assertEquals('c', self.component.get('a'))
 def test_create_tag_without_content_and_without_attributes(self):
     self.assertEquals('<x></x>', ComponentHtml.tag('x', ''))
 def test_create_tag_with_content_and_with_attributes(self):
     self.component = ComponentHtml('x', 'y', a='b')
     self.assertEquals('<x a="b">y</x>', self.component.as_html())
     self.component = ComponentHtml('x', 'y', a='b', c='d')
     self.assertEquals('<x a="b" c="d">y</x>', self.component.as_html())
 def test_get_return_value_of_a_inexistent_attribute_must_return_None(self):
     self.component = ComponentHtml('x', 'y')
     self.assertEquals(None, self.component.get('a'))
 def test_create_tag_with_content_and_without_attributes(self):
     self.component = ComponentHtml('x', 'y')
     self.assertEquals('<x>y</x>', self.component.as_html())
class ComponentHtmlInstanceTests(TestCase):
    
    def test_create_tag_without_content_and_without_attributes(self):
        self.component = ComponentHtml('x')
        self.assertEquals('<x></x>', self.component.as_html())
    
    def test_create_tag_with_content_and_without_attributes(self):
        self.component = ComponentHtml('x', 'y')
        self.assertEquals('<x>y</x>', self.component.as_html())
    
    def test_create_tag_without_content_and_with_attributes(self):
        self.component = ComponentHtml('x', '', a='b')
        self.assertEquals('<x a="b"></x>', self.component.as_html())
        self.component = ComponentHtml('x', '', a='b', c='d')
        self.assertEquals('<x a="b" c="d"></x>', self.component.as_html())
    
    def test_create_tag_with_content_and_with_attributes(self):
        self.component = ComponentHtml('x', 'y', a='b')
        self.assertEquals('<x a="b">y</x>', self.component.as_html())
        self.component = ComponentHtml('x', 'y', a='b', c='d')
        self.assertEquals('<x a="b" c="d">y</x>', self.component.as_html())
        
    def test_get_return_value_of_the_attribute(self):
        self.component = ComponentHtml('x', 'y', a='b')
        self.assertEquals('b', self.component.get('a'))
        
    def test_get_return_value_of_a_inexistent_attribute_must_return_None(self):
        self.component = ComponentHtml('x', 'y')
        self.assertEquals(None, self.component.get('a'))
        
    def test_set_value_of_the_attribute(self):
        self.component = ComponentHtml('x', 'y', a='b')
        self.component.set('a', 'c')
        self.assertEquals('c', self.component.get('a'))
 def test_creation_ignore_null_attributes(self):
     self.assertEquals('<x></x>', ComponentHtml.tag('x', '', a=None))
 def test_clazz_attribute_is_converted_to_class_attribute(self):
     self.assertEquals('<x class="b">y</x>', ComponentHtml.tag('x', 'y', clazz='b'))
 def test_create_tag_without_content_and_with_attributes(self):
     self.assertEquals('<x a="b"></x>', ComponentHtml.tag('x', '', a='b'))
     self.assertEquals('<x a="b" c="d"></x>', ComponentHtml.tag('x', '', a='b', c='d'))