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'})
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'})
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'})
def test_incomplete(self): metadata = {'providers': {'a': {}}, 'resources': {}} # noinspection PyProtectedMember d = resource._get_resource_metadata(provider='a', metadata=metadata) assert (d == {'provider': 'a'})
def test_empty(self): metadata = {'providers': {}, 'resources': {}} # noinspection PyProtectedMember d = resource._get_resource_metadata(metadata=metadata) assert (d == {})