Browse Source

Reorganize core package tests into modules

tags/v1.0.0
Krzysztof Klimonda 11 years ago
parent
commit
03e05906f8
3 changed files with 24 additions and 2 deletions
  1. +2
    -0
      pinry/core/tests/__init__.py
  2. +11
    -2
      pinry/core/tests/api.py
  3. +11
    -0
      pinry/core/tests/forms.py

+ 2
- 0
pinry/core/tests/__init__.py View File

@@ -0,0 +1,2 @@
from .api import *
from .forms import *

pinry/core/tests.py → pinry/core/tests/api.py View File

@@ -6,8 +6,11 @@ from django_images.models import Thumbnail
from taggit.models import Tag
from tastypie.test import ResourceTestCase

from .models import Pin, Image
from ..users.models import User
from ..models import Pin, Image
from ...users.models import User


__all__ = ['ImageResourceTest', 'PinResourceTest']


def filter_generator_for(size):
@@ -197,6 +200,12 @@ class PinResourceTest(ResourceTestCase):
self.assertValidJSONResponse(response)
self.assertEqual(self.deserialize(response)['objects'][0]['id'], pin.id)

def test_get_list_json_filtered(self):
tag = self.pin_1.tags.all()[0]
response = self.api_client.get('/api/v1/pin/', format='json', data={'tag': tag})
self.assertValidJSONResponse(response)
self.assertEqual(self.deserialize(response)['objects'][0]['id'], self.pin_1.id)

def test_get_list_json(self):
user = User.objects.get(pk=1)
image = Image.objects.get(pk=1)

+ 11
- 0
pinry/core/tests/forms.py View File

@@ -0,0 +1,11 @@
from django.test import TestCase
from ..forms import ImageForm


__all__ = ['ImageFormTest']

class ImageFormTest(TestCase):
def test_image_field_prefix(self):
"""Assert that the image field has a proper name"""
form = ImageForm()
self.assertInHTML("<input id='id_qqfile' name='qqfile' type='file' />", str(form))

Loading…
Cancel
Save