コード例 #1
0
ファイル: TradeTest.py プロジェクト: eapeyton/tradeaide
    def testReadScoring(self):
        self.maxDiff = None
        exp_scoring = {'passing_yds': .04,
                       'passing_tds': 4,
                       'passing_int': -2,
                       'passing_twoptm': 2,
                       'rushing_yds': .1,
                       'rushing_tds': 6,
                       'rushing_att': 0,
                       'rushing_twoptm': 2,
                       'receiving_yds': .1,
                       'receiving_tds': 6,
                       'receiving_rec': 0,
                       'receiving_twoptm': 2,
                       "puntret_tds": 6,
                       "kickret_tds": 6,
                       'fumbles_tot': -2,
                       'kicking_fgm': 3,
                       'kicking_fgmissed': -1,
                       'kicking_xpmade': 1,
                       'kicking_xpmissed': -1}
        scoring = STD
        self.assertEqual(scoring, exp_scoring)

        exp_scoring['receiving_rec'] = 0.5
        scoring = Trade.extend_scoring_file(TestData('standard.json'), TestData('halfppr_ext.json'))
        self.assertEqual(scoring, exp_scoring)

        with self.assertRaises(Trade.NotEnoughRulesError):
            Trade.read_scoring_file(TestData('notenoughrules.json'))
コード例 #2
0
ファイル: TradeTest.py プロジェクト: eapeyton/tradeaide
import nfldb
import os
import unittest
import mock
import collections
import Trade
import json

def TestData(path):
    data = ''
    with open(os.path.join('testdata', path), 'r') as f:
        data = f.read()
    return data

STD = Trade.read_scoring_file(TestData('standard.json'))
PURE = Trade.read_scoring_file(TestData('pure.json'))

class PlayerDBTests(unittest.TestCase):
    def setUp(self):
        self.test_player1 = createQB(363, 1, 2, rushing_yds=3, rushing_att=1)
        self.test_player2 = createRB(57, 0, 11, receiving_rec=1, rushing_att=15)
        self.test_aggpps = [createPP('QB'), createPP('RB'), createPP('WR'),
                            createPP('TE'), createPP('RB'), createPP('RB')]


    def testAggPPToPlayer(self):
        playerDB = Trade.PlayerDB()
        db = nfldb.connect()
        q = nfldb.Query(db)
        q.game(gsis_id='2009091000')