def test_provider_import(self):
     test_tabs = {"account_name": "cavlec", "standard_urls_input": TEST_URL2}
     members = provider.import_products("slideshare", test_tabs)
     print members
     expected = [('url', u'https://www.slideshare.net/hpiwowar/right-time-right-place-to-change-the-world'), ('url', u'http://www.slideshare.net/cavlec/week8-5557551'), ('url', u'http://www.slideshare.net/cavlec/canoe-the-open-content-rapids'), ('url', u'http://www.slideshare.net/cavlec/so-you-think-you-know-libraries'), ('url', u'http://www.slideshare.net/cavlec/what-we-organize'), ('url', u'http://www.slideshare.net/cavlec/escapar-la-carrera-de-la-reina'), ('url', u'http://www.slideshare.net/cavlec/librarians-love-data'), ('url', u'http://www.slideshare.net/cavlec/even-the-loons-are-licensed'), ('url', u'http://www.slideshare.net/cavlec/institutional-repositories-rebirth-of-the-phoenix'), ('url', u'http://www.slideshare.net/cavlec/manufacturing-serendipity-12176916'), ('url', u'http://www.slideshare.net/cavlec/canoe-the-open-content-rapids-2862487'), ('url', u'http://www.slideshare.net/cavlec/encryption-27779361'), ('url', u'http://www.slideshare.net/cavlec/who-owns-our-work-notes'), ('url', u'http://www.slideshare.net/cavlec/rdf-rda-and-other-tlas'), ('url', u'http://www.slideshare.net/cavlec/whats-driving-open-access'), ('url', u'http://www.slideshare.net/cavlec/manufacturing-serendipity'), ('url', u'http://www.slideshare.net/cavlec/i-own-copyright-so-i-pwn-you'), ('url', u'http://www.slideshare.net/cavlec/paying-forit'), ('url', u'http://www.slideshare.net/cavlec/grab-a-bucket-its-raining-data'), ('url', u'http://www.slideshare.net/cavlec/soylent-semantic-web-is-people-with-notes'), ('url', u'http://www.slideshare.net/cavlec/who-owns-our-work'), ('url', u'http://www.slideshare.net/cavlec/soylent-semanticweb-is-people'), ('url', u'http://www.slideshare.net/cavlec/open-sesame-and-other-open-movements'), ('url', u'http://www.slideshare.net/cavlec/digital-preservation-and-institutional-repositories'), ('url', u'http://www.slideshare.net/cavlec/a-successful-failure-community-requirements-gathering-for-dspace'), ('url', u'http://www.slideshare.net/cavlec/project-management-16606291'), ('url', u'http://www.slideshare.net/cavlec/databases-markup-and-regular-expressions'), ('url', u'http://www.slideshare.net/cavlec/solving-problems-with-web-20'), ('url', u'http://www.slideshare.net/cavlec/educators-together'), ('url', u'http://www.slideshare.net/cavlec/le-ir-cest-mort-vive-le-ir'), ('url', u'http://www.slideshare.net/cavlec/open-content'), ('url', u'http://www.slideshare.net/cavlec/so-are-we-winning-yet'), ('url', u'http://www.slideshare.net/cavlec/save-the-cows-data-curation-for-the-rest-of-us-1533252'), ('url', u'http://www.slideshare.net/cavlec/grab-a-bucket-its-raining-data-2134106'), ('url', u'http://www.slideshare.net/cavlec/nsa-27779364'), ('url', u'http://www.slideshare.net/cavlec/is-this-big-data-which-i-see-before-me'), ('url', u'http://www.slideshare.net/cavlec/escaping-the-red-queens-race-with-open-access'), ('url', u'http://www.slideshare.net/cavlec/research-data-and-scholarly-communication'), ('url', u'http://www.slideshare.net/cavlec/so-arewewinningyet-notes'), ('url', u'http://www.slideshare.net/cavlec/week13-5972690'), ('url', u'http://www.slideshare.net/cavlec/privacy-inlibs'), ('url', u'http://www.slideshare.net/cavlec/marc-and-bibframe-linking-libraries-and-archives'), ('url', u'http://www.slideshare.net/cavlec/frbr-and-rda'), ('url', u'http://www.slideshare.net/cavlec/the-social-journal'), ('url', u'http://www.slideshare.net/cavlec/occupy-copyright'), ('url', u'http://www.slideshare.net/cavlec/research-data-and-scholarly-communication-16366049'), ('url', u'http://www.slideshare.net/cavlec/what-youre-up-against'), ('url', u'http://www.slideshare.net/cavlec/escaping-datageddon'), ('url', u'http://www.slideshare.net/cavlec/risk-management-and-auditing'), ('url', u'http://www.slideshare.net/cavlec/the-canonically-bad-digital-humanities-proposal'), ('url', u'http://www.slideshare.net/cavlec/data-and-the-law'), ('url', u'http://www.slideshare.net/cavlec/ejournals-and-open-access'), ('url', u'http://www.slideshare.net/cavlec/preservation-and-institutional-repositories-for-the-digital-arts-and-humanities'), ('url', u'http://www.slideshare.net/cavlec/avoiding-heronway'), ('url', u'http://www.slideshare.net/cavlec/taming-the-monster-digital-preservation-planning-and-implementation-tools'), ('url', u'http://www.slideshare.net/cavlec/library-linked-data')]
     for member in expected:
         assert(member in members)
