-
Notifications
You must be signed in to change notification settings - Fork 1
adding prelim tests #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import pytest | ||
|
|
||
|
|
||
| @pytest.fixture(scope='function') | ||
| def get_client(client): | ||
| return client | ||
|
|
||
|
|
||
| @pytest.fixture(scope='function') | ||
| def create_user(django_user_model): | ||
| username = "testuser" | ||
| password = "testpassword" | ||
| django_user_model.objects.create_user(username=username, password=password) | ||
|
|
||
| return username, password | ||
|
|
||
|
|
||
| @pytest.fixture(scope='function') | ||
| def load_game_data(db): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 compile_configs | ||
|
|
||
| return True | ||
|
|
||
|
|
||
| @pytest.fixture(scope='function') | ||
| def logged_in_client(create_user, client): | ||
| username, password = create_user | ||
| client.login(username=username, password=password) | ||
|
|
||
| return client | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| from django.urls import reverse | ||
| import pytest | ||
| from .fixtures import logged_in_client, load_game_data, create_user, get_client | ||
|
|
||
| class TestGameView: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. subclass |
||
|
|
||
| def test_list_game_without_login_fails(self, client): | ||
| response = client.get(reverse('game', args=(1,))) | ||
| assert response.status_code == 302 | ||
|
|
||
| def test_list_game_succeeds(self, load_game_data, logged_in_client): | ||
| response = logged_in_client.get(reverse('game', args=(1,))) | ||
|
|
||
| assert response.status_code == 200 | ||
| assert response.template_name[0] == 'front/game.html' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
|
||
|
|
||
|
|
||
| # class TestModuleView: | ||
| # | ||
| # def test_list_game_succeeds(self, load_game_data, logged_in_client): | ||
| # response = logged_in_client.get(reverse('module', args=(1,))) | ||
| # | ||
| # assert response.status_code == 200 | ||
| # assert response.template_name[0] == 'front/game.html' | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
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