From e321e1c89ac702a2b388ce5b5e1b4f34ce86745e Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Fri, 11 Aug 2023 13:47:13 +0200 Subject: 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. --- test.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'test.py') diff --git a/test.py b/test.py index c1a5423..8d217ca 100755 --- a/test.py +++ b/test.py @@ -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)) -- cgit v1.2.3