def test_make_link_node(self): rel, href, value = self.links[0] r = ioc_et.make_link_node(rel, value, href) self.assertEqual(r.tag, 'link') self.assertEqual(r.attrib.get('rel'), rel) self.assertEqual(r.attrib.get('href'), href) self.assertEqual(r.text, value) rel2, href2, value2 = self.links[1] r2 = ioc_et.make_link_node(rel2, value2, href2) self.assertEqual(r2.tag, 'link') self.assertEqual(r2.attrib.get('rel'), rel2) self.assertEqual(r2.attrib.get('href'), href2) self.assertEqual(r2.text, value2)
def add_link(self, rel, value, href=None): """ Add a Link metadata element to the IOC. :param rel: Type of the link. :param value: Value of the link text. :param href: A href value assigned to the link. :return: True """ links_node = self.metadata.find('links') if links_node is None: links_node = ioc_et.make_links_node() self.metadata.append(links_node) link_node = ioc_et.make_link_node(rel, value, href) links_node.append(link_node) return True