aboutsummaryrefslogtreecommitdiff
path: root/test/cli_test.py
diff options
context:
space:
mode:
authorVee9ahd1 <[email protected]>2019-06-03 16:16:51 -0400
committerVee9ahd1 <[email protected]>2019-06-03 16:16:51 -0400
commit16e8cb2ff9cc94265d3ad960d51ac8fa318b1b74 (patch)
tree02af6c5d7eb1288dd225df0895d29c6bb5017725 /test/cli_test.py
parent64307dc3dbe633d4ff8bfb80a7f5895f00019356 (diff)
added tests for ganbreeder login args
Diffstat (limited to 'test/cli_test.py')
-rw-r--r--test/cli_test.py60
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()