Skip to content

Commit 8d0568c

Browse files
committed
added tests for async create, update and delete CBVs.
1 parent 6b6cb53 commit 8d0568c

File tree

9 files changed

+584
-6
lines changed

9 files changed

+584
-6
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
An empty login template.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
A form: {{ form }}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Are you sure?
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
A form: {{ form }}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Generic: Are you sure?

tests/test_generic_views/forms.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
11
from asgiref.sync import sync_to_async
22
from django import forms
33

4-
from .models import Author
4+
from .models import Author, Artist
5+
6+
7+
class ArtistModelForm(forms.ModelForm):
8+
class Meta:
9+
model = Artist
10+
fields = "__all__" # noqa: DJ007
11+
12+
async def asave(self, commit=True):
13+
# temp, until async model form is added
14+
return await sync_to_async(self.save)(commit=commit)
15+
16+
17+
class AuthorModelForm(forms.ModelForm):
18+
class Meta:
19+
model = Author
20+
fields = "__all__" # noqa: DJ007
21+
22+
async def asave(self, commit=True):
23+
# temp, until async model form is added
24+
return await sync_to_async(self.save)(commit=commit)
525

626

727
class AuthorForm(forms.ModelForm):

0 commit comments

Comments
 (0)