diff --git a/cos_alerter/alerter.py b/cos_alerter/alerter.py index 07a442a..4b90b22 100644 --- a/cos_alerter/alerter.py +++ b/cos_alerter/alerter.py @@ -76,7 +76,7 @@ def reload(self): base_dir = xdg_base_dirs.xdg_state_home() / "cos_alerter" if not base_dir.exists(): base_dir.mkdir(parents=True) - self.data["state_file"] = base_dir / "clients.state" + self.data["clients_file"] = base_dir / "clients.state" def deep_update(base: dict, new: typing.Optional[dict]): @@ -161,10 +161,10 @@ def initialize(): } # Recover any state that was dumped on last exit. - if config["state_file"].exists(): - with config["state_file"].open() as f: + if config["clients_file"].exists(): + with config["clients_file"].open() as f: existing_clients = json.load(f) - config["state_file"].unlink() + config["clients_file"].unlink() for client in existing_clients: if client in state["clients"]: state["clients"][client]["alert_time"] = existing_clients[client]["alert_time"] @@ -193,7 +193,7 @@ def dump_and_pause(): # pragma: no cover } for client in state["clients"] } - with config["state_file"].open("w") as f: + with config["clients_file"].open("w") as f: json.dump(clients_without_locks, f) @staticmethod diff --git a/tests/test_alerter.py b/tests/test_alerter.py index 2cbe389..e446672 100644 --- a/tests/test_alerter.py +++ b/tests/test_alerter.py @@ -173,8 +173,8 @@ def test_is_down_from_graceful_shutdown(monotonic_mock, fake_fs): with open("/etc/cos-alerter.yaml", "w") as f: yaml.dump(conf, f) config.reload() - fake_fs.create_file(config["state_file"]) - with config["state_file"].open("w") as f: + fake_fs.create_file(config["clients_file"]) + with config["clients_file"].open("w") as f: f.write('{"clientid1": {"alert_time": 500, "notify_time": null}}') monotonic_mock.return_value = 1000 print("Hello Test")