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