-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add view to list comments of a changeset
- Loading branch information
1 parent
6032358
commit ee9cb1a
Showing
5 changed files
with
70 additions
and
2 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 |
---|---|---|
|
@@ -1263,3 +1263,52 @@ def test_set_harmful_by_staff_user(self): | |
) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertEqual(Changeset.objects.filter(checked=True).count(), 5) | ||
|
||
class TestChangesetCommentsView(APITestCase): | ||
def setUp(self): | ||
self.changeset = HarmfulChangesetFactory( | ||
id=55736682, | ||
) | ||
HarmfulChangesetFactory(id=1343) | ||
self.user = User.objects.create_user( | ||
username='test', | ||
password='password', | ||
email='[email protected]', | ||
) | ||
UserSocialAuth.objects.create( | ||
user=self.user, | ||
provider='openstreetmap', | ||
uid='123123', | ||
) | ||
|
||
def test_unauthenticated_changeset_detail_response(self): | ||
response = self.client.get( | ||
reverse('changeset:comment-list', args=[self.changeset.id]) | ||
) | ||
self.assertEqual(response.status_code, 401) | ||
|
||
def test_authenticated_changeset_detail_response(self): | ||
self.client.login(username=self.user.username, password='password') | ||
response = self.client.get( | ||
reverse('changeset:comment', args=[self.changeset.id]) | ||
) | ||
|
||
self.assertEqual(response.status_code, 200) | ||
self.assertTrue(len(response.data) > 0) | ||
|
||
def test_changeset_does_not_exist(self): | ||
self.client.login(username=self.user.username, password='password') | ||
response = self.client.get( | ||
reverse('changeset:comment', args=[1234]) | ||
) | ||
|
||
self.assertEqual(response.status_code, 404) | ||
|
||
def test_changeset_without_comments(self): | ||
self.client.login(username=self.user.username, password='password') | ||
response = self.client.get( | ||
reverse('changeset:comment', args=[1343]) | ||
) | ||
|
||
self.assertEqual(response.status_code, 200) | ||
self.assertTrue(response.data, []) |
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