Tag test fixture

This commit is contained in:
Aarni Halinen
2019-11-09 22:35:47 +02:00
parent ff98f700f9
commit b2e2ff6699
4 changed files with 56 additions and 43 deletions
+5 -10
View File
@@ -4,22 +4,17 @@ from django.utils import timezone
from rest_framework import status
from rest_framework.test import APITestCase, APIRequestFactory, force_authenticate
from webapp.models import Tag, Event
from webapp.models import Event
from webapp.serializers import EventSerializer
import tempfile
from webapp.tests.tag_fixture import tagBuilder, createTagIcon
class EventTestCase(APITestCase):
def setUp(self):
self.icon = tempfile.NamedTemporaryFile(suffix=".jpg").name
Tag.objects.create(slug='testtag1', name='test1', icon=self.icon)
tag1 = Tag.objects.get(slug="testtag1")
Tag.objects.create(slug="testtag2", name='test2', icon=self.icon)
tag2 = Tag.objects.get(slug="testtag2")
self.assertEqual(Tag.objects.count(), 2)
self.testTagId = Tag.objects.get(slug="testtag1").id
tag1 = tagBuilder()
tag2 = tagBuilder("testtag2")
self.testTagId = tag1.id
# Visible and relevant
Event.objects.create(