| 38 | |
| 39 | |
| 40 | class MainTest(unittest.TestCase): |
| 41 | def test_main_smoke_user_error(self): |
| 42 | with self.assertRaises(SystemExit) as e: |
| 43 | main.main() |
| 44 | self.assertEqual(e.exception.code, 2) |
| 45 | |
| 46 | def test_main_smoke_help(self): |
| 47 | with self.assertRaises(SystemExit) as e: |
| 48 | main.main(['--help']) |
| 49 | self.assertEqual(e.exception.code, 0) |
| 50 | |
| 51 | def test_main_smoke_help_short(self): |
| 52 | with self.assertRaises(SystemExit) as e: |
| 53 | main.main(['-h']) |
| 54 | self.assertEqual(e.exception.code, 0) |
| 55 | |
| 56 | def test_main_missing_adv_format(self): |
| 57 | string_list = '--severity critical'.split() |
| 58 | with self.assertRaises(SystemExit) as e: |
| 59 | main.main(string_list) |
| 60 | self.assertEqual(e.exception.code, 2) |
| 61 | |
| 62 | def test_main_unknown_adv_format(self): |
| 63 | string_list = '--unknown'.split() |
| 64 | with self.assertRaises(SystemExit) as e: |
| 65 | main.main(string_list) |
| 66 | self.assertEqual(e.exception.code, 2) |
| 67 | |
| 68 | def test_main_filter_forbidden_by_api(self): |
| 69 | se = '2017-06-20', '2017-06-21' |
| 70 | s_e = DATE_SEP_TOKEN.join(se) |
| 71 | string_list = ( |
| 72 | '--cvrf --product foo --first_published {}'.format(s_e).split()) |
| 73 | with self.assertRaises(SystemExit) as e: |
| 74 | main.main(string_list) |
| 75 | self.assertEqual(e.exception.code, 2) |
| 76 | |
| 77 | def test_main_filter_date_format_end_missing(self): |
| 78 | se = '2017-06-20', '' |
| 79 | s_e = DATE_SEP_TOKEN.join(se) |
| 80 | string_list = ( |
| 81 | '--cvrf --product foo --first_published {}'.format(s_e).split()) |
| 82 | with self.assertRaises(SystemExit) as e: |
| 83 | main.main(string_list) |
| 84 | self.assertEqual(e.exception.code, 2) |
| 85 | |
| 86 | def test_main_filter_date_format_sep_bad(self): |
| 87 | se = '2017-06-20', '2017-06-21' |
| 88 | s_e = 'P'.join(se) |
| 89 | string_list = ( |
| 90 | '--cvrf --product foo --first_published {}'.format(s_e).split()) |
| 91 | with self.assertRaises(SystemExit) as e: |
| 92 | main.main(string_list) |
| 93 | self.assertEqual(e.exception.code, 2) |
| 94 | |
| 95 | def test_main_filter_date_format_end_bad(self): |
| 96 | se = '2017-06-20', '2017-06-00' |
| 97 | s_e = DATE_SEP_TOKEN.join(se) |
nothing calls this directly
no outgoing calls
no test coverage detected