def test_Team_1(self):
		header = ["Div","Date","HomeTeam","AwayTeam","FTHG","FTAG","FTR","HTHG","HTAG","HTR","HST","AST","HS","AS","WHH","B365A"]
		values = ["E0","26/03/08","Bohs","Rowfus","4","1","H","3","1","H","4","4","10","5","1.1","1.2"]
		fixture1 = Fixture(header, values)

		header = ["Div","Date","HomeTeam","AwayTeam","FTHG","FTAG","FTR","HTHG","HTAG","HTR","HST","AST","HS","AS","WHH","B365A"]
		values = ["E0","27/03/08","Bohs","Rowfus","5","2","H","3","1","H","4","4","10","5","1.1","1.2"]
		fixture2 = Fixture(header, values)

		header = ["Div","Date","HomeTeam","AwayTeam","FTHG","FTAG","FTR","HTHG","HTAG","HTR","HST","AST","HS","AS","WHH","B365A"]
		values = ["E0","28/03/08","Bohs","Rowfus","3","1","H","1","1","D","4","4","10","5","1.1","1.2"]
		fixture3 = Fixture(header, values)

		header = ["Div","Date","HomeTeam","AwayTeam","FTHG","FTAG","FTR","HTHG","HTAG","HTR","HST","AST","HS","AS","WHH","B365A"]
		values = ["E0","28/03/08","Bohs","Rowfus","3","1","H","2","1","H","4","4","10","5","1.1","1.2"]
		fixture4 = Fixture(header, values)

		team = Team("Bohs")

		team.addFixture(fixture1)
		team.addFixture(fixture2)
		team.addFixture(fixture3)
		team.addFixture(fixture4)

		self.assertEquals(team.getProbWin(), 1.0)
	def test_GetPreviousResults_1(self):
		header = ["Div","Date","HomeTeam","AwayTeam","FTHG","FTAG","FTR","HTHG","HTAG","HTR","HST","AST","HS","AS","WHH","B365A"]
		values1 = ["E0","26/03/08","Bohs","Rowfus","2","1","H","0","1","H","1","1","4","1","1.1","1.2"]
		values2 = ["E0","27/03/08","Bohs","Rowfus","2","1","H","1","1","H","1","1","1","1","1.1","1.2"]
		values3 = ["E0","28/03/08","Bohs","Rowfus","2","1","H","1","1","D","1","1","1","1","1.1","1.2"]

		fixture1 = Fixture(header, values1)
		fixture2 = Fixture(header, values2)
		fixture3 = Fixture(header, values3)

		team = Team("Rowfus")
		team.addFixture(fixture1)
		team.addFixture(fixture2)
		team.addFixture(fixture3)

		results = team.getPreviousResults()
		result = True
		for testResult in results:
			if testResult != 'L':
				result = False
				break

		if len(results) != 3:
			result = False
					
		self.assertTrue(result)
	def test_GetPreviousLosses_2(self):
		header = ["Div","Date","HomeTeam","AwayTeam","FTHG","FTAG","FTR","HTHG","HTAG","HTR","HST","AST","HS","AS","WHH","B365A"]
		values1 = ["E0","28/03/08","Bohs","Rowfus","2","1","H","1","1","D","1","1","1","1","1.1","1.2"]
		values2 = ["E0","28/03/08","Bohs","Rowfus","2","2","H","1","1","D","1","1","1","1","1.1","1.2"]
		fixture1 = Fixture(header, values1)
		fixture2 = Fixture(header, values2)
		team = Team("Rowfus")
		team.addFixture(fixture2)
		result = team.getPreviousLosses(1)
		self.assertEquals(result, 0)
	def test_GetForm_4(self):
		header = ["Div","Date","HomeTeam","AwayTeam","FTHG","FTAG","FTR","HTHG","HTAG","HTR","HST","AST","HS","AS","WHH","B365A"]
		win = ["E0","26/03/08","Bohs","Rowfus","2","1","H","0","0","H","1","1","4","1","1.1","1.2"]
		loss = ["E0","26/03/08","Bohs","St. Pauli","0","3","H","0","1","H","1","1","4","1","1.1","1.2"]
		team = Team("Bohs")
		
		fixture1 = Fixture(header, win)
		fixture2 = Fixture(header, loss)
		team.addFixture(fixture2)
		team.addFixture(fixture1)

		result = team.getForm(5)
		self.assertEquals(result, 0.0)
	def test_GetForm_3(self):
		header = ["Div","Date","HomeTeam","AwayTeam","FTHG","FTAG","FTR","HTHG","HTAG","HTR","HST","AST","HS","AS","WHH","B365A"]
		win = ["E0","26/03/08","Bohs","Rowfus","2","1","H","0","0","H","1","1","4","1","1.1","1.2"]
		loss = ["E0","26/03/08","Bohs","St. Pauli","0","3","H","0","1","H","1","1","4","1","1.1","1.2"]
		team = Team("Bohs")
		
		for x in xrange(0, 20):
			fixture1 = Fixture(header, win)
			fixture2 = Fixture(header, loss)
			team.addFixture(fixture2)
			team.addFixture(fixture1)

		result = team.getForm(5)
		self.assertTrue(result > 0.45 and result < 0.65)
    def addFeatures(self, filename):
        """ Adds features from a specified filename.
		"""
        self.logger = logging.getLogger('LeaguePredict')

        # Read the CSV fixtures
        lineNum = 0
        header = None
        fixtureData = None
        fixturesList = []

        # Open and read the CSV fixtures file
        reader = csv.reader(open(filename, "rb"))
        for row in reader:
            if lineNum == 0:
                header = row
            else:
                fixtureData = row
                fixture = Fixture(header, fixtureData)
                fixturesList.append(fixture)
            lineNum += 1

        # Return the list of the fixtures in the CSV file
        self.logger.info('Read %d fixtures from %s (%d lines)',
                         len(fixturesList), filename, lineNum)

        # Initialise the features list
        self.setFeatures(fixturesList, filename)
	def test_GetPreviousWins_3(self):
		header = ["Div","Date","HomeTeam","AwayTeam","FTHG","FTAG","FTR","HTHG","HTAG","HTR","HST","AST","HS","AS","WHH","B365A"]
		values1 = ["E0","26/03/08","Bohs","Rowfus","2","1","H","0","1","H","1","1","4","1","1.1","1.2"]
		values2 = ["E0","27/03/08","Bohs","Rowfus","2","2","H","1","1","H","1","1","1","1","1.1","1.2"]
		values3 = ["E0","28/03/08","Bohs","Rowfus","2","2","H","1","1","D","1","1","1","1","1.1","1.2"]

		fixture1 = Fixture(header, values1)
		fixture2 = Fixture(header, values2)
		fixture3 = Fixture(header, values3)

		team = Team("Bohs")
		team.addFixture(fixture1)
		team.addFixture(fixture2)
		team.addFixture(fixture3)

		result = team.getPreviousWins(3)
		self.assertEquals(result, 1)
	def test_GetShots_3(self):
		header = ["Div","Date","HomeTeam","AwayTeam","FTHG","FTAG","FTR","HTHG","HTAG","HTR","HST","AST","HS","AS","WHH","B365A"]
		values = ["E0","26/03/08","Bohs","Rowfus","4","1","H","3","1","H","1","1","4","1","1.1","1.2"]
		fixture1 = Fixture(header, values)

		header = ["Div","Date","HomeTeam","AwayTeam","FTHG","FTAG","FTR","HTHG","HTAG","HTR","HST","AST","HS","AS","WHH","B365A"]
		values = ["E0","27/03/08","Bohs","Rowfus","5","2","H","3","1","H","1","1","1","1","1.1","1.2"]
		fixture2 = Fixture(header, values)

		header = ["Div","Date","HomeTeam","AwayTeam","FTHG","FTAG","FTR","HTHG","HTAG","HTR","HST","AST","HS","AS","WHH","B365A"]
		values = ["E0","28/03/08","Bohs","Rowfus","2","1","H","1","1","D","1","1","1","1","1.1","1.2"]
		fixture3 = Fixture(header, values)

		team = Team("Rowfus")
		team.addFixture(fixture1)
		team.addFixture(fixture2)
		team.addFixture(fixture3)

		total = fixture1.getHomeShots()
		total += fixture2.getHomeShots()
		total += fixture3.getHomeShots()

		self.assertEquals(total, 6)
	def test_RecentGA_1(self):
		header = ["Div","Date","HomeTeam","AwayTeam","FTHG","FTAG","FTR","HTHG","HTAG","HTR","HST","AST","HS","AS","WHH","B365A"]
		win = ["E0","26/03/08","Bohs","Rowfus","2","1","H","0","0","H","1","1","4","1","1.1","1.2"]
		loss = ["E0","26/03/08","Bohs","St. Pauli","0","3","H","0","1","H","1","1","4","1","1.1","1.2"]

		fixture1 = Fixture(header, loss)
		fixture2 = Fixture(header, loss)
		fixture3 = Fixture(header, loss)
		fixture4 = Fixture(header, loss)
		fixture5 = Fixture(header, win)
		fixture6 = Fixture(header, win)
		fixture7 = Fixture(header, loss)

		team = Team("Bohs")
		team.addFixture(fixture1)
		team.addFixture(fixture2)
		team.addFixture(fixture3)
		team.addFixture(fixture4)
		team.addFixture(fixture5)
		team.addFixture(fixture6)
		team.addFixture(fixture7)

		result = team.getRecentGA()
		self.assertEquals(result, 11)