Skip to content
This repository has been archived by the owner on Apr 8, 2023. It is now read-only.

Commit

Permalink
Fix failing test for new autosave deletion behavior
Browse files Browse the repository at this point in the history
Co-authored-by: Felix Auringer <[email protected]>
  • Loading branch information
frcroth and felixauringer committed Mar 13, 2021
1 parent 832bb25 commit 8c8b18c
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions _1327/documents/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,14 +640,28 @@ def test_autosave_delete_user_different_user(self):
def test_autosave_delete_user_insufficient_permissions(self):
user = baker.make(UserProfile)
autosave = baker.make(TemporaryDocumentText, document=self.document, author=user)

user2 = baker.make(UserProfile)
response = self.app.post(
reverse("documents:delete_autosave", args=[self.document.url_title]),
user=user,
user=user2,
expect_errors=True,
params={"autosave_id": autosave.id}
)
self.assertEqual(response.status_code, 403)

def test_autosave_can_be_deleted(self):
user = baker.make(UserProfile)
autosave = baker.make(TemporaryDocumentText, document=self.document, author=user)
response = self.app.post(
reverse("documents:delete_autosave", args=[self.document.url_title]),
user=user,
expect_errors=True,
params={"autosave_id": autosave.id}
)
self.assertEqual(response.status_code, 302)
self.assertEqual(TemporaryDocumentText.objects.count(), 0)

def test_autosave_delete_not_existing_autosave_id(self):
baker.make(TemporaryDocumentText, document=self.document, author=self.user)
response = self.app.post(
Expand Down Expand Up @@ -1449,8 +1463,7 @@ def test_delete_document_in_creation_fails_without_autosave(self):
user = baker.make(UserProfile)
document = baker.make(InformationDocument)
self.assertEqual(Document.objects.count(), 2)
response = self.app.post(reverse("documents:delete_document", args=[document.url_title]), user=user,
expect_errors=True)
response = self.app.post(reverse("documents:delete_document", args=[document.url_title]), user=user, expect_errors=True)
self.assertEqual(response.status_code, 403)

def test_delete_document_in_creation_with_autosave(self):
Expand All @@ -1464,6 +1477,7 @@ def test_delete_document_in_creation_with_autosave(self):
self.assertEqual(Document.objects.count(), 1)
self.assertEqual(TemporaryDocumentText.objects.count(), 0)


class TestPreview(WebTest):
csrf_checks = False

Expand Down

0 comments on commit 8c8b18c

Please sign in to comment.