Commit bb148de0 authored by okhin's avatar okhin

Organization models and view covered at 100%

parent c1cb576f
Pipeline #715 passed with stage
in 1 minute and 1 second
......@@ -13,10 +13,6 @@ class FeedbackViewSet(viewsets.ViewSet):
def create(self, request, campaign_pk=None):
serializer = FeedbackSerializer(data=request.data)
try:
serializer.is_valid()
except Exception as e:
print("Bloup")
raise e
serializer.is_valid()
feedback = Feedback.objects.create(**serializer.validated_data)
return Response(feedback.id)
from django.test import TestCase
from rest_framework.test import APIClient
from picampaign.organization.models import Organization, GroupType, Group, FeedbackCategory
from picampaign.campaign.models import Campaign
# Create your tests here.
class OrganizationTest(TestCase):
def test_str(self):
organization = Organization.objects.create(
name='Majestic 12',
sip_key='majestic-12'
)
self.assertEqual(str(organization), organization.name)
class GroupTypeTest(TestCase):
def test_str(self):
organization = Organization.objects.create(
name='Majestic 12',
sip_key='majestic-12'
)
grouptype = GroupType.objects.create(
name='comittee',
organization=organization
)
self.assertEqual(str(grouptype), grouptype.name)
class GroupTest(TestCase):
def test_str(self):
organization = Organization.objects.create(
name='Majestic 12',
sip_key='majestic-12'
)
grouptype = GroupType.objects.create(
name='comittee',
organization=organization
)
group = Group.objects.create(
name='group',
type=grouptype
)
self.assertEqual(str(group), group.name)
class FeedbackCategoryTest(TestCase):
def test_str(self):
organization = Organization.objects.create(
name='Majestic 12',
sip_key='majestic-12'
)
feedbackcategory =FeedbackCategory.objects.create(
name='Feedback',
organization=organization
)
self.assertEqual(str(feedbackcategory), feedbackcategory.name)
class CategoryViewSet(TestCase):
def setUp(self):
self.organization = Organization.objects.create(
name='Majestic 12',
sip_key='majestic-12'
)
self.campaign = Campaign.objects.create(
title='Test Campaign',
start_date='2000-01-01',
end_date='2100-12-31',
organization=self.organization
)
self.feedbackcategory = FeedbackCategory.objects.create(
name='Feedback',
organization=self.organization
)
def test_feedbackcategory_viewset(self):
client = APIClient()
response = client.get('/campaigns/%(cid)s/categories/' % {'cid': self.campaign.id}, format='json')
self.assertEqual(response.status_code, 200)
self.assertEqual(response.content, b'[{"id":1,"name":"Feedback"}]')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment