# Path: foosball/games/tests/factories.py
# class GameFactory(factory.django.DjangoModelFactory):
#     played_at = factory.fuzzy.FuzzyDateTime(
#         datetime.datetime.utcnow().replace(tzinfo=pytz.utc) - datetime.timedelta(weeks=8))
# 
#     membership1 = factory.RelatedFactory(TeamFactory, 'game')
#     membership2 = factory.RelatedFactory(TeamFactory, 'game')
# 
#     class Meta:
#         model = 'games.Game'
# 
# Path: foosball/games/tests/utils.py
# def handle_login(client):
#     """
#     Create user and log the user in.
#     """
#     user = UserFactory(username="foobar")
#     client.force_login(user)


import pytest
from django.core.urlresolvers import reverse
from foosball.games.tests.factories import GameFactory
from foosball.games.tests.utils import handle_login



@pytest.mark.django_db
@pytest.mark.client
def test_game_list_view_renders(client):
    handle_login(client)
    response = client.get(reverse("games:index"))
    assert response.status_code == 200


@pytest.mark.django_db
@pytest.mark.client
def test_game_detail_view_renders(client):
    handle_login(client)
    game = GameFactory()
    response = client.get(reverse("games:detail", kwargs={"pk": game.id}))
    assert response.status_code == 200


@pytest.mark.django_db
@pytest.mark.client
def test_game_create_view_renders(client):

# Path: foosball/games/tests/factories.py
# class GameFactory(factory.django.DjangoModelFactory):
#     played_at = factory.fuzzy.FuzzyDateTime(
#         datetime.datetime.utcnow().replace(tzinfo=pytz.utc) - datetime.timedelta(weeks=8))
# 
#     membership1 = factory.RelatedFactory(TeamFactory, 'game')
#     membership2 = factory.RelatedFactory(TeamFactory, 'game')
# 
#     class Meta:
#         model = 'games.Game'
# 
# Path: foosball/games/tests/utils.py
# def handle_login(client):
#     """
#     Create user and log the user in.
#     """
#     user = UserFactory(username="foobar")
#     client.force_login(user)


# Path: foosball/games/tests/test_views.py
import pytest
from django.core.urlresolvers import reverse
from foosball.games.tests.factories import GameFactory
from foosball.games.tests.utils import handle_login




@pytest.mark.django_db
@pytest.mark.client
def test_game_list_view_renders(client):
    handle_login(client)
    response = client.get(reverse("games:index"))
    assert response.status_code == 200


@pytest.mark.django_db
@pytest.mark.client
def test_game_detail_view_renders(client):
    handle_login(client)
    game = GameFactory()
    response = client.get(reverse("games:detail", kwargs={"pk": game.id}))
    assert response.status_code == 200


@pytest.mark.django_db
@pytest.mark.client
def test_game_create_view_renders(client):

    handle_login(client)