def test_api_check_returns_field_boolean_value(self): api = BdfCallbacks(Registry()) a_object = api.register('a_object', Object) a_object_instance = api.registry.get_instance(a_object) a_object_instance.boolean_field = False self.assertFalse(api.check(a_object, 'boolean_field')) a_object_instance.boolean_field = True self.assertTrue(api.check(a_object, 'boolean_field'))
def test_api_check_object_is_activated(self): class AObject(Object): activate = MagicMock() api = BdfCallbacks(Registry()) a_object = api.register('a_object', AObject) a_object_instance = api.registry.get_instance(a_object) api.check(a_object, 'any_field') a_object_instance.activate.assert_called_once()
def bdf(api: BdfCallbacks): c = api.register('a_condition', ACondition) b = api.register('a_behavior', ABehavior) if api.check(c, 'a_condition_field'): api.activate(b)
def test_api_check_non_existent_field_returns_false(self): api = BdfCallbacks(Registry()) a_object = api.register('a_object', Object) self.assertFalse(api.check(a_object, 'non_existent_field'))