forked from model-bakers/model_bakery
-
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.
[model-bakers#329] (WIP) Initial issue example model and test setup
- Loading branch information
1 parent
370406f
commit c79b7a6
Showing
5 changed files
with
56 additions
and
0 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
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.urls import include, path | ||
|
||
from tests.generic.views import issue329_view | ||
|
||
urlpatterns = [ | ||
path('issue-329/', issue329_view, name='issue-329'), | ||
] |
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,6 @@ | ||
from django.views import View | ||
from django.http import HttpResponse | ||
|
||
|
||
def issue329_view(_request): | ||
return HttpResponse(content='Issue 329', status=200) |
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,31 @@ | ||
import pytest | ||
|
||
from django.urls import reverse | ||
from django.test import Client | ||
|
||
from model_bakery import baker | ||
from tests.generic.models import Issue329ModelA, Issue329ModelB | ||
|
||
|
||
@pytest.fixture() | ||
def site_b(): | ||
return baker.make(Issue329ModelB) | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_issue_329(site_b): | ||
instances = ( | ||
record for record, _created in ( | ||
Issue329ModelA.objects.get_or_create(id=1), | ||
Issue329ModelA.objects.get_or_create(id=2) | ||
) | ||
) | ||
|
||
site_b.types.add(*instances) | ||
client = Client() | ||
url = reverse('issue-329') | ||
|
||
resp = client.get(url) | ||
|
||
assert resp.status_code == 200 | ||
assert resp.content == b'Issue 329' |