def testEspysParameter(self):
        """Test that the espys are properly being calculated"""
        mocker = MockLeague(self)

        # add an espys to the team
        self.add_espys(mocker.get_teams()[0],
                       mocker.get_sponsor(),
                       points=1)

        # valid league id
        league_id = mocker.get_league()['league_id']
        team = mocker.get_teams()[0]
        team_id = team['team_id']
        rv = self.app.post(Routes['vteam'], json={'league_id': league_id})
        expect = {'games': 1,
                  'hits_allowed': 3,
                  'hits_for': 2,
                  'losses': 1,
                  'name': team['team_name'],
                  'runs_against': 6,
                  'runs_for': 1,
                  'ties': 0,
                  'wins': 0,
                  'espys': 1}
        self.output(loads(rv.data))
        self.output(expect)
        self.assertTrue(len(loads(rv.data).keys()) > 0,
                        Routes['vteam'] + " Post: valid year")
        self.assertEqual(expect,
                         loads(rv.data)[str(team_id)],
                         Routes['vteam'] + " Post: valid year")
    def testPlayerName(self):
        """Tests using a player name as a parameter"""
        mocker = MockLeague(self)
        league = mocker.get_league()
        team = mocker.get_teams()[0]
        player = mocker.get_players()[0]
        sponsor = mocker.get_sponsor()

        # test a test player names
        params = {'player_name': player['player_name']}
        rv = self.app.post(Routes['vplayerteamLookup'], json=params)
        expect = [{
            'captain': player,
            'color': team['color'],
            'espys': 0,
            'league_id': league['league_id'],
            'sponsor_id': sponsor['sponsor_id'],
            'team_id': team['team_id'],
            'team_name': team['team_name'],
            'year': team['year']
        }]
        self.output(loads(rv.data))
        self.output(expect)
        self.assertEqual(expect, loads(rv.data), Routes['vplayerteamLookup'])

        # test a test player names
        params = {'player_name': "Not a player"}
        rv = self.app.post(Routes['vplayerteamLookup'], json=params)
        expect = []
        self.output(loads(rv.data))
        self.output(expect)
        self.assertEqual(expect, loads(rv.data), Routes['vplayerteamLookup'])