コード例 #1
0
 def __getProfiles__(self, data):
     profileExtractor = PlayerExtractor() 
     statsExtractor = StatsExtractor()
     
     results = []
     for r in data:
         profile = profileExtractor.extract(r)
         profile["statistics"] = statsExtractor.extract(r)
         profile["positions"] = self.getPositions(r["id"])
         results.append(profile)
     return results
         
コード例 #2
0
class PlayerExtractorTest(unittest.TestCase):


    def setUp(self):
        self.__extractor = PlayerExtractor()


    def testExtractProfile(self):
        profile = self.__profileMap__()
        self.assertEquals(self.__extractor.extract(profile), profile)

    def textExtractProfile_withOtherData(self):
        profile = self.__profileMap__()
        profile["stats"] = None
        self.assertEquals(self.__extractor.extract(profile), self.__profileMap__())

    def __profileMap__(self, playerId=0, name="test", team="team", price=100, rating=100):
        return {
            "id": playerId,
            "name": name,
            "team": team,
            "price": price,
            "rating": rating
        }