def test_fail_arguments(self):
     expected_failures = (
         ("--status", "not a status"),
         ("--not-an-option",),
         ("--af", "5"),
         ("--type", "not a type"),
         ("--field", "not a field"),
     )
     for failure in expected_failures:
         with capture_sys_output():
             with self.assertRaises(SystemExit):
                 Command().init_args(failure)
Пример #2
0
 def test_get_filters(self):
     cmd = Command()
     cmd.init_args([
         "--search", "the force is strong with this one",
         "--status", "ongoing",
         "--af", "6",
         "--type", "ping",
         "--started-before", "2015-01-01",
         "--started-after", "2014-01-01",
         "--stopped-before", "2015-01-01",
         "--stopped-after", "2014-01-01",
     ])
     self.assertEqual(cmd._get_filters(), {
         "search": "the force is strong with this one",
         "status__in": (2,),
         "af": 6,
         "type": "ping",
         "start_time__lt": datetime.datetime(2015, 1, 1),
         "start_time__gt": datetime.datetime(2014, 1, 1),
         "stop_time__lt": datetime.datetime(2015, 1, 1),
         "stop_time__gt": datetime.datetime(2014, 1, 1),
     })