def test_bintray_version_found(self):
        load_bintray_credentials_mock = MagicMock(return_value=('username', 'password'))
        parse_bundle_mock = MagicMock(return_value=('urn:x-bundle:', 'typesafe', 'bundle', 'bundle-name', 'v1', 'digest'))
        bintray_resolve_version_mock = MagicMock(return_value={
            'org': 'typesafe',
            'repo': 'bundle',
            'package_name': 'bundle-name',
            'compatibility_version': 'v1',
            'digest': 'digest',
            'path': 'download.zip'
        })
        resolve_bundle_mock = MagicMock(return_value=(True, 'bundle-name', 'mock bundle file'))

        with patch('conductr_cli.resolvers.bintray_resolver.load_bintray_credentials', load_bintray_credentials_mock), \
                patch('conductr_cli.bundle_shorthand.parse_bundle', parse_bundle_mock), \
                patch('conductr_cli.resolvers.bintray_resolver.bintray_resolve_version', bintray_resolve_version_mock), \
                patch('conductr_cli.resolvers.bintray_resolver.uri_resolver.resolve_bundle', resolve_bundle_mock):
            is_resolved, bundle_name, bundle_file = bintray_resolver.resolve_bundle('/cache-dir', 'bundle-name:v1')
            self.assertTrue(is_resolved)
            self.assertEqual('bundle-name', bundle_name)
            self.assertEqual('mock bundle file', bundle_file)

        load_bintray_credentials_mock.assert_called_with()
        parse_bundle_mock.assert_called_with('bundle-name:v1')
        bintray_resolve_version_mock.assert_called_with('username', 'password', 'typesafe', 'bundle', 'bundle-name',
                                                        'v1', 'digest')
        resolve_bundle_mock.assert_called_with('/cache-dir', 'https://dl.bintray.com/typesafe/bundle/download.zip',
                                               ('Bintray', 'username', 'password'))
    def test_failure_malformed_bundle_uri(self):
        parse_bundle_mock = MagicMock(side_effect=MalformedBundleUriError('test only'))

        with patch('conductr_cli.bundle_shorthand.parse_bundle', parse_bundle_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)

        parse_bundle_mock.assert_called_with('bundle-name:v1')
Example #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')
    def test_failure_http_error(self):
        load_bintray_credentials_mock = MagicMock(return_value=('username', 'password'))
        parse_bundle_mock = MagicMock(return_value=('urn:x-bundle:', 'typesafe', 'bundle', 'bundle-name', 'v1', 'digest'))
        bintray_resolve_version_mock = MagicMock(side_effect=HTTPError('test only'))

        with patch('conductr_cli.resolvers.bintray_resolver.load_bintray_credentials', load_bintray_credentials_mock), \
                patch('conductr_cli.bundle_shorthand.parse_bundle', parse_bundle_mock), \
                patch('conductr_cli.resolvers.bintray_resolver.bintray_resolve_version', bintray_resolve_version_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_bundle_mock.assert_called_with('bundle-name:v1')
        bintray_resolve_version_mock.assert_called_with('username', 'password', 'typesafe', 'bundle', 'bundle-name',
                                                        'v1', 'digest')
Example #5
0
    def test_failure_http_error(self):
        load_bintray_credentials_mock = MagicMock(return_value=('username', 'password'))
        parse_mock = MagicMock(return_value=('urn:x-bundle:', 'typesafe', 'bundle', 'bundle-name', 'v1', 'digest'))
        bintray_download_url_mock = MagicMock(side_effect=HTTPError('test only'))

        with patch('conductr_cli.resolvers.bintray_resolver.load_bintray_credentials', load_bintray_credentials_mock), \
                patch('conductr_cli.bundle_shorthand.parse', parse_mock), \
                patch('conductr_cli.resolvers.bintray_resolver.bintray_download_url', bintray_download_url_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')
        bintray_download_url_mock.assert_called_with('username', 'password', 'typesafe', 'bundle', 'bundle-name', 'v1',
                                                     'digest')
    def test_bintray_version_not_found(self):
        load_bintray_credentials_mock = MagicMock(return_value=('username', 'password'))
        parse_mock = MagicMock(return_value=('urn:x-bundle:', 'typesafe', 'bundle', 'bundle-name', 'v1', 'digest'))
        bintray_download_url_mock = MagicMock(return_value=None)

        with patch('conductr_cli.resolvers.bintray_resolver.load_bintray_credentials', load_bintray_credentials_mock), \
                patch('conductr_cli.bundle_shorthand.parse', parse_mock), \
                patch('conductr_cli.resolvers.bintray_resolver.bintray_download_url', bintray_download_url_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')
        bintray_download_url_mock.assert_called_with('username', 'password', 'typesafe', 'bundle', 'bundle-name', 'v1',
                                                     'digest')
Example #7
0
    def test_bintray_version_found(self):
        load_bintray_credentials_mock = MagicMock(return_value=('username', 'password'))
        parse_mock = MagicMock(return_value=('urn:x-bundle:', 'typesafe', 'bundle', 'bundle-name', 'v1', 'digest'))
        bintray_download_url_mock = MagicMock(return_value='https://dl.bintray.com/download.zip')
        resolve_bundle_mock = MagicMock(return_value=(True, 'bundle-name', 'mock bundle file'))

        with patch('conductr_cli.resolvers.bintray_resolver.load_bintray_credentials', load_bintray_credentials_mock), \
                patch('conductr_cli.bundle_shorthand.parse', parse_mock), \
                patch('conductr_cli.resolvers.bintray_resolver.bintray_download_url', bintray_download_url_mock), \
                patch('conductr_cli.resolvers.bintray_resolver.uri_resolver.resolve_bundle', resolve_bundle_mock):
            is_resolved, bundle_name, bundle_file = bintray_resolver.resolve_bundle('/cache-dir', 'bundle-name:v1')
            self.assertTrue(is_resolved)
            self.assertEqual('bundle-name', bundle_name)
            self.assertEqual('mock bundle file', bundle_file)

        load_bintray_credentials_mock.assert_called_with()
        parse_mock.assert_called_with('bundle-name:v1')
        bintray_download_url_mock.assert_called_with('username', 'password', 'typesafe', 'bundle', 'bundle-name', 'v1',
                                                     'digest')
        resolve_bundle_mock.assert_called_with('/cache-dir', 'https://dl.bintray.com/download.zip',
                                               ('Bintray', 'username', 'password'))