Fix tests

remotes/origin/issue/4795/notification_even_they_are_disabled
David Barragán Merino 2016-08-02 19:05:15 +02:00
parent 2f7384a76b
commit 9bba8efde9
2 changed files with 9 additions and 2 deletions

View File

@ -36,6 +36,15 @@ from . import models
import json import json
class UserStoryExistsValidator:
def validate_us_id(self, attrs, source):
value = attrs[source]
if not models.UserStory.objects.filter(pk=value).exists():
msg = _("There's no user story with that id")
raise ValidationError(msg)
return attrs
class RolePointsField(serializers.WritableField): class RolePointsField(serializers.WritableField):
def to_native(self, obj): def to_native(self, obj):
return {str(o.role.id): o.points.id for o in obj.all()} return {str(o.role.id): o.points.id for o in obj.all()}

View File

@ -123,7 +123,6 @@ def test_set_related_userstory(client):
} }
client.login(user) client.login(user)
response = client.json.post(url, json.dumps(data)) response = client.json.post(url, json.dumps(data))
print(response.data)
assert response.status_code == 200 assert response.status_code == 200
assert response.data['user_stories_counts'] == {'opened': 1, 'closed': 0} assert response.data['user_stories_counts'] == {'opened': 1, 'closed': 0}
@ -144,7 +143,6 @@ def test_set_related_userstory_existing(client):
} }
client.login(user) client.login(user)
response = client.json.post(url, json.dumps(data)) response = client.json.post(url, json.dumps(data))
print(response.data)
assert response.status_code == 200 assert response.status_code == 200
assert response.data['user_stories_counts'] == {'opened': 1, 'closed': 0} assert response.data['user_stories_counts'] == {'opened': 1, 'closed': 0}