Пример #1
0
def split_to_urn_and_rest(uri):
    if uri.startswith('urn:'):
        if uri.startswith('urn:x-bundle:'):
            return 'urn:x-bundle:', uri.replace('urn:x-bundle:', '')
        else:
            raise MalformedBundleUriError('{} is not a valid bundle uri'.format(uri))
    else:
        return 'urn:x-bundle:', uri
Пример #2
0
def split_to_org_repo_package(uri):
    parts = uri.split('/')
    if len(parts) == 3:
        return parts
    elif len(parts) == 2:
        return DEFAULT_ORG, parts[0], parts[1]
    elif len(parts) == 1:
        return DEFAULT_ORG, DEFAULT_REPO, parts[0]
    else:
        raise MalformedBundleUriError('{} is not a valid bundle uri'.format(uri))
Пример #3
0
    def test_failure_malformed_bundle_uri(self):
        load_bintray_credentials_mock = MagicMock(return_value=('username', 'password'))
        parse_mock = MagicMock(side_effect=MalformedBundleUriError('test only'))

        with patch('conductr_cli.resolvers.bintray_resolver.load_bintray_credentials', load_bintray_credentials_mock), \
                patch('conductr_cli.bundle_shorthand.parse', parse_mock):
            is_resolved, bundle_name, bundle_file = bintray_resolver.resolve_bundle('/cache-dir', 'bundle-name:v1')
            self.assertFalse(is_resolved)
            self.assertIsNone(bundle_name)
            self.assertIsNone(bundle_file)

        load_bintray_credentials_mock.assert_called_with()
        parse_mock.assert_called_with('bundle-name:v1')