class CheckShots(unittest.TestCase): def setUp(self): self.gamedata = gamedata[0] self.filename = self.gamedata['filename'] self.obj = ShotExtract(**self.gamedata) self.away_team = self.gamedata['away_team'] self.home_team = self.gamedata['home_team'] def testPlayerData(self): for itm in self.obj.getHomePlayers(): self.assertEqual(len(itm),9) for itm in self.obj.getAwayPlayers(): self.assertEqual(len(itm),9) def testCourtDimensions(self): self.assertEqual(self.obj.assertCourtDimensions(),(300, 282)) def testShotDefinitions(self): shots = db.nba_query("SELECT * FROM cbsshot") for line in self.obj.assertShotDefinitions(): converted = (int(line[0]),line[1]) self.assertTrue(converted in shots, "%s not found in known shots" % str(line)) def testShotData(self): for row in self.obj.getShotData(): self.assertEqual(len(row),10) def testAwayAndHomeTeams(self): self.assertTrue(self.obj.away_team,self.away_team) self.assertTrue(self.obj.home_team,self.home_team) def testExtract(self): self.obj.extractAndDump() self.assertTrue(self.filename + '_players' in os.listdir(LOGDIR_EXTRACT)) self.assertTrue(self.filename + '_shots' in os.listdir(LOGDIR_EXTRACT))
class CheckShots(unittest.TestCase): def setUp(self): self.gamedata = gamedata[0] self.filename = self.gamedata['filename'] self.obj = ShotExtract(**self.gamedata) self.away_team = self.gamedata['away_team'] self.home_team = self.gamedata['home_team'] def testPlayerData(self): for itm in self.obj.getHomePlayers(): self.assertEqual(len(itm), 9) for itm in self.obj.getAwayPlayers(): self.assertEqual(len(itm), 9) def testCourtDimensions(self): self.assertEqual(self.obj.assertCourtDimensions(), (300, 282)) def testShotDefinitions(self): shots = db.nba_query("SELECT * FROM cbsshot") for line in self.obj.assertShotDefinitions(): converted = (int(line[0]), line[1]) self.assertTrue(converted in shots, "%s not found in known shots" % str(line)) def testShotData(self): for row in self.obj.getShotData(): self.assertEqual(len(row), 10) def testAwayAndHomeTeams(self): self.assertTrue(self.obj.away_team, self.away_team) self.assertTrue(self.obj.home_team, self.home_team) def testExtract(self): self.obj.extractAndDump() self.assertTrue(self.filename + '_players' in os.listdir(LOGDIR_EXTRACT)) self.assertTrue(self.filename + '_shots' in os.listdir(LOGDIR_EXTRACT))
def setUp(self): self.gamedata = gamedata[0] self.filename = self.gamedata['filename'] self.obj = ShotExtract(**self.gamedata) self.away_team = self.gamedata['away_team'] self.home_team = self.gamedata['home_team']