Пример #1
0
    def test_league_answers(self):
        data = DataSetup('api_league_answers')
        data.create_users(3)
        data.create_leagues(1)
        data.create_member(data.user[0].get_object(), data.league[0], True)
        data.create_member(data.user[1].get_object(), data.league[0], False)
        data.create_prop_bet(data.league[0], False)
        data.create_prop_bet(data.league[0], False)
        data.create_prop_bet(data.league[0], False)

        url = '/api/league/answers'
        request = {
            'league_name': data.league[0].name,
            'answers': {
                data.prop_bet[0].title: True,
                data.prop_bet[1].title: True,
                data.prop_bet[2].title: True
            }
        }
        username = data.user[0].name
        self.auth_test(url, request)
        self.parameter_checks(url, request, username)

        # invalid league
        request = {
            'league_name': 'invalid_league',
            'answers': {
                data.prop_bet[0].title: True,
                data.prop_bet[1].title: True,
                data.prop_bet[2].title: True
            }
        }
        response = {
            'success': False,
            'errors': ['League and user do not match (user must be admin).']
        }
        self.custom_test(url, request, response, username)
        # not in league
        request = {
            'league_name': data.league[0].name,
            'answers': {
                data.prop_bet[0].title: True,
                data.prop_bet[1].title: True,
                data.prop_bet[2].title: True
            }
        }
        username = data.user[2].name
        self.custom_test(url, request, response, username)
        # not admin
        username = data.user[1].name
        self.custom_test(url, request, response, username)
        # valid
        response = {'success': True}
        username = data.user[0].name
        self.custom_test(url, request, response, username)
        # check data is created
        for x in range(0, 3):
            db_models.PropBet.objects.get(title=data.prop_bet[x].title,
                                          league=data.league[0],
                                          answer=True)
Пример #2
0
    def test_member_admin(self):
        data = DataSetup('api_member_admin')
        data.create_users(3)
        data.create_leagues(1)
        data.create_member(data.user[0].get_object(), data.league[0], True)
        data.create_member(data.user[1].get_object(), data.league[0], False)

        url = '/api/member/admin'
        request = {'league_name': data.league[0].name}
        username = data.user[0].name
        self.auth_test(url, request)
        self.parameter_checks(url, request, username)

        # invalid league
        request = {'league_name': 'invalid_league'}
        response = {
            'success': False,
            'errors': ['League and user do not match.']
        }
        self.custom_test(url, request, response, username)
        # not in league
        request = {'league_name': data.league[0].name}
        username = data.user[2].name
        self.custom_test(url, request, response, username)
        # not admin
        response = {'success': True, 'admin': False}
        username = data.user[1].name
        self.custom_test(url, request, response, username)
        # valid, picks
        response = {'success': True, 'admin': True}
        username = data.user[0].name
        self.custom_test(url, request, response, username)
Пример #3
0
    def test_league_join(self):
        data = DataSetup('api_league_join')
        data.create_users(1)
        data.create_leagues(1)

        url = '/api/league/join'
        request = {'league_name': data.league[0].name, 'password': '******'}
        username = data.user[0].name
        self.auth_test(url, request)
        self.parameter_checks(url, request, username)

        # invalid league
        request = {'league_name': 'invalid_league', 'password': '******'}
        response = {
            'success': False,
            'errors': ['League name and password do not match.']
        }
        self.custom_test(url, request, response, username)
        # invalid password
        request = {
            'league_name': data.league[0].name,
            'password': '******'
        }
        self.custom_test(url, request, response, username)
        # valid
        request = {'league_name': data.league[0].name, 'password': '******'}
        response = {'success': True}
        self.custom_test(url, request, response, username)
        # check data is created
        member = db_models.Member.objects.get(user=data.user[0].get_object(),
                                              league=data.league[0],
                                              admin=False)
