Пример #1
0
    def test_subject_url(self, monkeypatch):
        from openlibrary.plugins.worksearch import code
        from openlibrary.core import models
        monkeypatch.setattr(code, "get_subject",
                            lambda key: models.Subject(key=key, name=key))

        Seed = model.Seed
        print Seed(None, "subject:foo").url
        assert Seed(None, "subject:foo").url == "/subjects/foo"
        assert Seed(None, "person:foo").url == "/subjects/person:foo"
        assert Seed(None, "place:foo").url == "/subjects/place:foo"
        assert Seed(None, "time:foo").url == "/subjects/time:foo"
Пример #2
0
 def test_url(self):
     subject = models.Subject({"key": "/subjects/love"})
     assert subject.url() == "/subjects/love"
     assert subject.url("/lists") == "/subjects/love/lists"