示例#1
0
 def commit_matchups(self):
     for id, data in self.player_id_to_data.items():
         data['player_id'] = id
         matchup = self.for_matchup(data)
         row = Matchup.get_or_create(matchup, self.db)
         data['matchup_id'] = row.id
     self.db.session.commit()
示例#2
0
 def test_get_or_create(self):
     tim = PlayerTest().add_player()
     self.assertTrue(tim.id)
     data = {
         "player_id": tim.id,
         "week": "THE_WEEK",
         "opponent": "Ind",
         "team": "NE",
         "home_game": True
     }
     matchup = Matchup.get_or_create(data)
     self.assertTrue(matchup)
     self.assertEqual(data['week'], matchup.week)
     self.assertEqual(tim.id, matchup.player_id)
     another = Matchup.get_or_create(data)
     self.assertEqual(matchup, another)
     again = Matchup.get_or_create(data)
     self.assertEqual(matchup, again)