Beispiel #1
0
    def test_match_with_resource_name(self):

        metadata = {
            'providers': {
                'p': {}
            },
            'resources': {
                'r1.r2.r3': {
                    'path': 'abc',
                    'provider': 'p'
                },
                'r2': {
                    'path': 'abc',
                    'provider': 'p'
                },
            }
        }
        # noinspection PyProtectedMember
        d = resource._get_resource_metadata(resource='r1.r2.r3',
                                            provider='p',
                                            metadata=metadata)
        assert (d == {'alias': 'r1.r2.r3', 'path': 'abc', 'provider': 'p'})

        # noinspection PyProtectedMember
        d = resource._get_resource_metadata(resource='r1.r2.r3',
                                            provider='p_not',
                                            metadata=metadata)
        assert (d == {'alias': 'r1.r2.r3', 'path': 'abc', 'provider': 'p_not'})

        # noinspection PyProtectedMember
        d = resource._get_resource_metadata(resource='other',
                                            provider='p_not',
                                            metadata=metadata)
        assert (d == {'path': 'other', 'provider': 'p_not'})
Beispiel #2
0
    def test_minimal(self):

        metadata = {
            'providers': {
                'p': {}
            },
            'resources': { 'r': { 'provider': 'p'}}
        }
        # noinspection PyProtectedMember
        d = resource._get_resource_metadata(resource='r', provider='p', metadata=metadata)
        assert(d == {'alias': 'r', 'provider': 'p'})

        # noinspection PyProtectedMember
        d = resource._get_resource_metadata(resource='r', provider='p_not', metadata=metadata)
        assert(d == {'alias': 'r', 'provider': 'p_not'})
Beispiel #3
0
    def test_empty(self):

        metadata = {
            'providers': {},
            'resources': {}
        }
        # noinspection PyProtectedMember
        d = resource._get_resource_metadata(metadata=metadata)
        assert(d == {})
Beispiel #4
0
    def test_incomplete(self):

        metadata = {
            'providers': {
                'a': {}
            },
            'resources': {}
        }
        # noinspection PyProtectedMember
        d = resource._get_resource_metadata(provider='a', metadata=metadata)
        assert(d == {'provider':'a'})
Beispiel #5
0
    def test_no_match(self):

        metadata = {
            'providers': {
                'p': {}
            },
            'resources': {
                'r1': { 'path': 'abc', 'provider': 'p'},
                'r2': { 'path': 'abc', 'provider': 'p'},

            }
        }
        # noinspection PyProtectedMember
        d = resource._get_resource_metadata(resource='xyz', provider='abc', metadata=metadata)
        assert(d == {'path': 'xyz', 'provider': 'abc'})