Removed repeated model in tests and isort fix

This commit is contained in:
Rizwan Mansuri 2019-04-13 16:13:35 +01:00
parent c2c11a535f
commit 9e36a84619
3 changed files with 3 additions and 43 deletions

View File

@ -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):

View File

@ -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()

View File

@ -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