From 74dfa54d512dbbe6be6a188cec4b42efa6b2685c Mon Sep 17 00:00:00 2001 From: Rizwan Mansuri Date: Sat, 13 Apr 2019 16:05:50 +0100 Subject: [PATCH] Removed repeated models in tests --- .../test_generic_relations.py | 40 +------------------ tests/test_permissions.py | 3 +- tests/test_utils.py | 3 +- 3 files changed, 3 insertions(+), 43 deletions(-) diff --git a/tests/generic_relations/test_generic_relations.py b/tests/generic_relations/test_generic_relations.py index c6f2b0de4..33f8ea1d0 100644 --- a/tests/generic_relations/test_generic_relations.py +++ b/tests/generic_relations/test_generic_relations.py @@ -1,46 +1,8 @@ -from django.contrib.contenttypes.fields import ( - GenericForeignKey, GenericRelation -) -from django.contrib.contenttypes.models import ContentType -from django.db import models from django.test import TestCase from rest_framework import serializers - -class Tag(models.Model): - """ - Tags have a descriptive slug, and are attached to an arbitrary object. - """ - tag = models.SlugField() - content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE) - object_id = models.PositiveIntegerField() - tagged_item = GenericForeignKey('content_type', 'object_id') - - def __str__(self): - return self.tag - - -class Bookmark(models.Model): - """ - A URL bookmark that may have multiple tags attached. - """ - url = models.URLField() - tags = GenericRelation(Tag) - - def __str__(self): - return 'Bookmark: %s' % self.url - - -class Note(models.Model): - """ - A textual note that may have multiple tags attached. - """ - text = models.TextField() - tags = GenericRelation(Tag) - - def __str__(self): - return 'Note: %s' % self.text +from .models import Bookmark, Note, Tag class TestGenericRelations(TestCase): diff --git a/tests/test_permissions.py b/tests/test_permissions.py index 04fb3700f..c53dae18b 100644 --- a/tests/test_permissions.py +++ b/tests/test_permissions.py @@ -8,6 +8,7 @@ from django.contrib.auth.models import AnonymousUser, Group, Permission, User from django.db import models from django.test import TestCase from django.urls import ResolverMatch +from tests.models import BasicModel from rest_framework import ( HTTP_HEADER_ENCODING, RemovedInDRF310Warning, authentication, generics, @@ -18,8 +19,6 @@ from rest_framework.filters import DjangoObjectPermissionsFilter from rest_framework.routers import DefaultRouter from rest_framework.test import APIRequestFactory -from tests.models import BasicModel - factory = APIRequestFactory() diff --git a/tests/test_utils.py b/tests/test_utils.py index 996b3c8af..17c1a9bef 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,5 +1,6 @@ from django.conf.urls import url from django.test import TestCase, override_settings +from tests.models import BasicModel from rest_framework.decorators import action from rest_framework.routers import SimpleRouter @@ -10,8 +11,6 @@ from rest_framework.utils.urls import remove_query_param, replace_query_param from rest_framework.views import APIView from rest_framework.viewsets import ModelViewSet -from tests.models import BasicModel - class Root(APIView): pass