def test_input_to_output(self): # Set up entity with ability data entity = self.per_test_set_up() self.manager.system.get(OutputSystem)._unit_test(self.recv_output) # Ok... test the ability command. context = UnitTestContext(self) # no initial sub-context # Do the test command event. event = CommandInputEvent(entity.id, entity.type_id, context, "/ability $dex.mod + 4") self.trigger_events(event, expected_events=0) with log.LoggingManager.on_or_off(self.debugging): self.engine_tick(1) self.assertTrue(self.output_recvd) self.assertIsInstance(self.output_recvd, Envelope) self.assertEqual(self.output_recvd.desired_recipients, Recipient.BROADCAST) self.assertEqual(self.output_recvd.valid_recipients, Recipient.BROADCAST) # Should be EntityId:001 self.assertEqual(self.output_recvd.source_id.value, 1) # Envelope's data is the math tree results. Make sure they're what we # expect. self.assertIsInstance(self.output_recvd.data, MathTree) # Aluminum Dragon's data is: # veredi/zest/zata/integration/repository/file-tree/game/test-campaign/monsters/dragon/aluminum_dragon.yaml # Aluminum Dragon's Dex is: 10 (mod == 0) # dex.mod + 4 = 4 self.assertEqual(self.output_recvd.data.value, 4) self.manager.system.get(OutputSystem)._unit_test()
def test_cmd_alias(self): self.set_up_events() self.allow_registration() entity = self.create_entity() context = UnitTestContext(self) # no initial sub-context # Do the test command event. event = CommandInputEvent(entity.id, entity.type_id, context, "/ability $str.mod + 4") self.trigger_events(event, expected_events=0)
def test_skill_cmd(self): # Set up entity with skill data entity = self.per_test_set_up() # Let the commands register self.allow_registration() # Ok... test the skill command. context = UnitTestContext(self) # no initial sub-context # Do the test command event. event = CommandInputEvent(entity.id, entity.type_id, context, "/skill $perception + 4") self.trigger_events(event, expected_events=0)
def test_debug_background_cmd(self): self.engine_life_start() # Set up entity. Not much use right now but we need to test debug # command permissions someday so hi there debug guy. admin = self.create_entity() # Ok... test the background debug command context = UnitTestContext(self) # no initial sub-context # Do the test command event. event = CommandInputEvent( admin.id, admin.type_id, context, "/debug background") self.capture_logs(True) self.trigger_events(event, expected_events=0) self.capture_logs(False) self.assertTrue(self.logs) # Look through any received logs for our command output. log_level = None log_msg = None for captured_log in self.logs: if veredi.zest.debug.background._LOG_TITLE in captured_log[1]: log_level = captured_log[0] log_msg = captured_log[1] break else: self.fail("No background debug log found. log level: " f"{log_level}, log msg: {log_msg}") # TODO: Check output more, somehow? self.assertEqual(log_level, log.Level.CRITICAL) self.assertIn(veredi.zest.debug.background._LOG_TITLE, log_msg)