Esempio n. 1
0
    def atom_test(self):
        # atom tag as root
        atom = createAtom()
        self.assertEqual(tostring(atom), '<feed xmlns="http://www.w3.org/2005/Atom" />')

        # atom tag as SubElement of another root element
        root = Element("myCustomTag")
        atom = createAtom(root)
        root.append(atom)
        self.assertEqual(
            tostring(root),
            '<myCustomTag xmlns:atom="http://www.w3.org/2005/Atom">\
<atom:feed /></myCustomTag>',
        )
Esempio n. 2
0
    def entry_test(self):
        atom = createAtom()
        title = createTitle(root=atom, body="testEntry")
        iid = createID(1, root=atom)
        update = createUpdated("2012-0619T21:02:00.626Z", root=atom)
        entry = createEntry(iid, title, update, root=atom)
        atom.append(entry)
        self.assertEqual(
            tostring(atom),
            '<feed xmlns="http://www.w3.org/2005/Atom">\
<entry><id>1</id><title>testEntry</title><updated>2012-0619T21:02:00.626Z</updated></entry></feed>',
        )

        root = Element("myCustomTag")
        title = createTitle(root=root, body="testEntry")
        iid = createID(1, root=root)
        update = createUpdated("2012-0619T21:02:00.626Z", root=atom)
        atom = createEntry(iid, title, update, root=root)
        root.append(atom)
        self.assertEqual(
            tostring(root),
            '<myCustomTag xmlns:atom="http://www.w3.org/2005/Atom">\
<atom:entry><atom:id>1</atom:id><atom:title>testEntry</atom:title><updated>2012-0619T21:02:00.626Z</updated>\
</atom:entry></myCustomTag>',
        )

        root = createAtomDocument(1, "atomTitle", "2012-0619T21:02:00.626Z")
        iid = createID(2, root=root)
        title = createTitle(root=root, body="testEntry")
        update = createUpdated("2012-0619T21:02:00.626Z", root=root)
        entry = createEntry(iid, title, update, root=root)
        root.append(entry)
        self.assertEqual(
            tostring(root),
            '<feed xmlns="http://www.w3.org/2005/Atom"><id>1</id>\
<title>atomTitle</title><updated>2012-0619T21:02:00.626Z</updated><entry><id>2</id>\
<title>testEntry</title><updated>2012-0619T21:02:00.626Z</updated></entry></feed>',
            "Error",
        )