Ejemplo n.º 2
0
 def test_provider_import(self):
     tabs_input = {"account_name": "http://figshare.com/authors/schamberlain/96554", "standard_dois_input": "10.6084/m9.figshare.92393\nhttps://doi.org/10.6084/m9.figshare.865731"}
     members = provider.import_products("figshare", tabs_input)
     print members
     expected = [('doi', '10.6084/m9.figshare.92393'), ('doi', '10.6084/m9.figshare.865731'), ('doi', u'10.6084/m9.figshare.806563'), ('doi', u'10.6084/m9.figshare.806423'), ('doi', u'10.6084/m9.figshare.803123'), ('doi', u'10.6084/m9.figshare.791569'), ('doi', u'10.6084/m9.figshare.758498'), ('doi', u'10.6084/m9.figshare.757866'), ('doi', u'10.6084/m9.figshare.739343'), ('doi', u'10.6084/m9.figshare.729248'), ('doi', u'10.6084/m9.figshare.719786'), ('doi', u'10.6084/m9.figshare.669696'), ('doi', u'10.6084/m9.figshare.106915'), ('doi', u'10.6084/m9.figshare.97222'), ('doi', u'10.6084/m9.figshare.97221'), ('doi', u'10.6084/m9.figshare.97215'), ('doi', u'10.6084/m9.figshare.94296'), ('doi', u'10.6084/m9.figshare.94295'), ('doi', u'10.6084/m9.figshare.94219'), ('doi', u'10.6084/m9.figshare.94218'), ('doi', u'10.6084/m9.figshare.94217'), ('doi', u'10.6084/m9.figshare.94216'), ('doi', u'10.6084/m9.figshare.94090'), ('doi', u'10.6084/m9.figshare.94089'), ('doi', u'10.6084/m9.figshare.94030'), ('doi', u'10.6084/m9.figshare.91145'), ('doi', u'10.6084/m9.figshare.90832')]
     for member in expected:
         assert(member in members)
