def test_select_subraces(self): """ verify subraces""" self.redis.lpush('npc_race', 'orc') self.redis.lpush('npc_race', 'elf') self.redis.set('elf_subrace_chance', 101) city = City(self.redis) city.races = { 'orc': 3, 'elf': { 'shadowelf': 18, 'snowelf': 11, 'waterelf': 11 } } city.select_subraces() self.assertDictEqual( { 'orc': 3, 'elf': { 'shadowelf': 18, 'snowelf': 11, 'waterelf': 11 } }, city.races)
def test_select_subraces(self): """ verify subraces""" self.redis.lpush('npc_race','orc') self.redis.lpush('npc_race','elf') self.redis.set('elf_subrace_chance',101) city = City(self.redis) city.races = {'orc': 3, 'elf': {'shadowelf': 18, 'snowelf': 11, 'waterelf': 11}} city.select_subraces() self.assertDictEqual({'orc': 3, 'elf': {'shadowelf': 18, 'snowelf': 11, 'waterelf': 11} }, city.races)
def test_select_no_subraces(self): """ verify subraces""" self.redis.lpush('npc_race', 'orc') self.redis.lpush('npc_race', 'elf') self.redis.set('elf_subrace_chance', 101) city = City(self.redis) city.races = {'orc': 3, 'elf': 40} city.select_subraces() self.assertEqual(3, city.races['orc']) self.assertNotEqual(40, city.races['elf']) total = 0 for elfkey in city.races['elf'].keys(): self.assertIn(elfkey, ['shadowelf', 'snowelf', 'waterelf']) self.assertLessEqual(city.races['elf'][elfkey], 40) total += city.races['elf'][elfkey] """ Our total subraces should be equal to our original race percentage""" self.assertEqual(total, 40)
def test_select_no_subraces(self): """ verify subraces""" self.redis.lpush('npc_race','orc') self.redis.lpush('npc_race','elf') self.redis.set('elf_subrace_chance',101) city = City(self.redis) city.races = {'orc': 3, 'elf':40} city.select_subraces() self.assertEqual(3, city.races['orc']) self.assertNotEqual(40, city.races['elf']) total=0 for elfkey in city.races['elf'].keys(): self.assertIn(elfkey, ['shadowelf','snowelf','waterelf']) self.assertLessEqual(city.races['elf'][elfkey], 40) total+=city.races['elf'][elfkey] """ Our total subraces should be equal to our original race percentage""" self.assertEqual(total, 40)