def test_betting_makeBet_shouldNotMakeNaiveBet(self):
     # set up
     home = "Arsenal"
     away = "Man U"
     result = "H"
     chanceH = 0.3
     chanceA = 0.35
     chanceD = 0.35
     bet = "Don't make bet!"
     thresh = 0.4
     attrs = [
         "home team", "away team", "result", "chanceH", "chanceA",
         "chanceD", "bet"
     ]
     expected = "{0},{1},{2},{3},{4},{5},{6}\n".format(
         home, away, result, chanceH, chanceA, chanceD, bet)
     g = football.Game(attrs)
     # set the attributes
     g.setAttr("home team", home)
     g.setAttr("away team", away)
     g.setAttr("result", result)
     g.setAttr("chanceH", chanceH)
     g.setAttr("chanceA", chanceA)
     g.setAttr("chanceD", chanceD)
     g.setNaiveBet("chanceH", "chanceA", "chanceD", "bet", thresh)
     # excercise
     row = g.toCSVRow()
     # verify
     self.assertEqual(row, expected)
 def test_game_constructor_shouldCreateGame(self):
     # set up
     attrs = ["home team", "away team", "result"]
     # exerise
     g = football.Game(attrs)
     # verify
     self.assertEqual(len(g.attributes), 3)
 def test_game_setgetAttr_shouldSetAndGetAttributes(self):
     # set up
     teamname = "Arsenal"
     attrs = ["home team", "away team", "result"]
     g = football.Game(attrs)
     # exerise
     g.setAttr("home team", teamname)
     team = g.getAttr("home team")
     # verify
     self.assertEqual(team, teamname)
 def generate(self):
     # open the csv
     with open(self.path, 'rb') as statCsv:
         reader = csv.reader(statCsv)
         # print feature row
         self.printFeatures()
         for row in reader:
             # skip the heading row
             if (reader.line_num == 1): continue
             # create a new game and a game to hold data from csv row
             game = football.Game(self.features)
             rowGame = football.Game(self.columns)
             # populate the row variable with inital values from the row
             for i in range(0, len(self.columns)):
                 rowGame.setAttr(self.columns[i], row[i])
             # set up the teams and teamnames
             homeTeam = rowGame.getAttr(Constants.hometeam)
             awayTeam = rowGame.getAttr(Constants.awayteam)
             home = self.table.getTeam(homeTeam)
             away = self.table.getTeam(awayTeam)
             # set the date field
             self.setDate(game, rowGame)
             # set the game teams
             self.setTeamnames(game, home, away)
             # set the form fields
             self.setForm(game, home, away)
             # set the table position fields
             self.setTablePosition(game, home, away)
             # set the shots and shots on target per game
             self.setShots(game, rowGame, home, away)
             # set the game odds
             self.setOdds(game, rowGame)
             # set the goal difference
             self.setMatchRating(game, rowGame, home, away)
             # add the game to the list
             self.games.append(game)
             # update teams based on result
             self.setResult(game, rowGame, home, away)
             # print the game
             sys.stdout.write(game.toCSVRow())
 def test_game_toCSVRow_shouldReturnValidCsvRow(self):
     # set up
     home = "Arsenal"
     away = "Man U"
     result = "H"
     attrs = ["home team", "away team", "result"]
     expected = "{0},{1},{2}\n".format(home, away, result)
     g = football.Game(attrs)
     # set the attributes
     g.setAttr("home team", home)
     g.setAttr("away team", away)
     g.setAttr("result", result)
     # excercise
     row = g.toCSVRow()
     # verify
     self.assertEqual(row, expected)
 def test_betting_makeBet_shouldMakeBetDraw(self):
     # set up
     home = "Arsenal"
     away = "Man U"
     result = "H"
     chanceH = 0.25
     chanceA = 0.4
     chanceD = 0.35
     ratioH = 2.0
     ratioA = 2.4
     ratioD = 6.0
     bet = "Make bet on a draw!"
     thresh = 0.1
     attrs = [
         "home team", "away team", "result", "chanceH", "chanceA",
         "chanceD", "home ratio", "away ratio", "draw ratio", "bet"
     ]
     expected = "{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}\n".format(
         home, away, result, chanceH, chanceA, chanceD, ratioH, ratioA,
         ratioD, bet)
     g = football.Game(attrs)
     # set the attributes
     g.setAttr("home team", home)
     g.setAttr("away team", away)
     g.setAttr("result", result)
     g.setAttr("chanceH", chanceH)
     g.setAttr("chanceA", chanceA)
     g.setAttr("chanceD", chanceD)
     g.setAttr("home ratio", ratioH)
     g.setAttr("away ratio", ratioA)
     g.setAttr("draw ratio", ratioD)
     g.setBet("chanceH", "chanceA", "chanceD", "bet", thresh, "home ratio",
              "away ratio", "draw ratio")
     # excercise
     row = g.toCSVRow()
     # verify
     self.assertEqual(row, expected)