-
Notifications
You must be signed in to change notification settings - Fork 0
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
adds in sample pytest #30
base: main
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,2 @@ | ||
[pytest] | ||
DJANGO_SETTINGS_MODULE = config.settings |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import pytest | ||
from django.urls import reverse, resolve | ||
|
||
from common import views | ||
|
||
|
||
class TestClass: | ||
|
||
@pytest.mark.parametrize( | ||
"url_name, url, view_class", | ||
[ | ||
("index", "/", views.IndexView), | ||
], | ||
) | ||
def test_urls(self, url_name, url, view_class): | ||
resolver = resolve(url) | ||
assert resolver.view_name == url_name | ||
assert resolver.func.view_class == view_class | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from django.conf import settings | ||
from django.conf.urls import url | ||
from django.urls import re_path | ||
from django.urls import include, path | ||
|
||
from common import views | ||
|
@@ -30,7 +30,7 @@ | |
import debug_toolbar | ||
|
||
urlpatterns += [ | ||
url(r'^__debug__/', include(debug_toolbar.urls)), | ||
re_path(r'^__debug__/', include(debug_toolbar.urls)), | ||
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 think |
||
] | ||
{%- if cookiecutter.feature_annotations == "on" %} | ||
# END_FEATURE debug_toolbar | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ django-environ | |
django-extensions | ||
requests | ||
psycopg2 | ||
pytest | ||
{%- if cookiecutter.feature_annotations == "on" %} | ||
Comment on lines
+6
to
7
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 think we also need |
||
|
||
####### OPTIONAL FEATURES ####### | ||
|
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.
This definitely handles the use case of giving people a sample to follow, but it would be more ideal to have a sample that 1. uses the database, and 2. tests something that is code we've written and not django code
Maybe we can create a new view that uses
LoginRequiredMixin
and test access that requires the use of factories and making database calls?