def test_create__with_content_type(self): """Testing create instance with content type.""" name = value = content_type = 'Test' label = entities.Label( name=name, value=value, content_type=content_type ) self.assertEqual(label.content_type, content_type)
def test_create(self): """Testing create instance.""" name = value = 'Test' label = entities.Label(name=name, value=value) self.assertIsInstance(label, entities.Label) self.assertEqual(label.name, name) self.assertEqual(label.value, value)
def test_method_to_node(self): """Testing method to_node.""" name = value = content_type = 'Test' node = entities.Label( name=name, value=value, content_type=content_type ).to_node() self.assertEqual(node.attrib['Name'], name) self.assertEqual(node.attrib['Type'], content_type) self.assertEqual(node.text, value)
def test_method_to_xml(self): """Testing method to_xml.""" name = value = content_type = 'Test' label = entities.Label( name=name, value=value, content_type=content_type ) self.assertEqual( label.to_xml().decode('ascii'), ( '<Label Name="{0}" Type="{0}">' '<![CDATA[{0}]]></Label>' ).format(name) )
def test_method_to_node(self): """Testing method to_node.""" name = value = weight = icon_url = 'Test' field = entities.Field(name=name, value=value) label = entities.Label(name=name, value=value) node = entities.Entity( name=name, value=value, weight=weight, icon_url=icon_url, fields=[field], labels=[label] ).to_node() self.assertEqual(node.attrib['Type'], name) self.assertEqual(node.find('Weight').text, weight) self.assertEqual(node.find('IconURL').text, icon_url) self.assertEqual(node.find('Value').text, value) self.assertIn( field.value, node.find('AdditionalFields').getchildren()[0].text ) self.assertIn( label.value, node.find('DisplayInformation').getchildren()[0].text )