def test_03_name_and_version(self): """ Take an example supported article and check just the handler fields """ record = {} record['bibjson'] = {} record['provider'] = {} record['provider']['url'] = ['http://chi.sagepub.com/content/9/3/179'] record = models.MessageObject(record=record) sage = SagePlugin() sage.license_detect(record) record = record.record # just barebones checks to make sure the license and provenance objects # exist in the first place so the handler fields can be checked assert record['bibjson'].has_key('license') assert record['bibjson']['license'] assert 'provenance' in record['bibjson']['license'][-1] assert 'handler' in record['bibjson']['license'][-1]['provenance'] assert record['bibjson']['license'][-1]['provenance']['handler'] == 'sage' assert record['bibjson']['license'][-1]['provenance']['handler_version'] == '0.1'
def test_01_sage_supports_success(self): sage = SagePlugin() test_urls = ["http://chi.sagepub.com/content/9/3/179", "http://ehq.sagepub.com/content/43/2/205", "https://ehq.sagepub.com/jsafkjsaf"] for url in test_urls: assert sage.supports({"url" : [url]})
def test_04_sage_standard_OA_license_example1(self): record = {} record['bibjson'] = {} record['provider'] = {} record['provider']['url'] = ['http://ehq.sagepub.com/content/43/2/205'] record = models.MessageObject(record=record) sage = SagePlugin() sage.license_detect(record) record = record.record # check if all the important keys were created assert record['bibjson'].has_key('license') assert record['bibjson']['license'] # NB: some examples may fail the 'url' test since the Open Definition # data we're using as the basis for our licenses dictionary does not # have 'url' for all licenses. Fix by modifying licenses.py - add the data. assert all (key in record['bibjson']['license'][-1] for key in keys_in_license) assert all (key in record['bibjson']['license'][-1]['provenance'] for key in keys_in_provenance) # some content checks now assert record['bibjson']['license'][-1]['type'] == 'cc-by' assert record['bibjson']['license'][-1]['version'] == '3.0' assert 'id' not in record['bibjson']['license'][-1] # should not have "id" - due to bibserver assert not record['bibjson']['license'][-1]['jurisdiction'] assert record['bibjson']['license'][-1]['open_access'] assert record['bibjson']['license'][-1]['BY'] assert not record['bibjson']['license'][-1]['NC'] assert not record['bibjson']['license'][-1]['SA'] assert not record['bibjson']['license'][-1]['ND'] # In this case we also expect the Sage plugin to overwrite the ['license']['url'] # property with a more specific one from the license statement. assert record['bibjson']['license'][-1]['url'] == 'http://creativecommons.org/licenses/by/3.0/' assert record['bibjson']['license'][-1]['provenance']['agent'] == config.agent assert record['bibjson']['license'][-1]['provenance']['source'] == record['provider']['url'][0] assert record['bibjson']['license'][-1]['provenance']['date'] assert record['bibjson']['license'][-1]['provenance']['category'] == 'page_scrape' assert record['bibjson']['license'][-1]['provenance']['description'] == 'License decided by scraping the resource at ' + record['provider']['url'][0] + ' and looking for the following license statement: "' \ + 'This article is distributed under the terms of the Creative Commons Attribution 3.0 License (http://www.creativecommons.org/licenses/by/3.0/) which permits any use, reproduction and distribution of the work without further permission provided the original work is attributed as specified".'
def test_02_sage_supports_fail(self): sage = SagePlugin() test_urls = ["http://www.plosone.org/", "www.biomedcentral.com", "askjdfsakjdhfsa"] for url in test_urls: assert not sage.supports({"url" : [url]})