Skip to content

adding prelim tests#25

Open
nrahmani110 wants to merge 1 commit intomasterfrom
begin-pytests
Open

adding prelim tests#25
nrahmani110 wants to merge 1 commit intomasterfrom
begin-pytests

Conversation

@nrahmani110
Copy link
Copy Markdown
Collaborator

No description provided.

@nrahmani110 nrahmani110 requested review from a user, alfwong8 and psean21c November 5, 2019 05:14
Copy link
Copy Markdown
Collaborator

@psean21c psean21c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but I am wondering if it's about unit test for Python coding.

import pytest


@pytest.fixture(scope='function')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

django gives you a client object if you subclass django.test.TestCase



@pytest.fixture(scope='function')
def load_game_data(db):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be better to just use pure fixturized data instead of trying to use our "production data".

import pytest
from .fixtures import logged_in_client, load_game_data, create_user, get_client

class TestGameView:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subclass django.test.TestCase

response = logged_in_client.get(reverse('game', args=(1,)))

assert response.status_code == 200
assert response.template_name[0] == 'front/game.html'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also check to make sure the expected values render in the template.

assert f'{game.title}' in response.content

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants