def test_should_exit_program_when_strange_url_is_given(
            self, mock_exit_program):

        ensure_valid_repository_url('foo://bar')

        mock_exit_program.assert_called_with(
            'Given repository url "foo://bar" is invalid.', return_code=6)
Пример #2
0
def extract_repository_url_and_revision_from_arguments(arguments):
    """ Extracts the repository url and the revision from the given
        arguments ensuring that they have valid values. """

    repository_url = ensure_valid_repository_url(arguments[ARGUMENT_REPOSITORY])
    revision = ensure_valid_revision(arguments[ARGUMENT_REVISION])
    return repository_url, revision
Пример #3
0
def extract_repository_url_and_revision_from_arguments(arguments):
    """ Extracts the repository url and the revision from the given
        arguments ensuring that they have valid values. """

    repository_url = ensure_valid_repository_url(
        arguments[ARGUMENT_REPOSITORY])
    revision = ensure_valid_revision(arguments[ARGUMENT_REVISION])
    return repository_url, revision
    def test_should_prepend_file_scheme_if_url_has_no_scheme(self, mock_exit_program):

        actual_url = ensure_valid_repository_url('/directory/repository')

        self.assertEqual('file:///directory/repository', actual_url)
    def test_should_return_url_when_a_valid_file_url(self, mock_exit_program):

        actual_url = ensure_valid_repository_url('file://directory/repository')

        self.assertEqual('file://directory/repository', actual_url)
    def test_should_return_url_when_a_valid_ssh_url(self, mock_exit_program):

        actual_url = ensure_valid_repository_url('ssh://host/repository')

        self.assertEqual('ssh://host/repository', actual_url)
    def test_should_exit_program_when_strange_url_is_given(self, mock_exit_program):

        ensure_valid_repository_url('foo://bar')

        mock_exit_program.assert_called_with('Given repository url "foo://bar" is invalid.', return_code=6)
    def test_should_prepend_file_scheme_if_url_has_no_scheme(
            self, mock_exit_program):

        actual_url = ensure_valid_repository_url('/directory/repository')

        self.assertEqual('file:///directory/repository', actual_url)
    def test_should_return_url_when_a_valid_file_url(self, mock_exit_program):

        actual_url = ensure_valid_repository_url('file://directory/repository')

        self.assertEqual('file://directory/repository', actual_url)
    def test_should_return_url_when_a_valid_ssh_url(self, mock_exit_program):

        actual_url = ensure_valid_repository_url('ssh://host/repository')

        self.assertEqual('ssh://host/repository', actual_url)