-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better coverage for utils, cover __main__
- Loading branch information
Anton Kudinov
committed
Dec 4, 2017
1 parent
93bb625
commit ffb4f6b
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from ncssl_api_client.__main__ import main_cli_wrapper | ||
from unittest import TestCase | ||
import mock | ||
|
||
|
||
class MainTest(TestCase): | ||
|
||
@mock.patch('ncssl_api_client.__main__.main', return_value=mock.MagicMock()) | ||
def test_status_code_zero_on_success(self, result_mock): | ||
result_mock().is_successful.return_value = True | ||
with self.assertRaises(SystemExit) as cm: | ||
main_cli_wrapper() | ||
|
||
self.assertEqual(cm.exception.code, 0) | ||
|
||
@mock.patch('ncssl_api_client.__main__.main', return_value=mock.MagicMock()) | ||
def test_status_code_one_on_failure(self, result_mock): | ||
result_mock().is_successful.return_value = False | ||
with self.assertRaises(SystemExit) as cm: | ||
main_cli_wrapper() | ||
|
||
self.assertEqual(cm.exception.code, 1) |