Ejemplo 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)
Ejemplo 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"))
Ejemplo 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!"))
Ejemplo 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: "))
Ejemplo 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"))
Ejemplo 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:"))