コード例 #1
0
    def test_extract_link(self):
        no_rel = AtomFeed.E.link(href="http://foo/")
        eq_(None, OPDSImporter.extract_link(no_rel))

        no_href = AtomFeed.E.link(href="", rel="foo")
        eq_(None, OPDSImporter.extract_link(no_href))

        good = AtomFeed.E.link(href="http://foo", rel="bar")
        link = OPDSImporter.extract_link(good)
        eq_("http://foo", link.href)
        eq_("bar", link.rel)

        relative = AtomFeed.E.link(href="/foo/bar", rel="self")
        link = OPDSImporter.extract_link(relative, "http://server")
        eq_("http://server/foo/bar", link.href)
コード例 #2
0
    def test_extract_link_rights_uri(self):

        # Most of the time, a link's rights URI is inherited from the entry.
        entry_rights = RightsStatus.PUBLIC_DOMAIN_USA

        link_tag = AtomFeed.E.link(href="http://foo", rel="bar")
        link = OPDSImporter.extract_link(link_tag,
                                         entry_rights_uri=entry_rights)
        eq_(RightsStatus.PUBLIC_DOMAIN_USA, link.rights_uri)

        # But a dcterms:rights tag beneath the link can override this.
        rights_attr = "{%s}rights" % AtomFeed.DCTERMS_NS
        link_tag.attrib[rights_attr] = RightsStatus.IN_COPYRIGHT
        link = OPDSImporter.extract_link(link_tag,
                                         entry_rights_uri=entry_rights)
        eq_(RightsStatus.IN_COPYRIGHT, link.rights_uri)
コード例 #3
0
    def test_extract_link(self):
        E = builder.ElementMaker()
        no_rel = E.link(href="http://foo/")
        eq_(None, OPDSImporter.extract_link(no_rel))

        no_href = E.link(href="", rel="foo")
        eq_(None, OPDSImporter.extract_link(no_href))

        good = E.link(href="http://foo", rel="bar")
        link = OPDSImporter.extract_link(good)
        eq_("http://foo", link.href)
        eq_("bar", link.rel)

        relative = E.link(href="/foo/bar", rel="self")
        link = OPDSImporter.extract_link(relative, "http://server")
        eq_("http://server/foo/bar", link.href)