def test_dispatch(self):
        a1 = Antenna()
        check_obj = {"checked": False}
        test_key = "test_2"

        def callback(one):
            check_obj["checked"] = True

        a1.add_listener(test_key, callback)
        a1.dispatch_message(test_key, None)

        self.assertTrue(check_obj)
    def test_execute_object_check(self):
        a1 = Antenna()
        key = "test_6"
        check_obj = "random_text"
        info = {"some": "thing"}

        def callback(info_obj):
            nonlocal check_obj
            check_obj = info_obj

        a1.add_listener(key, callback)
        a1.dispatch_message(key, info)

        self.assertEqual(check_obj, info)
 def test_dispatch_non_existing(self):
     a1 = Antenna()
     with self.assertRaises(KeyError):
         a1.dispatch_message("not_a_valid_key", fail_when_empty=True)
     a1.dispatch_message("also_not_a_valid_key")