def test_valid_registration_with_exclude_iriset(self): """ A succesfull assertion using an iriset """ # iri set claims that http://example.com/foo/* is registered except for # the document hosted at http://example.com/foo/bar/ triples = { "redirects": {}, 'subjects': [ 'http://example.com', 'http://example.com/foo/blog/', 'http://example.com/foo/bar/', 'http://testing.com', 'http://testing.com/work/', 'foo_iriset' ], 'triples': { 'http://example.com/foo/blog/': { SIOC('has_owner'): ['http://testing.com'], CC('license'): ['http://creativecommons.org/licenses/by/3.0/'], }, 'http://example.com/foo/bar/': { SIOC('has_owner'): ['http://testing.com'], CC('license'): ['http://creativecommons.org/licenses/by/3.0/'], }, 'http://testing.com': { SIOC('owner_of'): ['http://testing.com/work/'], }, 'http://testing.com/work/': { SIOC('has_parent'): ['http://example.com'], CC('license'): ['http://creativecommons.org/licenses/by/3.0/'], }, 'http://example.com': { POWDER('iriset'): ['foo_iriset'], }, "foo_iriset": { POWDER('includeregex'): [ "\\:\\/\\/(([^\\/\\?\\#]*)\\@)?([^\\:\\/\\?\\#\\@]*)(\\:([0-9]+))?(\\/)", "\\:\\/\\/(([^\\/\\?\\#]*)\\@)?([^\\:\\/\\?\\#\\@]+\\.)?(example\\.com)(\\:([0-9]+))?\\/", "^(http)\\:\\/\\/" ], POWDER('excluderegex'): [ "\\:\\/\\/(([^\\/\\?\\#]*)\\@)?([^\\:\\/\\?\\#\\@]+\\.)?(example\\.com)(\\:([0-9]+))?\\/foo\\/bar\\/", ], }, } } self.assertTrue( metadata.is_registered( 'http://example.com/foo/blog/', 'http://creativecommons.org/licenses/by/3.0/', triples)) self.assertFalse( metadata.is_registered( 'http://example.com/foo/bar/', 'http://creativecommons.org/licenses/by/3.0/', triples))
def test_valid_registration_with_exclude_iriset(self): """ A succesfull assertion using an iriset """ # iri set claims that http://example.com/foo/* is registered except for # the document hosted at http://example.com/foo/bar/ triples = { "redirects":{}, 'subjects': ['http://example.com', 'http://example.com/foo/blog/', 'http://example.com/foo/bar/', 'http://testing.com', 'http://testing.com/work/', 'foo_iriset'], 'triples': { 'http://example.com/foo/blog/': { SIOC('has_owner'):['http://testing.com'], CC('license'):[ 'http://creativecommons.org/licenses/by/3.0/'], }, 'http://example.com/foo/bar/': { SIOC('has_owner'):['http://testing.com'], CC('license'):[ 'http://creativecommons.org/licenses/by/3.0/'], }, 'http://testing.com': { SIOC('owner_of'): ['http://testing.com/work/'], }, 'http://testing.com/work/': { SIOC('has_parent'): ['http://example.com'], CC('license'):[ 'http://creativecommons.org/licenses/by/3.0/'], }, 'http://example.com': { POWDER('iriset'): ['foo_iriset'], }, "foo_iriset": { POWDER('includeregex'): [ "\\:\\/\\/(([^\\/\\?\\#]*)\\@)?([^\\:\\/\\?\\#\\@]*)(\\:([0-9]+))?(\\/)", "\\:\\/\\/(([^\\/\\?\\#]*)\\@)?([^\\:\\/\\?\\#\\@]+\\.)?(example\\.com)(\\:([0-9]+))?\\/", "^(http)\\:\\/\\/"], POWDER('excluderegex'): [ "\\:\\/\\/(([^\\/\\?\\#]*)\\@)?([^\\:\\/\\?\\#\\@]+\\.)?(example\\.com)(\\:([0-9]+))?\\/foo\\/bar\\/",], }, } } self.assertTrue(metadata.is_registered('http://example.com/foo/blog/', 'http://creativecommons.org/licenses/by/3.0/', triples)) self.assertFalse(metadata.is_registered('http://example.com/foo/bar/', 'http://creativecommons.org/licenses/by/3.0/', triples))
def test_match_with_include_iriset(self): """ A succesfull assertion using an iriset """ triples = { 'redirects':{}, 'subjects': ['http://example.com', 'http://example.com/foo/1', 'http://example.com/1', 'http://testing.com', 'http://testing.com/work/', 'foo_iriset'], 'triples': { 'http://example.com/foo/1': { SIOC('has_owner'):['http://testing.com'], CC('license'):[ 'http://creativecommons.org/licenses/by/3.0/'], }, 'http://example.com/1': { # not included in the iriset, will fail SIOC('has_owner'):['http://testing.com'], CC('license'):[ 'http://creativecommons.org/licenses/by/3.0/'], }, 'http://testing.com': { SIOC('owner_of'): ['http://testing.com/work/'], }, 'http://testing.com/work/': { SIOC('has_parent'): ['http://example.com'], CC('license'):[ 'http://creativecommons.org/licenses/by/3.0/'], }, 'http://example.com': { POWDER('iriset'): ['foo_iriset'], }, "foo_iriset": { POWDER('includeregex'): [ "\\:\\/\\/(([^\\/\\?\\#]*)\\@)?([^\\:\\/\\?\\#\\@]*)(\\:([0-9]+))?(\\/)", "\\:\\/\\/(([^\\/\\?\\#]*)\\@)?([^\\:\\/\\?\\#\\@]+\\.)?(example\\.com)(\\:([0-9]+))?\\/foo\\/", "^(http)\\:\\/\\/"] }, } } self.assertTrue( metadata.is_registered( 'http://example.com/foo/1', 'http://creativecommons.org/licenses/by/3.0/', triples)) self.assertFalse( metadata.is_registered( 'http://example.com/1', 'http://creativecommons.org/licenses/by/3.0/', triples))
def test_match_with_include_iriset(self): """ A succesfull assertion using an iriset """ triples = { 'redirects':{}, 'subjects': ['http://example.com', 'http://example.com/foo/1', 'http://example.com/1', 'http://testing.com', 'http://testing.com/work/', 'foo_iriset'], 'triples': { 'http://example.com/foo/1': { SIOC('has_owner'):['http://testing.com'], CC('license'):[ 'http://creativecommons.org/licenses/by/3.0/'], }, 'http://example.com/1': { # not included in the iriset, will fail SIOC('has_owner'):['http://testing.com'], CC('license'):[ 'http://creativecommons.org/licenses/by/3.0/'], }, 'http://testing.com': { SIOC('owner_of'): ['http://testing.com/work/'], }, 'http://testing.com/work/': { SIOC('has_parent'): ['http://example.com'], CC('license'):[ 'http://creativecommons.org/licenses/by/3.0/'], }, 'http://example.com': { POWDER('iriset'): ['foo_iriset'], }, "foo_iriset": { POWDER('includeregex'): [ "\\:\\/\\/(([^\\/\\?\\#]*)\\@)?([^\\:\\/\\?\\#\\@]*)(\\:([0-9]+))?(\\/)", "\\:\\/\\/(([^\\/\\?\\#]*)\\@)?([^\\:\\/\\?\\#\\@]+\\.)?(example\\.com)(\\:([0-9]+))?\\/foo\\/", "^(http)\\:\\/\\/"] }, } } self.assertTrue(metadata.is_registered('http://example.com/foo/1', 'http://creativecommons.org/licenses/by/3.0/', triples)) self.assertFalse(metadata.is_registered('http://example.com/1', 'http://creativecommons.org/licenses/by/3.0/', triples))
def test_cc_network_registration_example (self): """ Ensure that a CC Network registration scenario passes """ triples = { "redirects":{}, "subjects": [ "MnRxHtQa824", "http://staging.creativecommons.net/example", "http://staging.creativecommons.net/r/lookup/", "http://staging.creativecommons.org/~john/metadata/?test=register", "http://staging.creativecommons.net/", "http://staging.creativecommons.net/r/1/", "http://staging.creativecommons.org/~john/metadata/",], "triples": { "http://staging.creativecommons.net/example": { "http://xmlns.com/foaf/0.1/nick": ["example"], "http://rdfs.org/sioc/ns#member_of": ["http://staging.creativecommons.net/"], "http://rdfs.org/sioc/ns#owner_of": [ "http://staging.creativecommons.org/~john/metadata/", "http://staging.creativecommons.net/r/1/"], "http://www.w3.org/1999/xhtml/vocab#license": [ "http://creativecommons.org/licenses/by/3.0/"], }, "MnRxHtQa824": { "http://www.w3.org/2007/05/powder#includeregex": [ "\\:\\/\\/(([^\\/\\?\\#]*)\\@)?([^\\:\\/\\?\\#\\@]*)(\\:([0-9]+))?(\\/\\~john\\/metadata\\/)", "^(http)\\:\\/\\/", "\\:\\/\\/(([^\\/\\?\\#]*)\\@)?([^\\:\\/\\?\\#\\@]+\\.)?(staging\\.creativecommons\\.org)(\\:([0-9]+))?\\/"] }, "http://staging.creativecommons.net/r/lookup/": { "http://rdfs.org/sioc/services#service_protocol": [ "http://wiki.creativecommons.org/work-lookup"] }, "http://staging.creativecommons.org/~john/metadata/?test=register": { "http://rdfs.org/sioc/ns#has_owner": [ "http://staging.creativecommons.net/example"] }, "http://staging.creativecommons.net/": { "http://purl.org/dc/terms/title": ["CC Network"], "http://rdfs.org/sioc/services#has_service": ["http://staging.creativecommons.net/r/lookup/"] }, "http://staging.creativecommons.net/r/1/": { "http://purl.org/dc/terms/creator": [ "http://staging.creativecommons.net/example"], "http://purl.org/dc/terms/created": ["01/22/2010"], "http://rdfs.org/sioc/ns#has_owner": ["http://staging.creativecommons.net/example"], "http://rdfs.org/sioc/ns#parent_of": ["http://staging.creativecommons.org/~john/metadata/"], "http://www.w3.org/2007/05/powder#iriset": ["MnRxHtQa824"] }, "http://staging.creativecommons.org/~john/metadata/": { "http://purl.org/dc/terms/title": ["Testing Metadata"], "http://rdfs.org/sioc/ns#has_parent": ["http://staging.creativecommons.net/r/1/"], "http://www.w3.org/1999/xhtml/vocab#license": ["http://creativecommons.org/licenses/by/3.0/"] } } } self.assertTrue(metadata.is_registered('http://staging.creativecommons.org/~john/metadata/?test=register', 'http://creativecommons.org/licenses/by/3.0/', triples))
def test_badge_redirects_registration(self): """ A badge links to an old profile uri (e.g. https://creativecommons.net/example/) causing a redirect to /example then the registration should still be successful """ test_url = 'http://code.creativecommons.org/tests/metadata_scraper/work_redirect.html' response = self.app.get('/triples?url=' + test_url) triples = json.loads(response.body) self.assertTrue(metadata.is_registered( test_url, 'http://creativecommons.org/licenses/by/3.0/us/', triples))