Ejemplo n.º 3
0
 def test_provider_import(self):
     test_tabs = {"account_name": "egonw", "standard_urls_input": "https://github.com/openphacts/BridgeDb\nhttps://github.com/total-impact/totalimpactcore"}
     members = provider.import_products("github", test_tabs)
     print members
     expected = [('url', u'https://github.com/openphacts/BridgeDb'), ('url', u'https://github.com/total-impact/totalimpactcore'), ('url', u'https://github.com/egonw/blueobelisk.debian'), ('url', u'https://github.com/egonw/ACS-Twitter-Visualization'), ('url', u'https://github.com/egonw/bioclipse.cir'), ('url', u'https://github.com/egonw/bioclipse.social'), ('url', u'https://github.com/egonw/bioclipse.sb'), ('url', u'https://github.com/egonw/acsrdf2010'), ('url', u'https://github.com/egonw/bioclipse.brunn'), ('url', u'https://github.com/egonw/5stardata.info'), ('url', u'https://github.com/egonw/biostar-central'), ('url', u'https://github.com/egonw/bioclipse.core'), ('url', u'https://github.com/egonw/bioclipse.statistics'), ('url', u'https://github.com/egonw/bioclipse.rdf'), ('url', u'https://github.com/egonw/bioclipse.wikipathways'), ('url', u'https://github.com/egonw/bioclipse.ds'), ('url', u'https://github.com/egonw/cb'), ('url', u'https://github.com/egonw/bioclipse.bridgedb'), ('url', u'https://github.com/egonw/bioclipse.opentox'), ('url', u'https://github.com/egonw/bopaper'), ('url', u'https://github.com/egonw/bioclipse.openphacts'), ('url', u'https://github.com/egonw/bioclipse.ambit'), ('url', u'https://github.com/egonw/bioclipse.cheminformatics'), ('url', u'https://github.com/egonw/AZOrange'), ('url', u'https://github.com/egonw/blueobelisk.userscript'), ('url', u'https://github.com/egonw/BridgeDb'), ('url', u'https://github.com/egonw/bioclipse.bigcatedu'), ('url', u'https://github.com/egonw/bioclipse.oscar'), ('url', u'https://github.com/egonw/bioclipse.ons'), ('url', u'https://github.com/egonw/bioclipse.experimental'), ('url', u'https://github.com/egonw/biblatex-biomedcentral'), ('url', u'https://github.com/egonw/cacm-article')]
     for member in expected:
         assert(member in members)
Ejemplo n.º 4
0
 def test_import_products(self):
     response = provider.import_products(
         "product_id_strings", {
             "product_id_strings": [
                 "123456", "HTTPS://starbucks.com", "arXiv:1305.3328",
                 "http://doi.org/10.123/ABC"
             ]
         })
     expected = [('pmid', '123456'), ('url', 'HTTPS://starbucks.com'),
                 ('arxiv', '1305.3328'), ('doi', '10.123/abc')]
     assert_equals(response, expected)
Ejemplo n.º 5
0
def importer_post(provider_name):
    # need to do these ugly deletes because import products not in dict.  fix in future!
    try:
        profile_id = request.json["profile_id"]
        del request.json["profile_id"]
    except KeyError:
        abort(405, "missing profile_id")

    try:
        analytics_credentials = request.json["analytics_credentials"]
        del request.json["analytics_credentials"]
    except KeyError:
        analytics_credentials = {}

    try:
        existing_tiids = request.json["existing_tiids"]
        del request.json["existing_tiids"]
    except KeyError:
        existing_tiids = []

    try:
        retrieved_aliases = provider_module.import_products(
            provider_name, request.json)
    except ImportError:
        abort_custom(
            404,
            "an importer for provider '{provider_name}' is not found".format(
                provider_name=provider_name))
    except ProviderItemNotFoundError:
        abort_custom(404, "item not found")
    except ProviderItemNotFoundError:
        abort_custom(404, "item not found")
    except (ProviderTimeout, ProviderServerError):
        abort_custom(503, "timeout error, might be transient")
    except ProviderError:
        abort(500, "internal error from provider")

    new_aliases = item_module.aliases_not_in_existing_tiids(
        retrieved_aliases, existing_tiids)
    tiids_aliases_map = item_module.create_tiids_from_aliases(
        profile_id, new_aliases, analytics_credentials, myredis, provider_name)
    # logger.debug(u"in provider_importer_get with {tiids_aliases_map}".format(
    #     tiids_aliases_map=tiids_aliases_map))

    products_dict = format_into_products_dict(tiids_aliases_map)

    resp = make_response(
        json.dumps({"products": products_dict}, sort_keys=True, indent=4), 200)
    return resp
