diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-08-11 14:17:20 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2023-08-11 14:17:20 +0200 |
| commit | c1a35a78595b4d75ac845af322f69a42c6f72bd3 (patch) | |
| tree | ecb09ed196cf13cb70ceec31a03039e93bcf3e73 | |
| parent | 00972de003602c433d87e4a35ba030672e10dd30 (diff) | |
| download | geldschieberbot-c1a35a78595b4d75ac845af322f69a42c6f72bd3.tar.gz geldschieberbot-c1a35a78595b4d75ac845af322f69a42c6f72bd3.zip | |
add doc strings and use more meaningful variable names
| -rwxr-xr-x | test.py | 25 |
1 files changed, 16 insertions, 9 deletions
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +"""System tests for the geldschieberbot""" from datetime import datetime, date, timedelta import json @@ -78,6 +79,7 @@ def _run_bot(sender, cmd): def run_bot(test, sender, cmd): + """Run the bot and check its status and error messages""" res = _run_bot(sender, cmd) test.assertEqual(res.returncode, 0) test.assertEqual(res.stderr, "") @@ -85,10 +87,12 @@ def run_bot(test, sender, cmd): def save_state(dest): + """Copy the used state file to a different location""" copyfile(os.environ["GSB_STATE_FILE"], dest) def reset_state(state=None): + """Reset or delete the used state file""" if state: copyfile(state, os.environ["GSB_STATE_FILE"]) else: @@ -98,24 +102,27 @@ def reset_state(state=None): def reset_state_string(string): - with open(os.environ["GSB_STATE_FILE"], "w", encoding='utf-8') as f: - json.dump(json.loads(string), f) + """Reset the used state to a string""" + with open(os.environ["GSB_STATE_FILE"], "w", + encoding='utf-8') as state_file: + json.dump(json.loads(string), state_file) def compare_state(expected_state_path, state=None, state_path=os.environ["GSB_STATE_FILE"]) -> bool: - s = '' + """Compare to states""" + state_str = '' if state is None: - with open(state_path, "r", encoding='utf-8') as sf: - s = sf.read() + with open(state_path, "r", encoding='utf-8') as state_file: + state_str = state_file.read() else: - s = json.dumps(state, cls=GeldschieberbotJSONEncoder) + state_str = json.dumps(state, cls=GeldschieberbotJSONEncoder) - with open(expected_state_path, "r", encoding='utf-8') as csf: - cs = csf.read() + with open(expected_state_path, "r", encoding='utf-8') as exp_state_file: + expected_state_str = exp_state_file.read() - return cs == s + return expected_state_str == state_str # pragma pylint: disable=missing-function-docstring,missing-class-docstring,invalid-name |
