Exemplo n.º 1
0
    def test_uri_not_found(self):
        exists_mock = MagicMock(return_value=False)

        with patch('os.path.exists', exists_mock):
            is_resolved, bundle_name, bundle_file = uri_resolver.load_bundle_configuration_from_cache(
                '/cache-dir', 'http://site.com/path/bundle-file.zip')
            self.assertFalse(is_resolved)
            self.assertIsNone(bundle_name)
            self.assertIsNone(bundle_file)

        exists_mock.assert_called_with('/cache-dir/bundle-file.zip')
Exemplo n.º 2
0
    def test_file(self):
        exists_mock = MagicMock()

        with patch('os.path.exists', exists_mock):
            is_resolved, bundle_name, bundle_file = uri_resolver.load_bundle_configuration_from_cache(
                '/cache-dir', '/tmp/bundle.zip')
            self.assertFalse(is_resolved)
            self.assertIsNone(bundle_name)
            self.assertIsNone(bundle_file)

        exists_mock.assert_not_called()
Exemplo n.º 3
0
    def test_file(self):
        exists_mock = MagicMock()

        with patch('os.path.exists', exists_mock):
            is_resolved, bundle_name, bundle_file = uri_resolver.load_bundle_configuration_from_cache(
                '/cache-dir', '/tmp/bundle.zip')
            self.assertFalse(is_resolved)
            self.assertIsNone(bundle_name)
            self.assertIsNone(bundle_file)

        exists_mock.assert_not_called()
Exemplo n.º 4
0
    def test_uri_not_found(self):
        exists_mock = MagicMock(return_value=False)

        with patch('os.path.exists', exists_mock):
            is_resolved, bundle_name, bundle_file = uri_resolver.load_bundle_configuration_from_cache(
                '/cache-dir',
                'http://site.com/path/bundle-file.zip')
            self.assertFalse(is_resolved)
            self.assertIsNone(bundle_name)
            self.assertIsNone(bundle_file)

        exists_mock.assert_called_with('/cache-dir/bundle-file.zip')
Exemplo n.º 5
0
    def test_uri_found(self):
        exists_mock = MagicMock(return_value=True)

        get_logger_mock, log_mock = create_mock_logger()

        with patch('os.path.exists', exists_mock), \
                patch('logging.getLogger', get_logger_mock):
            is_resolved, bundle_name, bundle_file = uri_resolver.load_bundle_configuration_from_cache(
                '/cache-dir',
                'http://site.com/path/bundle-file.zip')
            self.assertTrue(is_resolved)
            self.assertEqual('bundle-file.zip', bundle_name)
            self.assertEqual('/cache-dir/bundle-file.zip', bundle_file)

        exists_mock.assert_called_with('/cache-dir/bundle-file.zip')

        get_logger_mock.assert_called_with('conductr_cli.resolvers.uri_resolver')
        log_mock.info.assert_called_with('Retrieving from cache /cache-dir/bundle-file.zip')
Exemplo n.º 6
0
    def test_uri_found(self):
        exists_mock = MagicMock(return_value=True)

        get_logger_mock, log_mock = create_mock_logger()

        with patch('os.path.exists', exists_mock), \
                patch('logging.getLogger', get_logger_mock):
            is_resolved, bundle_name, bundle_file = uri_resolver.load_bundle_configuration_from_cache(
                '/cache-dir', 'http://site.com/path/bundle-file.zip')
            self.assertTrue(is_resolved)
            self.assertEqual('bundle-file.zip', bundle_name)
            self.assertEqual('/cache-dir/bundle-file.zip', bundle_file)

        exists_mock.assert_called_with('/cache-dir/bundle-file.zip')

        get_logger_mock.assert_called_with(
            'conductr_cli.resolvers.uri_resolver')
        log_mock.info.assert_called_with(
            'Retrieving from cache /cache-dir/bundle-file.zip')