コード例 #1
0
 def test_calculate_subraces_lowrolls(self, mockrand):
     self.redis.lpush('npc_race','gnome')
     city = City(self.redis)
     mockrand.randint.side_effect = [11, 1, 2, 3, 4, 5, 6, 7, 8, 9]
     mockredis = Mock(self.redis)
     mockredis.lrange = MagicMock(return_value=['halfelf', 'wildelf', 'woodelf', 'darkelf'])
     city.redis = mockredis
     subraces = city.calculate_which_subraces('elf', 40)
     self.assertDictEqual({'halfelf': 34, 'darkelf': 3, 'wildelf': 1, 'woodelf': 2}, subraces)
コード例 #2
0
 def test_calculate_racial_breakdown_lowrolls(self, mockrand):
     self.redis.lpush('npc_race','gnome')
     city = City(self.redis)
     mockrand.randint.side_effect = [11, 1, 2, 3, 4, 5, 6, 7, 8, 9]
     mockredis = Mock(self.redis)
     mockredis.lrange = MagicMock(return_value=['orc', 'ogre', 'molekin'])
     city.redis = mockredis
     city.calculate_racial_breakdown()
     self.assertLess(0, len(city.races))
     self.assertDictEqual({'molekin': 3, 'other': 94, 'orc': 1, 'ogre': 2}, city.races)
コード例 #3
0
 def test_calculate_racial_breakdown(self, mockrand):
     """  """
     self.redis.lpush('npc_race','gnome')
     city = City(self.redis)
     mockrand.randint.side_effect = [11, 30, 30, 30, 30]
     mockredis = Mock(self.redis)
     mockredis.lrange = MagicMock(return_value=['orc', 'ogre', 'molekin', 'human', 'harpy', 'halfling', 'elf'
                                                'goblin', 'gnome', 'dwarf', 'coatikin', 'bugbear', 'catfolk'])
     city.redis = mockredis
     city.calculate_racial_breakdown()
     self.assertLess(0, len(city.races))
     self.assertDictEqual({'molekin': 29, 'other': 11, 'orc': 30, 'ogre': 30}, city.races)
コード例 #4
0
 def test_calculate_subraces(self, mockrand):
     self.redis.lpush('npc_race', 'gnome')
     city = City(self.redis)
     mockrand.randint.side_effect = [29, 2, 39, 4, 5, 6, 7, 8, 9]
     mockredis = Mock(self.redis)
     mockredis.lrange = MagicMock(
         return_value=['halfelf', 'wildelf', 'woodelf', 'darkelf'])
     city.redis = mockredis
     subraces = city.calculate_which_subraces('elf', 40)
     self.assertDictEqual({
         'halfelf': 29,
         'wildelf': 2,
         'woodelf': 9
     }, subraces)
コード例 #5
0
    def test_get_scale(self):
        mockredis = Mock(self.redis)
        self.redis.lpush('npc_race','gnome')
        city = City(self.redis)
        citydata = [
            '{"maxpop": "100", "max_density": "400", "name": "settlement", "min_density": "10", "minpop": "25"}',
            '{"maxpop": "500", "max_density": "2000", "name": "hamlet", "min_density": "20", "minpop": "101"}',
            '{"maxpop": "600", "max_density": "2400", "name": "small village", "min_density": "30", "minpop": "501"}'
            ]

        mockredis.zrange = MagicMock(return_value=citydata)
        city.redis = mockredis
        scale = city.get_scale()
        self.assertEqual([{u'name': u'settlement'}, {u'name': u'hamlet'}, {u'name': u'small village'}], scale)
コード例 #6
0
 def test_calculate_racial_breakdown_lowrolls(self, mockrand):
     self.redis.lpush('npc_race', 'gnome')
     city = City(self.redis)
     mockrand.randint.side_effect = [11, 1, 2, 3, 4, 5, 6, 7, 8, 9]
     mockredis = Mock(self.redis)
     mockredis.lrange = MagicMock(return_value=['orc', 'ogre', 'molekin'])
     city.redis = mockredis
     city.calculate_racial_breakdown()
     self.assertLess(0, len(city.races))
     self.assertDictEqual({
         'molekin': 3,
         'other': 94,
         'orc': 1,
         'ogre': 2
     }, city.races)
コード例 #7
0
 def test_calculate_racial_breakdown(self, mockrand):
     """  """
     self.redis.lpush('npc_race', 'gnome')
     city = City(self.redis)
     mockrand.randint.side_effect = [11, 30, 30, 30, 30]
     mockredis = Mock(self.redis)
     mockredis.lrange = MagicMock(return_value=[
         'orc', 'ogre', 'molekin', 'human', 'harpy', 'halfling', 'elf'
         'goblin', 'gnome', 'dwarf', 'coatikin', 'bugbear', 'catfolk'
     ])
     city.redis = mockredis
     city.calculate_racial_breakdown()
     self.assertLess(0, len(city.races))
     self.assertDictEqual(
         {
             'molekin': 29,
             'other': 11,
             'orc': 30,
             'ogre': 30
         }, city.races)
コード例 #8
0
    def test_get_scale(self):
        mockredis = Mock(self.redis)
        self.redis.lpush('npc_race', 'gnome')
        city = City(self.redis)
        citydata = [
            '{"maxpop": "100", "max_density": "400", "name": "settlement", "min_density": "10", "minpop": "25"}',
            '{"maxpop": "500", "max_density": "2000", "name": "hamlet", "min_density": "20", "minpop": "101"}',
            '{"maxpop": "600", "max_density": "2400", "name": "small village", "min_density": "30", "minpop": "501"}'
        ]

        mockredis.zrange = MagicMock(return_value=citydata)
        city.redis = mockredis
        scale = city.get_scale()
        self.assertEqual([{
            u'name': u'settlement'
        }, {
            u'name': u'hamlet'
        }, {
            u'name': u'small village'
        }], scale)