-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update testing code to be compatible with PyCharm Django test runner …
…+ coverage
- Loading branch information
Showing
5 changed files
with
26 additions
and
24 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 |
---|---|---|
|
@@ -58,7 +58,7 @@ def setUp(self): | |
post_1 = Post.objects.all().first() | ||
post_1.status = Post.STATUS_APPROVED | ||
post_1.save() | ||
self.id = post_1.id | ||
self.post_id = post_1.id | ||
|
||
@mock.patch("portal.serializers.get_user_clubs", mock_get_user_clubs) | ||
def test_create_post(self): | ||
|
@@ -100,10 +100,10 @@ def test_fail_post(self): | |
@mock.patch("portal.permissions.get_user_clubs", mock_get_user_clubs) | ||
def test_update_post(self): | ||
payload = {"title": "New Test Title 3"} | ||
response = self.client.patch(f"/portal/posts/{self.id}/", payload) | ||
response = self.client.patch(f"/portal/posts/{self.post_id}/", payload) | ||
res_json = json.loads(response.content) | ||
self.assertEqual(self.id, res_json["id"]) | ||
self.assertEqual("New Test Title 3", Post.objects.get(id=self.id).title) | ||
self.assertEqual(self.post_id, res_json["id"]) | ||
self.assertEqual("New Test Title 3", Post.objects.get(id=self.post_id).title) | ||
# since the user is not an admin, approved should be set to false after update | ||
self.assertEqual(Post.STATUS_DRAFT, res_json["status"]) | ||
|
||
|
@@ -113,9 +113,9 @@ def test_update_post_admin(self): | |
admin = User.objects.create_superuser("[email protected]", "admin", "admin") | ||
self.client.force_authenticate(user=admin) | ||
payload = {"title": "New Test Title 3"} | ||
response = self.client.patch(f"/portal/posts/{self.id}/", payload) | ||
response = self.client.patch(f"/portal/posts/{self.post_id}/", payload) | ||
res_json = json.loads(response.content) | ||
self.assertEqual(self.id, res_json["id"]) | ||
self.assertEqual(self.post_id, res_json["id"]) | ||
self.assertEqual(Post.STATUS_APPROVED, res_json["status"]) | ||
|
||
@mock.patch("portal.serializers.get_user_clubs", mock_get_user_clubs) | ||
|
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
Empty file.