예제 #1
0
    def test_duplicates_list(self):
        item_docs = [
            {"_id": "a1", "last_modified": "now",
                "aliases": {"doi":["doi.org/aaa"], "url":["111", "def.com"]}}
            ,{"_id": "b2", "last_modified": "now",
                "aliases": {"doi":["doi.org/222"]}}
            ,{"_id": "c2", "last_modified": "now",
                "aliases": {"doi":["doi.org/222"]}}
            ,{"_id": "d2", "last_modified": "now",
                "aliases": {"doi":["doi.org/222"], "url":["foo"]}}
            ,{"_id": "e1",  "last_modified": "now",
                "aliases": {"url":["111"]}}
            ,{"_id": "f3",  "last_modified": "now",
                "aliases": {"doi":["333"], "url":["333"]}}
            ,{"_id": "g4",  "last_modified": "now",
                "aliases": {
                    "biblio": [{"title": "my paper", "authors": "smith"}]
                }}
            ,{"_id": "h4",  "last_modified": "now",
                "aliases": {
                    "biblio": [{"title": "My paper", "authors": "Smith"}]
                }}
            ]

        item_objs = [item_module.create_objects_from_item_doc(item_doc) for item_doc in item_docs]
        item_objs[-1].biblios[0].provider = "user_provided"
        tiids = [item.tiid for item in item_objs]

        response = item_module.build_duplicates_list(tiids)
        print response
        expected = [[{'tiid': u'a1', 'has_user_provided_biblio': False}, {'tiid': u'e1', 'has_user_provided_biblio': False}], [{'tiid': u'b2', 'has_user_provided_biblio': False}, {'tiid': u'c2', 'has_user_provided_biblio': False}, {'tiid': u'd2', 'has_user_provided_biblio': False}], [{'tiid': u'f3', 'has_user_provided_biblio': False}], [{'tiid': u'g4', 'has_user_provided_biblio': False}, {'tiid': u'h4', 'has_user_provided_biblio': True}]]
        assert_equals(response, expected)
예제 #2
0
def products_duplicates_post():
    # logger.debug(u"in products_duplicates_post with tiids")
    tiids = request.json["tiids"]
    duplicates_list = item_module.build_duplicates_list(tiids)
    resp = make_response(
        json.dumps({"duplicates_list": duplicates_list},
                   sort_keys=True,
                   indent=4), 200)
    return resp
예제 #3
0
def products_duplicates_post():
    # logger.debug(u"in products_duplicates_post with tiids")
    tiids = request.json["tiids"]
    duplicates_list = item_module.build_duplicates_list(tiids)
    resp = make_response(json.dumps({"duplicates_list": duplicates_list}, sort_keys=True, indent=4), 200)   
    return resp