-
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.
Merge pull request #165 from willemarcel/develop
add view to list comments of a changeset
- Loading branch information
Showing
12 changed files
with
176 additions
and
30 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 |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
from social_django.models import UserSocialAuth | ||
from rest_framework.test import APITestCase | ||
from requests_oauthlib import OAuth1Session | ||
import mock | ||
from unittest import mock | ||
|
||
from ...users.models import User | ||
from ..models import Changeset | ||
|
@@ -160,3 +160,53 @@ def test_comment_changeset_doesnt_exist(self): | |
) | ||
|
||
self.assertEqual(response.status_code, 404) | ||
|
||
|
||
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', 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.assertEqual(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
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
24 changes: 24 additions & 0 deletions
24
osmchadjango/supervise/migrations/0015_auto_20181129_1135.py
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Generated by Django 2.0.9 on 2018-11-29 11:35 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('supervise', '0014_auto_20180307_1417'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='blacklisteduser', | ||
name='uid', | ||
field=models.CharField(max_length=255), | ||
), | ||
migrations.AlterUniqueTogether( | ||
name='blacklisteduser', | ||
unique_together={('uid', 'added_by')}, | ||
), | ||
] |
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
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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# Test dependencies go here. | ||
-r base.txt | ||
flake8==3.5.0 | ||
django-test-plus==1.0.22 | ||
factory-boy==2.9.2 | ||
mock==2.0.0 | ||
flake8==3.6.0 | ||
django-test-plus==1.1.1 | ||
factory-boy==2.11.1 |