Пример #4
0
    def test_member_get_picks(self):
        data = DataSetup('api_member_get_picks')
        data.create_users(3)
        data.create_leagues(2)
        data.create_member(data.user[0].get_object(), data.league[0], False)
        data.create_member(data.user[1].get_object(), data.league[0], False)
        data.create_member(data.user[0].get_object(), data.league[1], False)
        data.create_prop_bet(data.league[0], True)
        data.create_prop_bet(data.league[0], False)
        data.create_prop_bet(data.league[0], True)
        data.create_pick(data.member[0], data.prop_bet[0], True)
        data.create_pick(data.member[0], data.prop_bet[1], False)
        data.create_pick(data.member[0], data.prop_bet[2], True)

        url = '/api/member/picks/get'
        request = {'league_name': data.league[0].name}
        username = data.user[0].name
        self.auth_test(url, request)
        self.parameter_checks(url, request, username)

        # invalid league
        request = {'league_name': 'invalid_league'}
        response = {
            'success': False,
            'errors': ['League and user do not match.']
        }
        self.custom_test(url, request, response, username)
        # not in league
        request = {'league_name': data.league[0].name}
        username = data.user[2].name
        self.custom_test(url, request, response, username)
        # valid, no picks & no prop bets
        request = {'league_name': data.league[1].name}
        response = {'success': True, 'picks': {}}
        username = data.user[0].name
        self.custom_test(url, request, response, username)
        # valid, no picks (returns default False for each prop bet)
        request = {'league_name': data.league[0].name}
        response = {
            'success': True,
            'picks': {
                data.prop_bet[0].title: False,
                data.prop_bet[1].title: False,
                data.prop_bet[2].title: False
            }
        }
        username = data.user[1].name
        self.custom_test(url, request, response, username)
        # valid, picks
        response = {
            'success': True,
            'picks': {
                data.prop_bet[0].title: True,
                data.prop_bet[1].title: False,
                data.prop_bet[2].title: True
            }
        }
        username = data.user[0].name
        self.custom_test(url, request, response, username)
Пример #5
0
    def test_member_update_picks(self):
        data = DataSetup('api_member_update_picks')
        data.create_users(2)
        data.create_leagues(1)
        data.create_member(data.user[0].get_object(), data.league[0], False)
        data.create_prop_bet(data.league[0], True)
        data.create_prop_bet(data.league[0], True)
        data.create_prop_bet(data.league[0], True)

        url = '/api/member/picks/update'
        request = {
            'league_name': data.league[0].name,
            'picks': {
                data.prop_bet[0].title: False,
                data.prop_bet[1].title: False,
                data.prop_bet[2].title: False
            }
        }
        username = data.user[0].name
        self.auth_test(url, request)
        self.parameter_checks(url, request, username)

        # invalid league
        request = {
            'league_name': 'invalid_league',
            'picks': {
                data.prop_bet[0].title: False,
                data.prop_bet[1].title: False,
                data.prop_bet[2].title: False
            }
        }
        response = {
            'success': False,
            'errors': ['League and user do not match.']
        }
        username = data.user[0].name
        self.custom_test(url, request, response, username)
        # not in league
        request = {
            'league_name': data.league[0].name,
            'picks': {
                data.prop_bet[0].title: False,
                data.prop_bet[1].title: False,
                data.prop_bet[2].title: False
            }
        }
        username = data.user[1].name
        self.custom_test(url, request, response, username)
        # valid
        response = {'success': True}
        username = data.user[0].name
        self.custom_test(url, request, response, username)
        # check data is updated
        for x in range(0, 3):
            db_models.Pick.objects.get(member=data.member[0],
                                       prop_bet=data.prop_bet[x],
                                       response=False)
Пример #6
0
    def test_league_scoreboard(self):
        data = DataSetup('api_league_scoreboard')
        data.create_users(4)
        data.create_leagues(1)
        data.create_member(data.user[0].get_object(), data.league[0], False)
        data.create_member(data.user[1].get_object(), data.league[0], False)
        data.create_member(data.user[2].get_object(), data.league[0], False)
        data.create_prop_bet(data.league[0], True)
        data.create_prop_bet(data.league[0], False)
        data.create_prop_bet(data.league[0], True)
        data.create_pick(data.member[0], data.prop_bet[0], True)
        data.create_pick(data.member[0], data.prop_bet[1], False)
        data.create_pick(data.member[0], data.prop_bet[2], True)
        data.create_pick(data.member[1], data.prop_bet[0], False)
        data.create_pick(data.member[1], data.prop_bet[1], False)
        data.create_pick(data.member[1], data.prop_bet[2], False)
        data.create_pick(data.member[2], data.prop_bet[0], False)
        data.create_pick(data.member[2], data.prop_bet[1], True)
        data.create_pick(data.member[2], data.prop_bet[2], False)

        url = '/api/league/scoreboard'
        request = {'league_name': data.league[0].name}
        username = data.user[0].name
        self.auth_test(url, request)
        self.parameter_checks(url, request, username)

        # invalid league
        request = {'league_name': 'invalid_league'}
        response = {
            'success': False,
            'errors': ['League and user do not match.']
        }
        self.custom_test(url, request, response, username)
        # not in league
        request = {'league_name': data.league[0].name}
        username = data.user[3].name
        self.custom_test(url, request, response, username)
        # valid
        response = {
            'scoreboard': [{
                'username': data.user[0].name,
                'score': 3
            }, {
                'username': data.user[1].name,
                'score': 1
            }, {
                'username': data.user[2].name,
                'score': 0
            }],
            'success':
            True
        }
        username = data.user[0].name
        self.custom_test(url, request, response, username)
