def test_get_by_uri(self): # Make sure that only the document with the given uri is retrieved d = Document({ "id": "1", "title": "document1", "link": [peerj["html"], peerj["pdf"]] }) d.save() d = Document({ "id": "2", "title": "document2", "link": [ { "href": "http://nature.com/123/", "type": "text/html" } ], }) d.save() d = Document({ "id": "3", "title": "document3", "link": [peerj["doc"]] }) d.save() doc = Document.get_by_uri("https://peerj.com/articles/53/") assert doc assert_equal(doc['title'], "document1")
def test_get_by_uri(self): # create 3 documents and make sure get_by_uri works properly d = Document({ "id": "1", "title": "document1", "link": [ { "href": "https://peerj.com/articles/53/", "type": "text/html" }, { "href": "https://peerj.com/articles/53.pdf", "type": "application/pdf" }, ], }) d.save() d = Document({ "id": "2", "title": "document2", "link": [ { "href": "https://peerj.com/articles/53/", "type": "text/html" }, { "href": "https://peerj.com/articles/53.pdf", "type": "application/pdf" }, ], }) d.save() d = Document({ "id": "3", "title": "document3", "link": [{ "href": "http://nature.com/123/", "type": "text/html" }], }) d.save() doc = Document.get_by_uri("https://peerj.com/articles/53/") assert doc assert_equal(doc['title'], "document1")
def test_get_by_uri(self): # create 3 documents and make sure get_by_uri works properly d = Document({ "id": "1", "title": "document1", "link": [ { "href": "https://peerj.com/articles/53/", "type": "text/html" }, { "href": "https://peerj.com/articles/53.pdf", "type": "application/pdf" }, ], }) d.save() d = Document({ "id": "2", "title": "document2", "link": [ { "href": "https://peerj.com/articles/53/", "type": "text/html" }, { "href": "https://peerj.com/articles/53.pdf", "type": "application/pdf" }, ], }) d.save() d = Document({ "id": "3", "title": "document3", "link": [ { "href": "http://nature.com/123/", "type": "text/html" } ], }) d.save() doc = Document.get_by_uri("https://peerj.com/articles/53/") assert doc assert_equal(doc['title'], "document1")
def test_merge_links(self): d = Document({ "id": "1", "title": "document", "link": [ { "href": "https://peerj.com/articles/53/", "type": "text/html" }, { "href": "https://peerj.com/articles/53.pdf", "type": "application/pdf" } ], }) d.save() d = Document.fetch(1) assert d assert_equal(len(d['link']), 2) d.merge_links([ { "href": "https://peerj.com/articles/53/", "type": "text/html" }, { "href": "http://peerj.com/articles/53.doc", "type": "application/vnd.ms-word.document" } ]) d.save() assert_equal(len(d['link']), 3) d = Document.fetch(1) assert d assert_equal(len(d['link']), 3) doc = Document.get_by_uri("https://peerj.com/articles/53/") assert doc assert_equal(len(doc['link']), 3)
def test_merge_links(self): d = Document({ "id": "1", "title": "document", "link": [peerj["html"], peerj["pdf"]] }) d.save() d = Document.fetch(1) assert d assert_equal(len(d['link']), 2) d.merge_links([peerj["html"], peerj["doc"]]) d.save() assert_equal(len(d['link']), 3) d = Document.fetch(1) assert d assert_equal(len(d['link']), 3) doc = Document.get_by_uri("https://peerj.com/articles/53/") assert doc assert_equal(len(doc['link']), 3)
def test_merge_links(self): d = Document({ "id": "1", "title": "document", "link": [{ "href": "https://peerj.com/articles/53/", "type": "text/html" }, { "href": "https://peerj.com/articles/53.pdf", "type": "application/pdf" }], }) d.save() d = Document.fetch(1) assert d assert_equal(len(d['link']), 2) d.merge_links([{ "href": "https://peerj.com/articles/53/", "type": "text/html" }, { "href": "http://peerj.com/articles/53.doc", "type": "application/vnd.ms-word.document" }]) d.save() assert_equal(len(d['link']), 3) d = Document.fetch(1) assert d assert_equal(len(d['link']), 3) doc = Document.get_by_uri("https://peerj.com/articles/53/") assert doc assert_equal(len(doc['link']), 3)
def test_get_by_uri_not_found(self): assert Document.get_by_uri("bogus") is None