diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-08-11 13:47:13 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2023-08-11 13:47:13 +0200 |
| commit | e321e1c89ac702a2b388ce5b5e1b4f34ce86745e (patch) | |
| tree | fd922a0111ac76386e60727b7dad88feb6f6a2ca /test.py | |
| parent | 8f3bbb54a54232c97049ba8ebe587566e2987af8 (diff) | |
| download | geldschieberbot-e321e1c89ac702a2b388ce5b5e1b4f34ce86745e.tar.gz geldschieberbot-e321e1c89ac702a2b388ce5b5e1b4f34ce86745e.zip | |
extract message sending from the Geldschieberbot class
This makes the class more flexible and allows for different means of
sending the replies back by executing a subprocess or using dbus/jsonrpc.
Also remove the never used group send command.
Make the Geldschieberbot constructor parameters mandatory and let the
caller handle the configuration.
Diffstat (limited to 'test.py')
| -rwxr-xr-x | test.py | 19 |
1 files changed, 9 insertions, 10 deletions
@@ -12,8 +12,12 @@ from geldschieberbot import Geldschieberbot, GeldschieberbotJSONEncoder alice, bob, charlie = "alice", "bob", "charlie" num = {alice: "+49123456", bob: "+49654321", charlie: "+49615243"} -os.environ["GSB_GROUP_ID"] = "test" -os.environ["GSB_STATE_FILE"] = "test/state.json" + +DEFAULT_STATE_FILE = 'test/state.json' +DEFAULT_GROUP_ID = 'test' + +os.environ["GSB_GROUP_ID"] = DEFAULT_GROUP_ID +os.environ["GSB_STATE_FILE"] = DEFAULT_STATE_FILE os.environ["GSB_SEND_CMD"] = "cat" os.environ["GSB_SEND_GROUP"] = "cat" os.environ["GSB_SEND_USER"] = "cat" @@ -1391,19 +1395,14 @@ class TestConvertState(unittest.TestCase): class TestStateLoadStore(unittest.TestCase): - def test_default_init(self): - bot = Geldschieberbot() - self.assertTrue( - compare_state(os.environ['GSB_STATE_FILE'], state=bot.state)) - - def test_explicit_init(self): + def test_init(self): sp = "test/state_3users.json" - bot = Geldschieberbot(sp) + bot = Geldschieberbot(sp, DEFAULT_GROUP_ID) self.assertTrue(compare_state(sp, state=bot.state)) def test_explicit_load(self): sp = "test/state_3users.json" - bot = Geldschieberbot() + bot = Geldschieberbot(DEFAULT_STATE_FILE, DEFAULT_GROUP_ID) bot.load_state(sp) self.assertTrue(compare_state(sp, state=bot.state)) |
