Skip to content

Commit

Permalink
separate django from drf tests
Browse files Browse the repository at this point in the history
  • Loading branch information
justquick committed Oct 15, 2022
1 parent 4fa7754 commit 93940ba
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 25 deletions.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,14 @@
from unittest import skipUnless

from django.core.exceptions import ImproperlyConfigured
from django.contrib.auth.models import Group
from django.contrib.sites.models import Site
from django.urls import reverse

from actstream.signals import action
from actstream.registry import register, unregister
from actstream.models import Action, actor_stream, model_stream
from actstream.tests.base import render, ActivityBaseTestCase
from actstream.tests.test_drf import BaseDRFTestCase
from actstream.settings import USE_JSONFIELD
from actstream.drf.urls import router
from actstream.drf.serializers import registered_serializers as serializers

from testapp.models import MyUser, Player, Abstract, Unregistered
from testapp_nested.models.my_model import NestedModel
from testapp.drf import GroupSerializer
from testapp.models import MyUser, Abstract, Unregistered


class TestAppTests(ActivityBaseTestCase):
Expand Down Expand Up @@ -84,19 +76,3 @@ def test_jsonfield(self):
self.assertEqual(newaction.data['text'], 'foobar')
self.assertEqual(newaction.data['tags'], ['sayings'])
self.assertEqual(newaction.data['more_data'], {'pk': self.user.pk})


class DRFTestAppTests(BaseDRFTestCase):

def test_urls(self):
self._check_urls('actions', 'follows', 'groups', 'sites',
'players', 'nested-models', 'my-users')

def test_serializers(self):

models = (Group, MyUser, Player, Site, NestedModel)
self.assertSetEqual(serializers.keys(), models, domap=False)

groups = self.get(reverse('group-list'))
assert len(groups) == 2
self.assertSetEqual(GroupSerializer.Meta.fields, groups[0].keys())
25 changes: 25 additions & 0 deletions runtests/testapp/tests/test_drf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from django.contrib.auth.models import Group
from django.contrib.sites.models import Site
from django.urls import reverse

from actstream.tests.test_drf import BaseDRFTestCase
from actstream.drf.serializers import registered_serializers as serializers
from testapp.models import MyUser, Player
from testapp_nested.models.my_model import NestedModel
from testapp.drf import GroupSerializer


class DRFTestAppTests(BaseDRFTestCase):

def test_urls(self):
self._check_urls('actions', 'follows', 'groups', 'sites',
'players', 'nested-models', 'my-users')

def test_serializers(self):

models = (Group, MyUser, Player, Site, NestedModel)
self.assertSetEqual(serializers.keys(), models, domap=False)

groups = self.get(reverse('group-list'))
assert len(groups) == 2
self.assertSetEqual(GroupSerializer.Meta.fields, groups[0].keys())

0 comments on commit 93940ba

Please sign in to comment.