diff options
-rw-r--r-- | test/cli_test.py | 60 |
1 files changed, 58 insertions, 2 deletions
diff --git a/test/cli_test.py b/test/cli_test.py index 392d5da..de66828 100644 --- a/test/cli_test.py +++ b/test/cli_test.py @@ -1,7 +1,63 @@ import unittest +import context +from gantools import cli + +def validate_args(args): + # check if username, password, and keys are all set or all empty + if not (lambda l: (not any(l)) or all(l))(\ + [e is not None and e is not [] for e in [args.username, args.password, args.keys]]): + print(args.username) + print(args.password) + print(args.keys) + raise Exception('ganbreeder login credentials are invalid') class TestCli(unittest.TestCase): - def test_main(self): - self.assertEqual(True,True,"Will always pass") + def test_handle_args_ganbreeder_login_correct(self): + argv = [ + '-u', '[email protected]',# user name + '-p', 'password123',# password + '-k', 'aaaa', 'bbbb', 'cccc',# keys + ] + args = cli.handle_args(argv=argv) + validate_args(args) + + def test_handle_args_ganbreeder_login_no_user(self): + argv = [ + '-p', 'password123',# password + '-k', 'aaaa', 'bbbb', 'cccc',# keys + ] + try: + args = cli.handle_args(argv=argv) + except: + return # this is supposed to cause an exception + validate_args(args) + + def test_handle_args_ganbreeder_login_no_pass(self): + argv = [ + '-u', '[email protected]',# user name + '-k', 'aaaa', 'bbbb', 'cccc',# keys + ] + try: + args = cli.handle_args(argv=argv) + except: + return # this is supposed to cause an exception + validate_args(args) + + def test_handle_args_ganbreeder_login_no_keys(self): + argv = [ + '-u', '[email protected]',# user name + '-p', 'password123',# password + ] + try: + args = cli.handle_args(argv=argv) + except: + return # this is supposed to cause an exception + validate_args(args) + + def test_handle_args_ganbreeder_login_empty(self): + argv = [] + args = cli.handle_args(argv=argv) + validate_args(args) + if __name__ == '__main__': unittest.main() |