Skip to content

Commit

Permalink
Test collecting of departments.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahaith committed May 6, 2016
1 parent a2db1b1 commit 9ec0063
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
13 changes: 13 additions & 0 deletions talks/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ def setUp(self):
)
ti.save()
future_event.save()

collectedItemCt = ContentType.objects.get_for_model(models.CollectedDepartment)
collectedDep = factories.CollectedDepartmentFactory.create(
department=self.department1
)
collectionItem = factories.CollectionItemFactory.create(
collection=collection1,
content_type=collectedItemCt,
object_id=collectedDep.id
)
self.req_factory = APIRequestFactory()
self.client = APIClient()

Expand Down Expand Up @@ -183,6 +193,9 @@ def test_retrieve_collection_happy(self, requests_get):
self.assertContains(response, "IT talks collection")
self.assertContains(response, "_links")
self.assertContains(response, "_embedded")
# should return a talk organised by department 1
self.assertContains(response, "A future event")
self.assertNotContains(response, "A past event")

def test_retrieve_collection_invalid(self):
response = self.client.get('/api/collections/id/foo')
Expand Down
10 changes: 9 additions & 1 deletion talks/events/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import factory

from . import models
from talks.users.models import Collection
from talks.users.models import Collection, CollectionItem, CollectedDepartment


class EventGroupFactory(factory.django.DjangoModelFactory):
Expand Down Expand Up @@ -47,3 +47,11 @@ class Meta:
class TopicItemFactory_noSubFactory(factory.django.DjangoModelFactory):
class Meta:
model = models.TopicItem

class CollectedDepartmentFactory(factory.django.DjangoModelFactory):
class Meta:
model = CollectedDepartment

class CollectionItemFactory(factory.django.DjangoModelFactory):
class Meta:
model = CollectionItem

0 comments on commit 9ec0063

Please sign in to comment.