mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-25 19:14:01 +03:00
Remove test cruft
This commit is contained in:
parent
fd7db776ad
commit
e5cd693e7b
|
@ -1,8 +0,0 @@
|
||||||
from django.db import models
|
|
||||||
|
|
||||||
from tests.users.models import User
|
|
||||||
|
|
||||||
|
|
||||||
class Account(models.Model):
|
|
||||||
owner = models.ForeignKey(User, related_name='accounts_owned')
|
|
||||||
admins = models.ManyToManyField(User, blank=True, null=True, related_name='accounts_administered')
|
|
|
@ -1,11 +0,0 @@
|
||||||
from rest_framework import serializers
|
|
||||||
|
|
||||||
from tests.accounts.models import Account
|
|
||||||
from tests.users.serializers import UserSerializer
|
|
||||||
|
|
||||||
|
|
||||||
class AccountSerializer(serializers.ModelSerializer):
|
|
||||||
admins = UserSerializer(many=True)
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
model = Account
|
|
|
@ -33,9 +33,6 @@ def pytest_configure():
|
||||||
'rest_framework',
|
'rest_framework',
|
||||||
'rest_framework.authtoken',
|
'rest_framework.authtoken',
|
||||||
'tests',
|
'tests',
|
||||||
'tests.accounts',
|
|
||||||
'tests.records',
|
|
||||||
'tests.users',
|
|
||||||
),
|
),
|
||||||
PASSWORD_HASHERS=(
|
PASSWORD_HASHERS=(
|
||||||
'django.contrib.auth.hashers.SHA1PasswordHasher',
|
'django.contrib.auth.hashers.SHA1PasswordHasher',
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
# From test_validation...
|
|
||||||
|
|
||||||
class TestPreSaveValidationExclusions(TestCase):
|
|
||||||
def test_pre_save_validation_exclusions(self):
|
|
||||||
"""
|
|
||||||
Somewhat weird test case to ensure that we don't perform model
|
|
||||||
validation on read only fields.
|
|
||||||
"""
|
|
||||||
obj = ValidationModel.objects.create(blank_validated_field='')
|
|
||||||
request = factory.put('/', {}, format='json')
|
|
||||||
view = UpdateValidationModel().as_view()
|
|
||||||
response = view(request, pk=obj.pk).render()
|
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
||||||
|
|
||||||
|
|
||||||
# From test_permissions...
|
|
||||||
|
|
||||||
class ModelPermissionsIntegrationTests(TestCase):
|
|
||||||
def setUp(...):
|
|
||||||
...
|
|
||||||
|
|
||||||
def test_has_put_as_create_permissions(self):
|
|
||||||
# User only has update permissions - should be able to update an entity.
|
|
||||||
request = factory.put('/1', {'text': 'foobar'}, format='json',
|
|
||||||
HTTP_AUTHORIZATION=self.updateonly_credentials)
|
|
||||||
response = instance_view(request, pk='1')
|
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
||||||
|
|
||||||
# But if PUTing to a new entity, permission should be denied.
|
|
||||||
request = factory.put('/2', {'text': 'foobar'}, format='json',
|
|
||||||
HTTP_AUTHORIZATION=self.updateonly_credentials)
|
|
||||||
response = instance_view(request, pk='2')
|
|
||||||
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
|
|
|
@ -1,6 +0,0 @@
|
||||||
from django.db import models
|
|
||||||
|
|
||||||
|
|
||||||
class Record(models.Model):
|
|
||||||
account = models.ForeignKey('accounts.Account', blank=True, null=True)
|
|
||||||
owner = models.ForeignKey('users.User', blank=True, null=True)
|
|
|
@ -96,9 +96,6 @@ INSTALLED_APPS = (
|
||||||
'rest_framework',
|
'rest_framework',
|
||||||
'rest_framework.authtoken',
|
'rest_framework.authtoken',
|
||||||
'tests',
|
'tests',
|
||||||
'tests.accounts',
|
|
||||||
'tests.records',
|
|
||||||
'tests.users',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# OAuth is optional and won't work if there is no oauth_provider & oauth2
|
# OAuth is optional and won't work if there is no oauth_provider & oauth2
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
# from django.test import TestCase
|
|
||||||
|
|
||||||
# from rest_framework import serializers
|
|
||||||
# from tests.accounts.serializers import AccountSerializer
|
|
||||||
|
|
||||||
|
|
||||||
# class ImportingModelSerializerTests(TestCase):
|
|
||||||
# """
|
|
||||||
# In some situations like, GH #1225, it is possible, especially in
|
|
||||||
# testing, to import a serializer who's related models have not yet
|
|
||||||
# been resolved by Django. `AccountSerializer` is an example of such
|
|
||||||
# a serializer (imported at the top of this file).
|
|
||||||
# """
|
|
||||||
# def test_import_model_serializer(self):
|
|
||||||
# """
|
|
||||||
# The serializer at the top of this file should have been
|
|
||||||
# imported successfully, and we should be able to instantiate it.
|
|
||||||
# """
|
|
||||||
# self.assertIsInstance(AccountSerializer(), serializers.ModelSerializer)
|
|
|
@ -1,6 +0,0 @@
|
||||||
from django.db import models
|
|
||||||
|
|
||||||
|
|
||||||
class User(models.Model):
|
|
||||||
account = models.ForeignKey('accounts.Account', blank=True, null=True, related_name='users')
|
|
||||||
active_record = models.ForeignKey('records.Record', blank=True, null=True)
|
|
|
@ -1,8 +0,0 @@
|
||||||
from rest_framework import serializers
|
|
||||||
|
|
||||||
from tests.users.models import User
|
|
||||||
|
|
||||||
|
|
||||||
class UserSerializer(serializers.ModelSerializer):
|
|
||||||
class Meta:
|
|
||||||
model = User
|
|
Loading…
Reference in New Issue
Block a user