def test_error_response(self): create_method = mock.MagicMock( side_effect=exceptions.AbnormalGithubResponse) self.fake_release.return_value = mock.MagicMock(publish=create_method) with mock.patch.object(sys, "argv", SHORT_ARGS): main() create_method.assert_called_with(tag_name=TEST_TAG, name=TEST_TAG, body=DEFAULT_RELEASE_MESSAGE)
def test_good_commands(self): create_method = mock.MagicMock( return_value="http://localhost/tag/testurl") self.fake_release.return_value = mock.MagicMock(publish=create_method) with mock.patch.object(sys, "argv", SHORT_ARGS): main() create_method.assert_called_with(tag_name=TEST_TAG, name=TEST_TAG, body=DEFAULT_RELEASE_MESSAGE)
def test_quoted_release_message(self): release_message = "hello world you see it" create_method = mock.MagicMock( return_value="http://localhost/tag/testurl") self.fake_release.return_value = mock.MagicMock(publish=create_method) with mock.patch.object(sys, "argv", SHORT_ARGS + [release_message]): main() create_method.assert_called_with(tag_name=TEST_TAG, name=TEST_TAG, body=release_message)
def test_custom_release_message(self): release_message = ["hello", "world", "you", "see", "it"] create_method = mock.MagicMock( return_value="http://localhost/tag/testurl") self.fake_release.return_value = mock.MagicMock(publish=create_method) with mock.patch.object(sys, "argv", SHORT_ARGS + release_message): main() create_method.assert_called_with( tag_name=TEST_TAG, name=TEST_TAG, body=" ".join(release_message), )
def test_insufficent_args(): with mock.patch.object(sys, "argv", SHORT_ARGS[:2]): main()
def test_no_args(): with mock.patch.object(sys, "argv", []): main()
def test_no_gease_file_in_main(self): self.fake_expand.return_value = os.path.join("tests") with mock.patch.object(sys, "argv", SHORT_ARGS): main()
def test_key_error_in_main(self): self.fake_expand.return_value = os.path.join("tests", "fixtures", "malformed") with mock.patch.object(sys, "argv", SHORT_ARGS): main()