@@ -251,6 +251,12 @@ def test_generate_world_items(self):
251251 shield = result .items [1 ]
252252 assert (shield ['name' ] == 'shield' )
253253
254+ self .llm_util ._world_building .io_util .response = ''
255+ result = self .llm_util ._world_building .generate_world_items (world_generation_context = WorldGenerationContext (story_context = '' ,story_type = '' ,world_info = '' ,world_mood = 0 ))
256+ assert not result .valid
257+ assert (len (result .items ) == 0 )
258+
259+
254260 def test_generate_world_creatures (self ):
255261 # mostly for coverage
256262 self .llm_util ._world_building .io_util .response = '{"creatures":[{"name": "dragon", "body": "Creature", "unarmed_attack": "BITE", "hp":100, "level":10}]}'
@@ -263,6 +269,10 @@ def test_generate_world_creatures(self):
263269 assert (dragon ["level" ] == 10 )
264270 assert (dragon ["unarmed_attack" ] == UnarmedAttack .BITE .name )
265271
272+ self .llm_util ._world_building .io_util .response = ''
273+ result = self .llm_util ._world_building .generate_world_creatures (world_generation_context = WorldGenerationContext (story_context = '' ,story_type = '' ,world_info = '' ,world_mood = 0 ))
274+ assert not result .valid
275+ assert (len (result .creatures ) == 0 )
266276
267277 def test_get_neighbor_or_generate_zone (self ):
268278 """ Tests the get_neighbor_or_generate_zone method of llm_utils.
@@ -472,6 +482,25 @@ def test_issue_overwriting_exits(self):
472482 assert ((len (rocky_cliffs .exits ) == 6 ))
473483 assert ((len (location_response .new_locations ) == 2 ))
474484
485+ def test_generate_location_empty_response (self ):
486+ self .llm_util ._world_building .io_util .response = ''
487+ location = Location (name = 'Outside' )
488+ result = self .llm_util .generate_start_location (location ,
489+ story_type = '' ,
490+ story_context = '' ,
491+ zone_info = {},
492+ world_info = '' )
493+ assert result .empty ()
494+
495+ self .llm_util ._world_building .io_util .response = '{}'
496+ location = Location (name = 'Outside' )
497+ result = self .llm_util .generate_start_location (location ,
498+ story_type = '' ,
499+ story_context = '' ,
500+ zone_info = {},
501+ world_info = '' )
502+ assert result .empty ()
503+
475504 def test_generate_note_lore (self ):
476505 self .llm_util ._quest_building .io_util .response = 'A long lost tale of a hero who saved the world from a great evil.'
477506 world_generation_context = WorldGenerationContext (story_context = self .story .config .context , story_type = self .story .config .type , world_info = '' , world_mood = 0 )
0 commit comments