Пример #7
0
  def test_league_answers_submit(self):
    data = DataSetup('ui_league_answers_submit')
    data.create_users(3)
    data.create_leagues(1)
    data.create_member(data.user[0].get_object(), data.league[0], True)
    data.create_member(data.user[1].get_object(), data.league[0], False)
    data.create_prop_bet(data.league[0], True)
    data.create_prop_bet(data.league[0], True)
    data.create_prop_bet(data.league[0], True)
    url = '/ui/league/answers/submit'

    self.auth_test(url)

    response_template = 'ui/landing.html'
    response_context = {'message': 
      'Error: League is invalid or you are not a member.'}
    payload = {'league_name': data.league[0].name, data.prop_bet[0].title: False, 
      data.prop_bet[1].title: False, data.prop_bet[2].title: False}
    # not member
    username = data.user[2].name
    self.custom_test(url, 'POST', response_template, response_context, 
      payload=payload, username=username)
    # invalid league
    payload = {'league_name': 'invalid_league', data.prop_bet[0].title: False, 
      data.prop_bet[1].title: False, data.prop_bet[2].title: False}
    username = data.user[0].name
    self.custom_test(url, 'POST', response_template, response_context, 
      payload=payload, username=username)
    response_template = 'ui/league_home.html'
    # missing answers
    response_context = {'message': 'Error: Answers block is invalid or missing.'}
    payload = {'league_name': data.league[0].name}
    username = data.user[0].name
    self.custom_test(url, 'POST', response_template, response_context, 
      payload=payload, username=username)
    # not admin
    response_context = {'message': 'Error: You must be an admin to update league answers.'}
    payload = {'league_name': data.league[0].name, data.prop_bet[0].title: False, 
      data.prop_bet[1].title: False, data.prop_bet[2].title: False}
    username = data.user[1].name
    self.custom_test(url, 'POST', response_template, response_context, 
      payload=payload, username=username)
    # valid
    response_context = {'message': 'Successfully updated league answers.'}
    username = data.user[0].name
    self.custom_test(url, 'POST', response_template, response_context, 
      payload=payload, username=username)
    # check data is updated
    for x in range(0, 3):
      db_models.PropBet.objects.get(title=data.prop_bet[x].title, 
        league=data.league[0], answer=False)
Пример #8
0
  def test_create_league_submit(self):
    data = DataSetup('ui_create_league_submit')
    data.create_users(1)
    data.create_leagues(1)  
    url = '/ui/league/create/submit'
    username = data.user[0].name

    self.auth_test(url)

    response_template = 'ui/league_create.html'
    response_context = {'message': 
      'Error: League name, password, and/or prop bet list is invalid or missing.'}
    # missing league name
    payload = {'leaguePassword': '******', 'propBetList': 
      'Test Prop Bet 1\nTest Prop Bet 2\nTest Prop Bet 3'}
    self.custom_test(url, 'POST', response_template, response_context, 
      payload=payload, username=username)
    # missing password
    payload = {'leagueName': 'unique_league_name', 'propBetList': 
      'Test Prop Bet 1\nTest Prop Bet 2\nTest Prop Bet 3'}
    self.custom_test(url, 'POST', response_template, response_context, 
      payload=payload, username=username)
    # missing prop bet list
    payload = {'leagueName': 'unique_league_name', 'leaguePassword': '******'}
    self.custom_test(url, 'POST', response_template, response_context, 
      payload=payload, username=username)
    # not unique
    response_context = {'message': 'Error: League name must be unique.'}
    payload = {'leagueName': data.league[0].name, 'leaguePassword': '******', 
      'propBetList': 'Test Prop Bet 1\nTest Prop Bet 2\nTest Prop Bet 3'}
    self.custom_test(url, 'POST', response_template, response_context, 
      payload=payload, username=username)
    # valid
    response_template = 'ui/league_home.html'
    response_context = {'message': 'Successfully created league.'}
    payload = {'leagueName': 'unique_league_name', 'leaguePassword': '******', 
      'propBetList': 'Test Prop Bet 1\nTest Prop Bet 2\nTest Prop Bet 3'}
    self.custom_test(url, 'POST', response_template, response_context, 
      payload=payload, username=username)
    # check data is created
    new_league = db_models.League.objects.get(name='unique_league_name')
    new_member = db_models.Member.objects.get(user=data.user[0].get_object(), 
      league=new_league, admin=True)
    new_prop_bets = db_models.PropBet.objects.filter(league=new_league)
    new_prop_bets = [row.title for row in new_prop_bets]
    self.assertEqual(new_prop_bets, ['Test Prop Bet 1', 'Test Prop Bet 2', 
      'Test Prop Bet 3'])
