Skip to content

Commit

Permalink
more appropriate variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
dstathis committed Feb 26, 2024
1 parent b809abb commit ee4b06e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions cos_alerter/alerter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]):
Expand Down Expand Up @@ -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"]
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/test_alerter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit ee4b06e

Please sign in to comment.