This repository has been archived by the owner on Oct 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a work-in-progress attempt at switching over to mypy as part of #85. There's still some work to be done (e.g. mypy ignore comments need to be added where appropriate) and I'm currently working with some local changes pyre's stubs, but I wanted to track the work being done.
- Loading branch information
Showing
55 changed files
with
43 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ omit = | |
|
||
[run] | ||
branch = true | ||
data_file = ../.coverage | ||
data_file = .coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,15 +3,14 @@ | |
from django.contrib.auth import get_user_model | ||
from django.http import Http404, HttpRequest | ||
from django.test import Client | ||
from factory.django import DjangoModelFactory | ||
from factory.django import DjangoModelFactory # type: ignore[import] | ||
import pytest | ||
from sesame.utils import get_query_string | ||
from sesame.utils import get_query_string # type: ignore[import] | ||
|
||
from applications.models import Application | ||
from applications.views import apply | ||
|
||
|
||
# pyre-ignore[13]: Investigate type stubs for factory-boy. | ||
class ApplicationFactory(DjangoModelFactory): | ||
class Meta: | ||
model = Application | ||
|
@@ -24,29 +23,25 @@ class Meta: | |
|
||
class UserFactory(DjangoModelFactory): | ||
class Meta: | ||
# pyre-ignore[16]: This is fixed by https://github.com/facebook/pyre-check/pull/256. | ||
model = get_user_model() | ||
django_get_or_create = ("email",) | ||
|
||
email = "[email protected]" | ||
|
||
|
||
@pytest.mark.django_db | ||
# pyre-ignore[11]: This is fixed by https://github.com/facebook/pyre-check/pull/256. | ||
def test_that_one_of_form_type_and_pk_is_required_by_apply(client: Client) -> None: | ||
user = UserFactory() | ||
qs = get_query_string(user) | ||
client.get(f"/login/magic{qs}") | ||
|
||
request = HttpRequest() | ||
request.user = user | ||
# pyre-ignore[16]: pyre doesn't think ExceptionInfo as an __enter__. | ||
with pytest.raises(Http404): | ||
apply(request, form_type=None, pk=None) | ||
|
||
|
||
@pytest.mark.django_db | ||
# pyre-ignore[11]: This is fixed by https://github.com/facebook/pyre-check/pull/256. | ||
def test_user_can_edit_their_application(client: Client) -> None: | ||
user = UserFactory() | ||
qs = get_query_string(user) | ||
|
@@ -67,7 +62,6 @@ def test_user_can_edit_their_application(client: Client) -> None: | |
|
||
|
||
@pytest.mark.django_db | ||
# pyre-ignore[11]: This is fixed by https://github.com/facebook/pyre-check/pull/256. | ||
def test_user_can_view_their_application(client: Client) -> None: | ||
user = UserFactory() | ||
qs = get_query_string(user) | ||
|
@@ -80,7 +74,6 @@ def test_user_can_view_their_application(client: Client) -> None: | |
|
||
|
||
@pytest.mark.django_db | ||
# pyre-ignore[11]: This is fixed by https://github.com/facebook/pyre-check/pull/256. | ||
def test_user_cant_view_someone_elses_application(client: Client) -> None: | ||
user = UserFactory() | ||
other = UserFactory(email=f"other+{user.email}") | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.test import Client | ||
|
||
|
||
def client() -> Client: | ||
return Client() |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,22 +2,20 @@ | |
|
||
from django.contrib.auth import get_user_model | ||
from django.test import Client | ||
from factory.django import DjangoModelFactory | ||
from factory.django import DjangoModelFactory # type: ignore[import] | ||
import pytest | ||
from sesame.utils import get_query_string | ||
from sesame.utils import get_query_string # type: ignore[import] | ||
|
||
|
||
class UserFactory(DjangoModelFactory): | ||
class Meta: | ||
# pyre-ignore[16]: This is fixed by https://github.com/facebook/pyre-check/pull/256. | ||
model = get_user_model() | ||
django_get_or_create = ("email",) | ||
|
||
email = "[email protected]" | ||
|
||
|
||
@pytest.mark.django_db | ||
# pyre-ignore[11]: This is fixed by https://github.com/facebook/pyre-check/pull/256. | ||
def test_login_link_is_not_shown_to_logged_in_users(client: Client) -> None: | ||
user = UserFactory() | ||
qs = get_query_string(user) | ||
|
@@ -27,7 +25,6 @@ def test_login_link_is_not_shown_to_logged_in_users(client: Client) -> None: | |
assert b"log in" not in response.content.lower() | ||
|
||
|
||
# pyre-ignore[11]: This is fixed by https://github.com/facebook/pyre-check/pull/256. | ||
def test_login_link_is_shown_to_guests(client: Client) -> None: | ||
response = client.get("/") | ||
assert b"log in" in response.content.lower() |
File renamed without changes.
Oops, something went wrong.