Пример #9
0
  def test_league_picks(self):
    data = DataSetup('ui_league_picks')
    data.create_users(3)
    data.create_leagues(1)
    data.create_member(data.user[0].get_object(), data.league[0], True)
    data.create_member(data.user[1].get_object(), data.league[0], True)
    data.create_prop_bet(data.league[0], True)
    data.create_prop_bet(data.league[0], True)
    data.create_prop_bet(data.league[0], True)
    data.create_pick(data.member[0], data.prop_bet[0], False)
    data.create_pick(data.member[0], data.prop_bet[1], False)
    data.create_pick(data.member[0], data.prop_bet[2], False)
    url = '/ui/league/picks/%s' % data.league[0].name

    self.auth_test(url)

    response_template = 'ui/landing.html'
    response_context = {'message': 
      'Error: League is invalid or you are not a member.'}
    # not member
    username = data.user[2].name
    self.custom_test(url, 'GET', response_template, response_context, 
      username=username)
    # invalid league
    username = data.user[0].name
    url = '/ui/league/picks/invalid_league'
    self.custom_test(url, 'GET', response_template, response_context, 
      username=username)
    url = '/ui/league/picks/%s' % data.league[0].name
    # valid without picks
    username = data.user[1].name
    response_template = 'ui/league_entry.html'
    response_context = {'user': data.user[1].get_object(), 'league_name': 
      data.league[0].name, 'answers': False, 'prop_bets': 
      {data.prop_bet[0].title: None, data.prop_bet[1].title: None, 
      data.prop_bet[2].title: None}}
    self.custom_test(url, 'GET', response_template, response_context, 
      username=username)
    # valid with picks
    username = data.user[0].name
    response_context = {'user': data.user[0].get_object(), 'league_name': 
      data.league[0].name, 'answers': False, 'prop_bets': 
      {data.prop_bet[0].title: False, data.prop_bet[1].title: False, 
      data.prop_bet[2].title: False}} 
    self.custom_test(url, 'GET', response_template, response_context, 
      username=username)
Пример #10
0
  def test_scoreboard(self):
    data = DataSetup('ui_scoreboard')
    data.create_users(4)
    data.create_leagues(1)
    data.create_member(data.user[0].get_object(), data.league[0], False)
    data.create_member(data.user[1].get_object(), data.league[0], False)
    data.create_member(data.user[2].get_object(), data.league[0], False)
    data.create_prop_bet(data.league[0], True)
    data.create_prop_bet(data.league[0], False)
    data.create_prop_bet(data.league[0], True)
    data.create_pick(data.member[0], data.prop_bet[0], True)
    data.create_pick(data.member[0], data.prop_bet[1], False)
    data.create_pick(data.member[0], data.prop_bet[2], True)
    data.create_pick(data.member[1], data.prop_bet[0], False)
    data.create_pick(data.member[1], data.prop_bet[1], False)
    data.create_pick(data.member[1], data.prop_bet[2], False)
    data.create_pick(data.member[2], data.prop_bet[0], False)
    data.create_pick(data.member[2], data.prop_bet[1], True)
    data.create_pick(data.member[2], data.prop_bet[2], False)
    url = '/ui/league/scoreboard/%s' % data.league[0].name

    self.auth_test(url)

    response_template = 'ui/landing.html'
    response_context = {'message': 
      'Error: League is invalid or you are not a member.'}
    # invalid league
    username = data.user[0].name 
    url = '/ui/league/scoreboard/invalid_league'
    self.custom_test(url, 'GET', response_template, response_context, 
      username=username)
    # not member
    username = data.user[3].name 
    url = '/ui/league/scoreboard/%s' % data.league[0].name
    self.custom_test(url, 'GET', response_template, response_context, 
      username=username)
    # valid
    response_template = 'ui/league_scoreboard.html'
    response_context = {'scores': [{'username': data.user[0].name, 'score': 3}, 
      {'username': data.user[1].name, 'score': 1}, 
      {'username': data.user[2].name, 'score': 0}]}
    username = data.user[1].name
    self.custom_test(url, 'GET', response_template, response_context, 
      username=username)     
