コード例 #1
0
ファイル: test_command.py プロジェクト: meffij/quilt
    def test_config_bad_urls(self, mock_input, mock_load_config,
                             mock_save_config):
        test_urls = [
            'foo.com',
            'ftp://foo.com',
            'blah://bar.com',
            'http://foo.bar.com/baz',
        ]
        # test general URL setting -- result should match initial state
        mock_load_config.return_value = {}
        initial_url = command.get_registry_url()

        for test_url in test_urls:
            mock_input.return_value = test_url

            with assertRaisesRegex(self, command.CommandException,
                                   'Invalid URL'):
                command.config()

            assert mock_input.called
            mock_input.reset_mock()

            mock_save_config.assert_not_called()

            assert command.get_registry_url() == initial_url
コード例 #2
0
ファイル: test_command.py プロジェクト: meffij/quilt
    def test_config_urls_default(self, mock_input, mock_load_config,
                                 mock_save_config):
        # test setting default URL with blank string -- result should be default
        mock_load_config.return_value = {}
        mock_input.return_value = ''

        command.config()

        assert mock_input.called

        args, kwargs = mock_save_config.call_args
        mock_load_config.return_value = args[0] if args else kwargs['cfg']
        assert command.get_registry_url() == command.DEFAULT_REGISTRY_URL
コード例 #3
0
ファイル: test_command.py プロジェクト: meffij/quilt
    def test_config_good_urls(self, mock_input, mock_load_config,
                              mock_save_config):
        test_urls = [
            'https://foo.com',
            'http://foo.com',
            'https://foo.bar.net',
        ]
        # test general URL setting -- result should match input
        for test_url in test_urls:
            mock_load_config.return_value = {}
            mock_input.return_value = test_url

            command.config()

            assert mock_input.called
            mock_input.reset_mock()

            args, kwargs = mock_save_config.call_args
            mock_load_config.return_value = args[0] if args else kwargs['cfg']
            assert test_url == command.get_registry_url()