Beispiel #1
0
    def test_apply_defaults(self, tmpdir, debug, verbose, defaults):
        cider = Cider(False, debug, verbose, cider_dir=str(tmpdir))
        cider.defaults = MagicMock()
        cider.read_defaults = MagicMock(return_value=defaults)
        cider.apply_defaults()

        for domain, options in defaults.items():
            for key, value in options.items():
                cider.defaults.write.assert_any_call(domain, key, value)
Beispiel #2
0
    def test_apply_defaults(self, tmpdir, debug, verbose, defaults):
        cider = Cider(False, debug, verbose, cider_dir=str(tmpdir))
        cider.defaults = MagicMock()
        cider.read_defaults = MagicMock(return_value=defaults)
        cider.apply_defaults()

        for domain, options in defaults.items():
            for key, value in options.items():
                cider.defaults.write.assert_any_call(domain, key, value)
Beispiel #3
0
    def test_set_default(self, tmpdir, debug, verbose, domain, key, values,
                         bool_values, force):
        cider = Cider(False, debug, verbose, cider_dir=str(tmpdir))
        cider.defaults = MagicMock()

        for value in values + map(random_case, bool_values):
            json_value = cider.json_value(value)
            cider.set_default(domain, key, value, force=force)
            cider.defaults.write.assert_called_with(domain, key, json_value,
                                                    force)

            assert cider.read_defaults()[domain][key] == json_value

            # Verify str(value) => defaults.write(value)
            cider.set_default(domain, key, str(value), force=force)
            cider.defaults.write.assert_called_with(
                domain, key, cider.json_value(str(value)), force)
Beispiel #4
0
    def test_set_default(
        self, tmpdir, debug, verbose, domain, key, values, bool_values, force
    ):
        cider = Cider(False, debug, verbose, cider_dir=str(tmpdir))
        cider.defaults = MagicMock()

        for value in values + map(random_case, bool_values):
            json_value = cider.json_value(value)
            cider.set_default(domain, key, value, force=force)
            cider.defaults.write.assert_called_with(
                domain, key, json_value, force
            )

            assert cider.read_defaults()[domain][key] == json_value

            # Verify str(value) => defaults.write(value)
            cider.set_default(domain, key, str(value), force=force)
            cider.defaults.write.assert_called_with(
                domain, key, cider.json_value(str(value)), force
            )
Beispiel #5
0
 def test_remove_default(self, tmpdir, debug, verbose, domain, key):
     cider = Cider(False, debug, verbose, cider_dir=str(tmpdir))
     cider.defaults = MagicMock()
     cider.remove_default(domain, key)
     cider.defaults.delete.assert_called_with(domain, key)
     assert key not in cider.read_defaults().get(domain, [])
Beispiel #6
0
 def test_remove_default(self, tmpdir, debug, verbose, domain, key):
     cider = Cider(False, debug, verbose, cider_dir=str(tmpdir))
     cider.defaults = MagicMock()
     cider.remove_default(domain, key)
     cider.defaults.delete.assert_called_with(domain, key)
     assert key not in cider.read_defaults().get(domain, [])