Ejemplo n.º 6
0
 def test_provider_import(self):
     test_tabs = {
         "account_name":
         "egonw",
         "standard_urls_input":
         "https://github.com/openphacts/BridgeDb\nhttps://github.com/total-impact/totalimpactcore"
     }
     members = provider.import_products("github", test_tabs)
     print members
     expected = [
         ('url', u'https://github.com/openphacts/BridgeDb'),
         ('url', u'https://github.com/total-impact/totalimpactcore'),
         ('url', u'https://github.com/egonw/blueobelisk.debian'),
         ('url', u'https://github.com/egonw/ACS-Twitter-Visualization'),
         ('url', u'https://github.com/egonw/bioclipse.cir'),
         ('url', u'https://github.com/egonw/bioclipse.social'),
         ('url', u'https://github.com/egonw/bioclipse.sb'),
         ('url', u'https://github.com/egonw/acsrdf2010'),
         ('url', u'https://github.com/egonw/bioclipse.brunn'),
         ('url', u'https://github.com/egonw/5stardata.info'),
         ('url', u'https://github.com/egonw/biostar-central'),
         ('url', u'https://github.com/egonw/bioclipse.core'),
         ('url', u'https://github.com/egonw/bioclipse.statistics'),
         ('url', u'https://github.com/egonw/bioclipse.rdf'),
         ('url', u'https://github.com/egonw/bioclipse.wikipathways'),
         ('url', u'https://github.com/egonw/bioclipse.ds'),
         ('url', u'https://github.com/egonw/cb'),
         ('url', u'https://github.com/egonw/bioclipse.bridgedb'),
         ('url', u'https://github.com/egonw/bioclipse.opentox'),
         ('url', u'https://github.com/egonw/bopaper'),
         ('url', u'https://github.com/egonw/bioclipse.openphacts'),
         ('url', u'https://github.com/egonw/bioclipse.ambit'),
         ('url', u'https://github.com/egonw/bioclipse.cheminformatics'),
         ('url', u'https://github.com/egonw/AZOrange'),
         ('url', u'https://github.com/egonw/blueobelisk.userscript'),
         ('url', u'https://github.com/egonw/BridgeDb'),
         ('url', u'https://github.com/egonw/bioclipse.bigcatedu'),
         ('url', u'https://github.com/egonw/bioclipse.oscar'),
         ('url', u'https://github.com/egonw/bioclipse.ons'),
         ('url', u'https://github.com/egonw/bioclipse.experimental'),
         ('url', u'https://github.com/egonw/biblatex-biomedcentral'),
         ('url', u'https://github.com/egonw/cacm-article')
     ]
     for member in expected:
         assert (member in members)
