def test_load_unusual(self, text, data, tmpdir):
        tmp = tmpdir / "test.conf"
        tmp.write("# univention_ base.conf\n" + text)

        ucr = backend._ConfigRegistry(str(tmp))
        ucr.load()
        assert ucr.items() == data.items()
    def test_busy(self, tmpdir):
        tmp = tmpdir / "test.conf"
        tmpdir.mkdir("test.conf.temp")

        ucr = backend._ConfigRegistry(str(tmp))
        with pytest.raises(EnvironmentError):
            ucr._save_file(str(tmp))
Example #3
0
 def _locked_app_ucr(cls, app):
     ucr_file = cls._get_app_ucr_filename(app)
     ucr = _ConfigRegistry(ucr_file)
     ucr.lock()
     try:
         ucr.load()
         yield ucr
     finally:
         ucr.unlock()
    def test_load_backup(self, tmpdir):
        tmp = tmpdir / "test.conf"
        tmp.write("")
        bak = tmpdir / "test.conf.bak"
        bak.write("#\nfoo: bar")

        ucr = backend._ConfigRegistry(str(tmp))
        ucr.load()
        assert ucr["foo"] == "bar"
        assert tmp.size() > 0
 def _get_app_ucr(cls, app):
     ucr_file = cls._get_app_ucr_filename(app)
     ucr = _ConfigRegistry(ucr_file)
     ucr.load()
     return ucr
 def test_devnull(self):
     ucr = backend._ConfigRegistry(os.path.devnull)
     ucr.save()
     assert os.path.exists(os.path.devnull)
     assert not os.path.isfile(os.path.devnull)
 def test_strict_value(self):
     ucr = backend._ConfigRegistry(os.path.devnull)
     ucr.strict_encoding = True
     with pytest.raises(backend.StrictModeException):
         ucr["key"] = b"\xff"
 def test_strict_key(self):
     ucr = backend._ConfigRegistry(os.path.devnull)
     ucr.strict_encoding = True
     with pytest.raises(backend.StrictModeException):
         ucr[b'\xff'] = "val"