Exemplo n.º 1
0
    def test_errors_when_no_git_repo_exists(self):
        with mock.patch(puts_path, mock.Mock()) as puts:
            validate()

            arg = SubstringMatcher(
                containing="Could not find a git repository")
            puts.assert_called_with(arg)
Exemplo n.º 2
0
    def test_warns_when_wercker_json_not_exists(self):

        with mock.patch(puts_path, mock.Mock()) as puts:
            validate()

            puts.assert_called_with(
                SubstringMatcher(
                    containing="Could not find a wercker.json file"))
Exemplo n.º 3
0
    def test_puts_error_when_wercker_json_is_not_valid(self):
        with mock.patch("json.load", mock.Mock()) as json_load:
            with mock.patch(puts_path, mock.Mock()) as puts:
                validate()

                json_load.assert_called_once()
                puts.assert_called_with(
                    SubstringMatcher(
                        containing="wercker.json is found and valid!"))
Exemplo n.º 4
0
    def test_puts_error_when_wercker_json_is_not_valid(self):
        e = ValueError('foo')
        with mock.patch("json.load", mock.Mock(side_effect=e)) as json_load:
            with mock.patch(puts_path, mock.Mock()) as puts:
                validate()

                json_load.assert_called_once()
                puts.assert_called_with(
                    SubstringMatcher(
                        containing="wercker.json is not valid json: "))
Exemplo n.º 5
0
    def test_puts_error_when_wercker_json_is_empty(self):
        e = IOError('foo')
        with mock.patch(open_path, mock.Mock(side_effect=e)) as open_file:
            with mock.patch(puts_path, mock.Mock()) as puts:
                validate()

                open_file.assert_called_once()
                puts.assert_called_with(
                    SubstringMatcher(
                        containing="wercker.json is found, but empty"))
Exemplo n.º 6
0
    def test_puts_error_when_wercker_json_could_not_be_opened(self):
        e = IOError('foo')
        with mock.patch(open_path, mock.Mock(side_effect=e)) as open_file:
            with mock.patch(puts_path, mock.Mock()) as puts:
                validate()

                open_file.assert_called_once()
                puts.assert_called_with(
                    SubstringMatcher(
                        containing="Error while reading wercker.json file:"))