Exemplo n.º 1
0
    def test_incomplete_metadata_registration(self):
        """ ownership assertion exists, but owner name & network info are req. """

        triples = {
                   'redirects':{},
                   'subjects': [
                        'http://example.com',
                        'http://testing.com'],
                   'triples': {
                       'http://example.com' : {
                           SIOC('has_owner') : ['http://testing.com'],
                           },
                       'http://testing.com' : {
                           SIOC('owner_of'): ['http://example.com'],
                           }
                       }
                   }

        reg = metadata.registration("http://example.com",
                                    triples,
                                    "http://creativecommons.org/licenses/by/3.0/")

        empty_reg = {
            'owner_url': '',
            'owner_name': '',
            'network_name': '',
            'lookup_uri': '',
            'network_url': ''}

        self.assertEqual(reg, empty_reg)
Exemplo n.º 2
0
    def test_no_registration(self):
        """ No registration metadata returns an empty dict """
        triples = {
                   'redirects':{},
                   'subjects': [
                        'http://example.com',],
                   'triples': {
                       'http://example.com' : {
                           CC('license') : [
                               'http://creativecommons.org/licenses/by/3.0/'],
                           }
                       }
                   }
                   

        reg = metadata.registration("http://example.com",
                                    triples,
                                    "http://creativecommons.org/licenses/by/3.0/")
        empty_reg = {
            'owner_url': '',
            'owner_name': '',
            'network_name': '',
            'lookup_uri': '',
            'network_url': ''}

        self.assertEqual(reg, empty_reg)
Exemplo n.º 3
0
    def test_no_reciprocal_registration(self):
        """ has_owner exists, but has no owner_of triple to compelte the
        assertion """

        triples = {
                   'redirects':{},
                   'subjects': [
                        'http://example.com',
                        'http://testing.com'],
                   'triples': {
                       'http://example.com' : {
                           SIOC('has_owner') : [
                               'http://testing.com'],
                           },
                       'http://testing.com' : {
                           CC('license') : [
                               'http://creativecommons.org/licenses/by/3.0/'],
                           }
                       }
                   }

        reg = metadata.registration("http://example.com",
                                    triples,
                                    "http://creativecommons.org/licenses/by/3.0/" )

        empty_reg = {
            'owner_url': '',
            'owner_name': '',
            'network_name': '',
            'lookup_uri': '',
            'network_url': ''}

        self.assertEqual(reg, empty_reg)
Exemplo n.º 4
0
    def test_valid_registration(self):
        """ ownership assertion exists, but owner name & network info are req. """

        triples = {
            'redirects': {},
            'subjects': [
                'http://example.com',
                'http://testing.com',
                'https://creativecommons.net',
                'https://creativecommons.net/r/lookup/',
            ],
            'triples': {
                'http://example.com': {
                    SIOC('has_owner'): ['http://testing.com'],
                },
                'http://testing.com': {
                    SIOC('owner_of'): ['http://example.com'],
                    SIOC('name'): ['Testing'],
                    SIOC('member_of'): ['https://creativecommons.net'],
                },
                'https://creativecommons.net': {
                    DCT('title'): ['CC Network'],
                    SIOC_SERVICE('has_service'):
                    ['https://creativecommons.net/r/lookup/'],
                },
                'https://creativecommons.net/r/lookup/': {
                    SIOC_SERVICE('service_protocol'):
                    ['http://wiki.creativecommons.org/work-lookup'],
                }
            }
        }

        reg = metadata.registration(
            "http://example.com", triples,
            "http://creativecommons.org/licenses/by/3.0/")

        test_registration = {
            'owner_url':
            'http://testing.com',
            'owner_name':
            'Testing',
            'network_url':
            'https://creativecommons.net',
            'network_name':
            'CC Network',
            'lookup_uri':
            'https://creativecommons.net/r/lookup/?uri=http://example.com'
        }

        self.assertEqual(reg, test_registration)
Exemplo n.º 5
0
    def test_valid_registration(self):
        """ ownership assertion exists, but owner name & network info are req. """

        triples = {
                   'redirects':{},
                   'subjects': [
                        'http://example.com',
                        'http://testing.com',
                        'https://creativecommons.net',
                        'https://creativecommons.net/r/lookup/',],
                   'triples': {
                       'http://example.com' : {
                           SIOC('has_owner') : ['http://testing.com'],
                           },
                       'http://testing.com' : {
                           SIOC('owner_of'): ['http://example.com'],
                           SIOC('name'): ['Testing'],
                           SIOC('member_of'): ['https://creativecommons.net'],
                           },
                       'https://creativecommons.net': {
                           DCT('title'):['CC Network'],
                           SIOC_SERVICE('has_service'): [
                               'https://creativecommons.net/r/lookup/'],
                           },
                       'https://creativecommons.net/r/lookup/': {
                           SIOC_SERVICE('service_protocol'):[
                               'http://wiki.creativecommons.org/work-lookup'],
                           }
                       }
                   }

        reg = metadata.registration("http://example.com",
                                    triples,
                                    "http://creativecommons.org/licenses/by/3.0/")

        test_registration = {
            'owner_url' : 'http://testing.com',
            'owner_name' : 'Testing',
            'network_url' : 'https://creativecommons.net',
            'network_name' : 'CC Network',
            'lookup_uri' : 'https://creativecommons.net/r/lookup/?uri=http://example.com'
            }

        self.assertEqual(reg, test_registration)