def test_objects_get_removed_after_truncate_command(self): attacker = Player(name='AttackerTest') attacker.save() self.assertEqual(Player.objects.all().count(), 1) victim = Player(name='VictimTest') victim.save() self.assertEqual(Player.objects.all().count(), 2) game = Game(id=10, fraglimit=50) game.save() self.assertEqual(Game.objects.all().count(), 1) frag = Frag(attacker=attacker, victim=victim, game=game, weapon='MOD_SHOTGUN') frag.save() self.assertEqual(Frag.objects.all().count(), 1) score = Scoreboard(player=attacker, score=12, game=game) score.save() self.assertEqual(Scoreboard.objects.all().count(), 1) call_command('truncate') self.assertEqual(Frag.objects.all().count(), 0) self.assertEqual(Player.objects.all().count(), 0) self.assertEqual(Scoreboard.objects.all().count(), 0) self.assertEqual(Game.objects.all().count(), 0)
return d[6:] + "-" + d[0:2] + "-" + d[3:5] def timeToSeconds(t): return float(t[0:2]) * 60 + float(t[3:]) notduplicated = [] teamteam = [] dups, games, ignored = 0, 0, 0 f = open(sys.argv[1], 'r') stats = csv.reader(f) flag = True for row in stats: if flag: flag = False continue g = Game(date = changeDate(row[0])) if sys.argv[2] != 'l': if row[30] == 'H': g.teamH = row[1] g.scoreH = row[2] g.firstDownH = row[3] g.thirdDownPctH = float(row[4][0:-1]) / 100 g.rushAttH = row[5] g.rushYdsH = row[6] g.passAttH = row[7] g.passCompH = row[8] g.passYdsH = row[9] g.passIntH = row[10] g.fumblesH = row[11] g.sackYdsH = row[12] g.penYdsH = row[13]
def add_new_game(self, game_id, parser_scoreboard): Game(id=game_id, fraglimit=parser_scoreboard.get_fraglimit()).save() print( "%s: added game (%s, %s)" % (self.database_prefix, game_id, parser_scoreboard.get_fraglimit())) self.add_scoreboard(parser_scoreboard.get_scoreboard(), game_id)