Ejemplo n.º 7
0
def importer_post(provider_name):
    # need to do these ugly deletes because import products not in dict.  fix in future!
    try:
        profile_id = request.json["profile_id"]
        del request.json["profile_id"]
    except KeyError:
        abort(405, "missing profile_id")

    try:
        analytics_credentials = request.json["analytics_credentials"]
        del request.json["analytics_credentials"]
    except KeyError:
        analytics_credentials = {}

    try:
        existing_tiids = request.json["existing_tiids"]
        del request.json["existing_tiids"]
    except KeyError:
        existing_tiids = []

    try:
        retrieved_aliases = provider_module.import_products(provider_name, request.json)
    except ImportError:
        abort_custom(404, "an importer for provider '{provider_name}' is not found".format(
            provider_name=provider_name))        
    except ProviderItemNotFoundError:
        abort_custom(404, "item not found")
    except ProviderItemNotFoundError:
        abort_custom(404, "item not found")
    except (ProviderTimeout, ProviderServerError):
        abort_custom(503, "timeout error, might be transient")
    except ProviderError:
        abort(500, "internal error from provider")

    new_aliases = item_module.aliases_not_in_existing_tiids(retrieved_aliases, existing_tiids)
    tiids_aliases_map = item_module.create_tiids_from_aliases(profile_id, new_aliases, analytics_credentials, myredis, provider_name)
    # logger.debug(u"in provider_importer_get with {tiids_aliases_map}".format(
    #     tiids_aliases_map=tiids_aliases_map))

    products_dict = format_into_products_dict(tiids_aliases_map)

    resp = make_response(json.dumps({"products": products_dict}, sort_keys=True, indent=4), 200)
    return resp
Ejemplo n.º 8
0
 def test_provider_import(self):
     tabs_input = {
         "account_name":
         "http://figshare.com/authors/schamberlain/96554",
         "standard_dois_input":
         "10.6084/m9.figshare.92393\nhttps://doi.org/10.6084/m9.figshare.865731"
     }
     members = provider.import_products("figshare", tabs_input)
     print members
     expected = [('doi', '10.6084/m9.figshare.92393'),
                 ('doi', '10.6084/m9.figshare.865731'),
                 ('doi', u'10.6084/m9.figshare.806563'),
                 ('doi', u'10.6084/m9.figshare.806423'),
                 ('doi', u'10.6084/m9.figshare.803123'),
                 ('doi', u'10.6084/m9.figshare.791569'),
                 ('doi', u'10.6084/m9.figshare.758498'),
                 ('doi', u'10.6084/m9.figshare.757866'),
                 ('doi', u'10.6084/m9.figshare.739343'),
                 ('doi', u'10.6084/m9.figshare.729248'),
                 ('doi', u'10.6084/m9.figshare.719786'),
                 ('doi', u'10.6084/m9.figshare.669696'),
                 ('doi', u'10.6084/m9.figshare.106915'),
                 ('doi', u'10.6084/m9.figshare.97222'),
                 ('doi', u'10.6084/m9.figshare.97221'),
                 ('doi', u'10.6084/m9.figshare.97215'),
                 ('doi', u'10.6084/m9.figshare.94296'),
                 ('doi', u'10.6084/m9.figshare.94295'),
                 ('doi', u'10.6084/m9.figshare.94219'),
                 ('doi', u'10.6084/m9.figshare.94218'),
                 ('doi', u'10.6084/m9.figshare.94217'),
                 ('doi', u'10.6084/m9.figshare.94216'),
                 ('doi', u'10.6084/m9.figshare.94090'),
                 ('doi', u'10.6084/m9.figshare.94089'),
                 ('doi', u'10.6084/m9.figshare.94030'),
                 ('doi', u'10.6084/m9.figshare.91145'),
                 ('doi', u'10.6084/m9.figshare.90832')]
     for member in expected:
         assert (member in members)
Ejemplo n.º 9
0
 def test_import_products_bad_providername(self):
     response = provider.import_products("nonexistant", {})
     expected = []
     assert_equals(response, expected)
Ejemplo n.º 10
0
 def test_import_products(self):
     response = provider.import_products("product_id_strings", 
             {"product_id_strings": ["123456", "HTTPS://starbucks.com", "arXiv:1305.3328", "http://doi.org/10.123/ABC"]})
     expected = [('pmid', '123456'), ('url', 'HTTPS://starbucks.com'), ('arxiv', '1305.3328'), ('doi', '10.123/abc')]
     assert_equals(response, expected)
Ejemplo n.º 11
0
 def test_import_products_bad_providername(self):
     response = provider.import_products("nonexistant", {})
     expected = []
     assert_equals(response, expected)