Пример #11
0
    def test_user_leagues(self):
        data = DataSetup('api_user_leagues')
        data.create_users(2)
        data.create_leagues(1)
        data.create_member(data.user[0].db_object, data.league[0], False)

        url = '/api/user/leagues'
        request = {}
        username = data.user[0].name
        self.auth_test(url, request)
        self.parameter_checks(url, request, username)

        # no leagues
        response = {'success': True, 'leagues': []}
        username = data.user[1].name
        self.custom_test(url, request, response, username)
        # valid
        response = {'success': True, 'leagues': [data.league[0].name]}
        username = data.user[0].name
        self.custom_test(url, request, response, username)
Пример #12
0
    def test_league_create(self):
        data = DataSetup('api_league_create')
        data.create_users(1)
        data.create_leagues(1)

        url = '/api/league/create'
        request = {
            'league_name': 'api_league_create_league_2',
            'password': '******',
            'prop_bets': 'Test Prop Bet 1\nTest Prop Bet 2\nTest Prop Bet 3'
        }
        username = data.user[0].name
        self.auth_test(url, request)
        self.parameter_checks(url, request, username)

        # duplicate name
        request = {
            'league_name': data.league[0].name,
            'password': '******',
            'prop_bets': 'Test Prop Bet 1\nTest Prop Bet 2\nTest Prop Bet 3'
        }
        response = {'success': False, 'errors': ['League name is taken.']}
        self.custom_test(url, request, response, username)
        # valid
        request = {
            'league_name': 'api_league_create_league_2',
            'password': '******',
            'prop_bets': 'Test Prop Bet 1\nTest Prop Bet 2\nTest Prop Bet 3'
        }
        response = {'success': True}
        self.custom_test(url, request, response, username)
        # check data is created
        new_league = db_models.League.objects.get(
            name='api_league_create_league_2')
        new_member = db_models.Member.objects.get(
            user=data.user[0].get_object(), league=new_league, admin=True)
        new_prop_bets = db_models.PropBet.objects.filter(league=new_league)
        new_prop_bets = [row.title for row in new_prop_bets]
        self.assertEqual(
            new_prop_bets,
            ['Test Prop Bet 1', 'Test Prop Bet 2', 'Test Prop Bet 3'])
Пример #13
0
  def test_league_answers(self):
    data = DataSetup('ui_league_answers')
    data.create_users(3)
    data.create_leagues(1)
    data.create_member(data.user[0].get_object(), data.league[0], True)
    data.create_member(data.user[1].get_object(), data.league[0], False)
    data.create_prop_bet(data.league[0], True)
    data.create_prop_bet(data.league[0], True)
    data.create_prop_bet(data.league[0], True)
    url = '/ui/league/answers/%s' % data.league[0].name

    self.auth_test(url)

    response_template = 'ui/landing.html'
    response_context = {'message': 
      'Error: League is invalid or you are not a member.'}
    # not member
    username = data.user[2].name
    self.custom_test(url, 'GET', response_template, response_context, 
      username=username)
    # invalid league
    url = '/ui/league/answers/invalid_league'
    username = data.user[0].name
    self.custom_test(url, 'GET', response_template, response_context, 
      username=username)
    url = '/ui/league/answers/%s' % data.league[0].name
    # not admin
    username = data.user[1].name 
    response_template = 'ui/league_home.html'
    response_context = {'message': 
      'Error: You must be an admin to update league answers.'}
    self.custom_test(url, 'GET', response_template, response_context, 
      username=username)
    # valid
    username = data.user[0].name 
    response_template = 'ui/league_entry.html'
    response_context = {'user': data.user[0].get_object(), 'league_name': 
      data.league[0].name, 'answers': True, 'prop_bets': {data.prop_bet[0].title: 
      True, data.prop_bet[1].title: True, data.prop_bet[2].title: True}}
    self.custom_test(url, 'GET', response_template, response_context, 
      username=username)
