コード例 #1
0
def testUnplayedGames():
	expectedResults = (
		'date,time,team1,team1seed,team2,team2seed\n'
		'03-28-2014,7:15 PM,Tennessee,11,Michigan,2\n'
		'03-28-2014,7:27 PM,Connecticut,7,Iowa State,3\n'
		'03-28-2014,9:45 PM,Kentucky,8,Louisville,4\n'
		'03-28-2014,9:57 PM,Michigan State,4,Virginia,1\n'
	)
	testUnplayed = open('TestData/03-28-2014_unplayed.html')
	csvFileName = 'TestData/03-28-2014_unplayed.csv'
	csvFile = open(csvFileName, 'w')

	soup = BeautifulSoup(testUnplayed.read())
	AutomaticFunctions.notYetPlayed(csvFile, soup, '03-28-2014')

	for (expected, actual) in zip(expectedResults, open(csvFileName)):
		assert expected == actual
コード例 #2
0
def testPastGame():
	expectedResults = (
		'date,team1seed,team1,team1score,team2seed,team2,team2score\n',
		'03-23-2014,10,Stanford,60,2,Kansas,57\n',
		'03-23-2014,8,Kentucky,78,1,Wichita State,76\n',
		'03-23-2014,3,Iowa State,85,6,North Carolina,83\n',
		'03-23-2014,11,Tennessee,83,14,Mercer,63\n',
		'03-23-2014,4,UCLA,77,12,Stephen F. Austin,60\n',
		'03-23-2014,6,Baylor,85,3,Creighton,55\n',
		'03-23-2014,1,Virginia,78,8,Memphis,60\n',
		'03-23-2014,1,Arizona,84,8,Gonzaga,61\n',
	)

	monthName = 'March'
	monthNumber = '03'
	year = '2014'
	day = '23'
	AutomaticFunctions.downloadAndStoreGames(monthName, monthNumber, year, day, 'played', True, 'Tests')
	testFile = open('Tests/%s/%s/%s-%s-%s_played.csv' % (year, monthName, monthNumber, day, year))

	for (expected, actual) in zip(expectedResults, testFile):
		assert expected == actual
コード例 #3
0
ファイル: Automatic.py プロジェクト: CST316TeamJ/SportsApp
import datetime
from datetime import timedelta
import AutomaticFunctions
import MySqlConnector


database = MySqlConnector.MySqlConnector(1, 2014)


# TODAY
print "Today's upcoming games"
monthName = datetime.date.today().strftime('%B')
monthNumber = datetime.date.today().strftime('%m')
year = datetime.date.today().strftime('%Y')
day = datetime.date.today().strftime('%d')
AutomaticFunctions.downloadAndStoreGames(monthName, monthNumber, year, day, 'unplayed', False, 'Games')


# YESTERDAY
print "Yesterday's played games"
monthName = (datetime.date.today() - timedelta(1)).strftime('%B')
monthNumber = (datetime.date.today() - timedelta(1)).strftime('%m')
year = (datetime.date.today() - timedelta(1)).strftime('%Y')
day = (datetime.date.today() - timedelta(1)).strftime('%d')
AutomaticFunctions.downloadAndStoreGames(monthName, monthNumber, year, day, 'played', True, 'Games')