Skip to content

Commit

Permalink
Add tests for publishing draft reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
anshg1214 committed Aug 30, 2022
1 parent 4f69a51 commit b399f16
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions critiquebrainz/frontend/views/test/test_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import critiquebrainz.db.license as db_license
import critiquebrainz.db.review as db_review
import critiquebrainz.db.revision as db_revision
import critiquebrainz.db.users as db_users
from critiquebrainz.db.user import User
from critiquebrainz.frontend.testing import FrontendTestCase
Expand Down Expand Up @@ -374,3 +375,32 @@ def test_hide_redirect(self):
review["entity_type"], review["entity_id"]))
redirect_url = urlparse(response.location)
self.assertEqual(redirect_url.path, url_for('review.entity', id=review['id']))


def test_publish_draft_review(self):
updated_text = 'This is the published review.'
review = self.create_dummy_review(is_draft=True)
self.temporary_login(self.user)

data = {
review["entity_type"]: review["entity_id"],
"state": "publish",
"license_choice": self.license["id"],
"language": 'en',
"agreement": 'True',
"text": updated_text,
"rating": review["rating"]
}

response = self.client.post(
"/review/%s/edit" % review["id"],
data=data,
query_string=data,
follow_redirects=True
)
self.assert200(response)
self.assertIn(updated_text, str(response.data))

# test draft revisions are deleted after review is published
revisions = db_revision.get_count(review["id"])
self.assertEqual(revisions, 1)

0 comments on commit b399f16

Please sign in to comment.