Пример #14
0
  def test_join_league_submit(self):
    data = DataSetup('ui_join_league_submit')
    data.create_users(1)
    data.create_leagues(1)  
    url = '/ui/league/join/submit'
    username = data.user[0].name

    self.auth_test(url)

    response_context = {'message': 
      'Error: League name and/or password is invalid or missing.'}
    response_template = 'ui/landing.html'
    # invalid league
    payload = {'leagueName': 'invalid_league', 'leaguePassword': '******'}
    self.custom_test(url, 'POST', response_template, response_context, 
      payload=payload, username=username)
    # missing league
    payload = {'leaguePassword': '******'}
    self.custom_test(url, 'POST', response_template, response_context, 
      payload=payload, username=username)
    # invalid password
    payload = {'leagueName': data.league[0].name, 'leaguePassword': 
      '******'}
    self.custom_test(url, 'POST', response_template, response_context, 
      payload=payload, username=username)
    # missing password
    payload = {'leagueName': data.league[0].name}
    self.custom_test(url, 'POST', response_template, response_context, 
      payload=payload, username=username)
    # valid
    payload = {'leagueName': data.league[0].name, 'leaguePassword': '******'}
    response_context = {'message': 'Successfully joined league.'}
    response_template = 'ui/league_home.html'
    self.custom_test(url, 'POST', response_template, response_context, 
      payload=payload, username=username)
    # check data is created
    member = db_models.Member.objects.get(user=data.user[0].get_object(), 
      league=data.league[0], admin=False)
Пример #15
0
  def test_landing(self):
    data = DataSetup('ui_landing')
    data.create_users(2)
    data.create_leagues(2)
    data.create_member(data.user[0].get_object(), data.league[0], True)
    data.create_member(data.user[0].get_object(), data.league[1], False)
    url = '/ui/main'
    response_template = 'ui/landing.html'
    username = data.user[1].name

    self.auth_test(url)

    # no leagues
    response_context = {'user': data.user[1].get_object(), 'leagues': [], 
      'message': ''}
    self.custom_test(url, 'GET', response_template, response_context, 
      username=username)
    # multiple leagues
    username = data.user[0].name
    response_context = {'user': data.user[0].get_object(), 'leagues': [
      data.league[0].name, data.league[1].name], 'message': ''}
    self.custom_test(url, 'GET', response_template, response_context, 
      username=username)
Пример #16
0
    def test_league_prop_bets(self):
        data = DataSetup('api_league_prop_bets')
        data.create_users(2)
        data.create_leagues(1)
        data.create_member(data.user[0].get_object(), data.league[0], False)
        data.create_prop_bet(data.league[0], False)
        data.create_prop_bet(data.league[0], False)

        url = '/api/league/prop-bets'
        request = {'league_name': data.league[0].name}
        username = data.user[0].name
        self.auth_test(url, request)
        self.parameter_checks(url, request, username)

        # invalid league
        request = {'league_name': 'invalid_league'}
        response = {
            'success': False,
            'errors': ['League and user do not match.']
        }
        self.custom_test(url, request, response, username)
        # not in league
        request = {'league_name': data.league[0].name}
        username = data.user[1].name
        self.custom_test(url, request, response, username)
        # valid
        request = {'league_name': data.league[0].name}
        response = {
            'success': True,
            'prop_bets': {
                data.prop_bet[0].title: False,
                data.prop_bet[1].title: False
            }
        }
        username = data.user[0].name
        self.custom_test(url, request, response, username)
Пример #17
0
  def test_league(self):
    data = DataSetup('ui_league')
    data.create_users(3)
    data.create_leagues(1)
    data.create_member(data.user[0].get_object(), data.league[0], True)
    data.create_member(data.user[1].get_object(), data.league[0], False)
    url = '/ui/league/home/%s' % data.league[0].name

    self.auth_test(url)

    response_template = 'ui/landing.html'
    response_context = {'message': 'Error: League is invalid or you are not a member.'}
    # invalid league
    url = '/ui/league/home/invalid_league'
    username = data.user[0].name
    self.custom_test(url, 'GET', response_template, response_context, 
      username=username)
    # not member
    url = '/ui/league/home/%s' % data.league[0].name
    username = data.user[2].name
    self.custom_test(url, 'GET', response_template, response_context, 
      username=username)
    # member, admin
    response_template = 'ui/league_home.html'
    response_context = {'message': '', 'admin': True, 'user': 
      data.user[0].get_object(), 'league': data.league[0]}
    username = data.user[0].name
    self.custom_test(url, 'GET', response_template, response_context, 
      username=username)
    # member, not admin
    response_template = 'ui/league_home.html'
    response_context = {'message': '', 'admin': False, 'user': 
      data.user[1].get_object(), 'league': data.league[0]}
    username = data.user[1].name
    self.custom_test(url, 'GET', response_template, response_context, 
      username=username)