Beispiel #1
0
 def test_incompatible_checked_not_defined(self):
     InputModifiers({
         "a": 1,
         "b": 2,
         "c": 3
     }).ensure_not_incompatible("x", ["a", "c"])
Beispiel #2
0
 def test_output_format(self):
     opt = "--output-format"
     val = "json"
     self.assertEqual(val, InputModifiers({opt: val}).get(opt))
Beispiel #3
0
 def test_not_specified_any(self):
     self.assertFalse(InputModifiers({"a": "1"}).is_specified_any(["b"]))
Beispiel #4
0
 def test_mutually_exclusive_not_specified(self):
     InputModifiers({
         "a": 1,
         "b": 2,
         "c": 3
     }).ensure_not_mutually_exclusive("x", "y")
Beispiel #5
0
 def test_get_non_existing(self):
     opt = "not_existing_option"
     with self.assertRaises(AssertionError) as cm:
         InputModifiers({}).get(opt)
     self.assertEqual(f"Non existing default value for '{opt}'",
                      str(cm.exception))
Beispiel #6
0
 def test_not_specified(self):
     self.assertFalse(InputModifiers({"a": "1"}).is_specified("b"))
Beispiel #7
0
 def test_multiple_get_existing(self):
     self.assertEqual(2, InputModifiers(dict(c=3, a=1, b=2)).get("b"))
Beispiel #8
0
 def test_explicit_default(self):
     val = "something"
     self.assertEqual(val, InputModifiers({}).get("--force", default=val))
Beispiel #9
0
 def test_get_existing(self):
     self.assertEqual(1, InputModifiers({"a": 1}).get("a"))
Beispiel #10
0
 def test_get_existing_with_default(self):
     self.assertEqual(1, InputModifiers({"a": 1}).get("a", default=2))
Beispiel #11
0
 def ensure(self, *specified):
     InputModifiers(self._get_specified(*specified)).ensure_only_supported(
         *self.supported)
Beispiel #12
0
 def test_dependencies_main_defined(self):
     InputModifiers({
         "a": 1,
         "b": 2,
         "c": 3
     }).ensure_dependency_satisfied("a", ["x", "y"])
Beispiel #13
0
 def test_output_format_default(self):
     self.assertEqual("text", InputModifiers({}).get("--output-format"))
Beispiel #14
0
 def test_wait(self):
     opt = "--wait"
     val = "something"
     self.assertEqual(val, InputModifiers({opt: val}).get(opt))
Beispiel #15
0
 def test_multiple_get_existing_with_default(self):
     self.assertEqual(
         2,
         InputModifiers(dict(c=3, a=1, b=2)).get("b", default=1))
Beispiel #16
0
 def test_wait_default(self):
     self.assertFalse(InputModifiers({}).get("--wait"))
Beispiel #17
0
 def test_default(self):
     self.assertEqual(2, InputModifiers({"a": 1}).get("b", default=2))
Beispiel #18
0
 def test_explicit_default_not_used(self):
     opt = "--force"
     self.assertTrue(InputModifiers({opt: ""}).get(opt, default=False))
Beispiel #19
0
 def test_debug_implicit(self):
     InputModifiers({"--debug": ""}).ensure_only_supported()
Beispiel #20
0
 def test_is_specified(self):
     self.assertTrue(InputModifiers({"a": "1"}).is_specified("a"))
Beispiel #21
0
 def test_bool_options(self):
     for opt in self.bool_opts:
         with self.subTest(opt=opt):
             self.assertTrue(InputModifiers({opt: ""}).get(opt), opt)
Beispiel #22
0
 def test_is_specified_any(self):
     self.assertTrue(
         InputModifiers({
             "a": "1"
         }).is_specified_any(["a", "b"]))
Beispiel #23
0
 def test_bool_options_defaults(self):
     for opt in self.bool_opts:
         with self.subTest(opt=opt):
             self.assertFalse(InputModifiers({}).get(opt), opt)
Beispiel #24
0
 def test_not_specified_any_default(self):
     self.assertFalse(
         InputModifiers({
             "a": "1"
         }).is_specified_any(["--debug"]))
Beispiel #25
0
 def test_val_options(self):
     val = "something"
     for opt in self.val_opts:
         with self.subTest(opt=opt):
             self.assertEqual(val, InputModifiers({opt: val}).get(opt), opt)
Beispiel #26
0
 def test_mutually_exclusive_one_specified(self):
     InputModifiers({
         "a": 1,
         "b": 2
     }).ensure_not_mutually_exclusive("a", "c")
Beispiel #27
0
 def test_val_options_defaults(self):
     for opt in self.val_opts:
         with self.subTest(opt=opt):
             self.assertIsNone(InputModifiers({}).get(opt), opt)
Beispiel #28
0
 def test_incompatible_incompatible_not_defined(self):
     InputModifiers({
         "a": 1,
         "b": 2,
         "c": 3
     }).ensure_not_incompatible("a", ["z", "y"])
Beispiel #29
0
def _modifiers(force=True):
    options = {}
    if force:
        options["--force"] = ""
    return InputModifiers(options)