MCPcopy Create free account
hub / github.com/CiscoPSIRT/openVulnQuery / CliApiTest

Class CliApiTest

tests/test_cli_api.py:14–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12SAMPLE_CLIENT_SECRET = 'DeadFaceDeadFaceDeadFace'
13
14class CliApiTest(unittest.TestCase):
15 def test_cli_api_unchanged_date_sep_token(self):
16 se = '2017-06-20', '2017-06-21'
17 s_e = DATE_SEP_TOKEN.join(se)
18 self.assertTupleEqual(
19 cli_api.valid_date(s_e), se)
20
21 def test_cli_api_unchanged_date_parser_format(self):
22 se = '1999-12-31', '2000-02-28'
23 s_e = DATE_SEP_TOKEN.join(se)
24 self.assertTupleEqual(
25 cli_api.valid_date(s_e), se)
26
27 def test_cli_api_date_date_sep_token_nok(self):
28 se = '2017-06-20', '2017-06-21'
29 s_e = ' '.join(se)
30 with self.assertRaises(argparse.ArgumentTypeError):
31 cli_api.valid_date(s_e)
32
33 def test_cli_api_date_parser_format_nok(self):
34 se = '19991231', '20000228'
35 s_e = DATE_SEP_TOKEN.join(se)
36 self.assertRaises(argparse.ArgumentTypeError, cli_api.valid_date, s_e)
37
38 def test_cli_api_date_parser_start_after_end(self):
39 se = '2000-02-28', '1999-12-31'
40 s_e = DATE_SEP_TOKEN.join(se)
41 self.assertRaises(argparse.ArgumentTypeError, cli_api.valid_date, s_e)
42
43 def test_cli_api_date_parser_start_after_now(self):
44 se = '9998-12-31', '9999-02-28'
45 s_e = DATE_SEP_TOKEN.join(se)
46 self.assertRaises(argparse.ArgumentTypeError, cli_api.valid_date, s_e)
47
48 def test_cli_api_date_parser_end_after_now(self):
49 se = '1999-12-31', '9999-02-28'
50 s_e = DATE_SEP_TOKEN.join(se)
51 self.assertRaises(argparse.ArgumentTypeError, cli_api.valid_date, s_e)
52
53 def test_add_options_to_parser_alien_target(self):
54 self.assertRaises(
55 NotImplementedError, cli_api.add_options_to_parser, '', '')
56
57 def test_parser_factory_dynamic_succeeds(self):
58 self.assertTrue(cli_api.parser_factory())
59
60 def test_parser_factory_dynamic_yields_expected_parser_type(self):
61 self.assertTrue(
62 isinstance(cli_api.parser_factory(), argparse.ArgumentParser))
63
64 def test_cli_api_process_command_line_help(self):
65 with self.assertRaises(SystemExit) as e:
66 cli_api.process_command_line(['--help'])
67 self.assertEqual(e.exception.code, 0)
68
69 def test_cli_api_process_command_line_help_short(self):
70 with self.assertRaises(SystemExit) as e:
71 cli_api.process_command_line(['-h'])

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected