Add version option to CLI.
This commit is contained in:
parent
9fc9177742
commit
a8bde4a438
2 changed files with 23 additions and 10 deletions
|
@ -23,7 +23,7 @@ def raise_exception(_):
|
|||
class TestCli(unittest.TestCase):
|
||||
test_file = os.path.join("tests", "unit", "data", "test_file.txt")
|
||||
|
||||
@mock.patch.object(openphoto.main, "OpenPhoto")
|
||||
@mock.patch.object(openphoto.main.openphoto, "OpenPhoto")
|
||||
@mock.patch('sys.stdout', new_callable=io.StringIO)
|
||||
def test_defaults(self, _, mock_openphoto):
|
||||
"""Check that the default behaviour is correct"""
|
||||
|
@ -32,14 +32,14 @@ class TestCli(unittest.TestCase):
|
|||
mock_openphoto.assert_called_with(config_file=None)
|
||||
get.assert_called_with("/photos/list.json", process_response=False)
|
||||
|
||||
@mock.patch.object(openphoto.main, "OpenPhoto")
|
||||
@mock.patch.object(openphoto.main.openphoto, "OpenPhoto")
|
||||
@mock.patch('sys.stdout', new_callable=io.StringIO)
|
||||
def test_config(self, _, mock_openphoto):
|
||||
"""Check that a config file can be specified"""
|
||||
main(["--config=test"])
|
||||
mock_openphoto.assert_called_with(config_file="test")
|
||||
|
||||
@mock.patch.object(openphoto.main, "OpenPhoto")
|
||||
@mock.patch.object(openphoto.main.openphoto, "OpenPhoto")
|
||||
@mock.patch('sys.stdout', new_callable=io.StringIO)
|
||||
def test_get(self, mock_stdout, mock_openphoto):
|
||||
"""Check that the get operation is working"""
|
||||
|
@ -52,7 +52,7 @@ class TestCli(unittest.TestCase):
|
|||
process_response=False)
|
||||
self.assertEqual(mock_stdout.getvalue(), "Result\n")
|
||||
|
||||
@mock.patch.object(openphoto.main, "OpenPhoto")
|
||||
@mock.patch.object(openphoto.main.openphoto, "OpenPhoto")
|
||||
@mock.patch('sys.stdout', new_callable=io.StringIO)
|
||||
def test_post(self, mock_stdout, mock_openphoto):
|
||||
"""Check that the post operation is working"""
|
||||
|
@ -65,7 +65,7 @@ class TestCli(unittest.TestCase):
|
|||
files={}, process_response=False)
|
||||
self.assertEqual(mock_stdout.getvalue(), "Result\n")
|
||||
|
||||
@mock.patch.object(openphoto.main, "OpenPhoto")
|
||||
@mock.patch.object(openphoto.main.openphoto, "OpenPhoto")
|
||||
@mock.patch('sys.stdout', new_callable=io.StringIO)
|
||||
def test_post_files(self, _, mock_openphoto):
|
||||
"""Check that files are posted correctly"""
|
||||
|
@ -104,7 +104,7 @@ class TestCli(unittest.TestCase):
|
|||
mock_stdout.getvalue())
|
||||
self.assertIn("To get your credentials", mock_stdout.getvalue())
|
||||
|
||||
@mock.patch.object(openphoto.main, "OpenPhoto")
|
||||
@mock.patch.object(openphoto.main.openphoto, "OpenPhoto")
|
||||
@mock.patch('sys.stdout', new_callable=io.StringIO)
|
||||
def test_verbose(self, mock_stdout, _):
|
||||
"""Check that the verbose option is working"""
|
||||
|
@ -112,7 +112,7 @@ class TestCli(unittest.TestCase):
|
|||
self.assertIn("Method: GET", mock_stdout.getvalue())
|
||||
self.assertIn("Endpoint: /photos/list.json", mock_stdout.getvalue())
|
||||
|
||||
@mock.patch.object(openphoto.main, "OpenPhoto")
|
||||
@mock.patch.object(openphoto.main.openphoto, "OpenPhoto")
|
||||
@mock.patch('sys.stdout', new_callable=io.StringIO)
|
||||
def test_pretty_print(self, mock_stdout, mock_openphoto):
|
||||
"""Check that the pretty-print option is working"""
|
||||
|
@ -120,3 +120,10 @@ class TestCli(unittest.TestCase):
|
|||
get.return_value = '{"test":1}'
|
||||
main(["-p"])
|
||||
self.assertEqual(mock_stdout.getvalue(), '{\n "test":1\n}\n')
|
||||
|
||||
@mock.patch('sys.stdout', new_callable=io.StringIO)
|
||||
def test_version(self, mock_stdout):
|
||||
"""Check that the version string is correctly printed"""
|
||||
main(["--version"])
|
||||
self.assertEqual(mock_stdout.getvalue(), openphoto.__version__ + "\n")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue