Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Moved tests from production project

  • Loading branch information...
commit 4d71061ecb0a46c45996e61e6f4992a75dc223b1 1 parent 7d1580d
Henrique Carvalho Alves authored
1  .gitignore
... ... @@ -1,4 +1,5 @@
1 1 *.DS_Store
2 2 *.pyc
3 3 *.egg-info
  4 +*.sublime*
4 5 build
0  manage.py 100644 → 100755
File mode changed
74 taggitext/fixtures/test.json
... ... @@ -0,0 +1,74 @@
  1 +[
  2 + {
  3 + "pk": 1,
  4 + "model": "taggit.tag",
  5 + "fields": {
  6 + "name": "The Matrix",
  7 + "slug": "the-matrix"
  8 + }
  9 + },
  10 + {
  11 + "pk": 2,
  12 + "model": "taggit.tag",
  13 + "fields": {
  14 + "name": "Keanu Reeves",
  15 + "slug": "keanu-reeves"
  16 + }
  17 + },
  18 + {
  19 + "pk": 3,
  20 + "model": "taggit.tag",
  21 + "fields": {
  22 + "name": "Laurence Fishburne",
  23 + "slug": "laurence-fishburne"
  24 + }
  25 + },
  26 + {
  27 + "pk": 4,
  28 + "model": "taggit.tag",
  29 + "fields": {
  30 + "name": "Carrie-Anne Moss",
  31 + "slug": "carrie-anne-moss"
  32 + }
  33 + },
  34 + {
  35 + "pk": 5,
  36 + "model": "taggit.tag",
  37 + "fields": {
  38 + "name": "Wachowski Brothers",
  39 + "slug": "wachowski-brothers"
  40 + }
  41 + },
  42 + {
  43 + "pk": 6,
  44 + "model": "taggit.tag",
  45 + "fields": {
  46 + "name": "Neo",
  47 + "slug": "neo"
  48 + }
  49 + },
  50 + {
  51 + "pk": 7,
  52 + "model": "taggit.tag",
  53 + "fields": {
  54 + "name": "Morpheus",
  55 + "slug": "morpheus"
  56 + }
  57 + },
  58 + {
  59 + "pk": 8,
  60 + "model": "taggit.tag",
  61 + "fields": {
  62 + "name": "Trinity",
  63 + "slug": "trinity"
  64 + }
  65 + },
  66 + {
  67 + "pk": 9,
  68 + "model": "taggit.tag",
  69 + "fields": {
  70 + "name": "Agent Smith",
  71 + "slug": "agent-smith"
  72 + }
  73 + }
  74 +]
3  taggitext/managers.py
... ... @@ -1,4 +1,3 @@
1   -from django.contrib.admin.widgets import AdminTextInputWidget
2 1 from django.utils.translation import ugettext_lazy as _
3 2 from django.utils.simplejson import loads
4 3
@@ -24,7 +23,5 @@ def formfield(self, form_class=AutocompleteTagField, **kwargs):
24 23 "help_text": "",
25 24 }
26 25 defaults.update(kwargs)
27   -
28 26 kwargs['widget'] = TagAutocomplete
29   -
30 27 return form_class(**kwargs)
0  taggitext/models.py
No changes.
23 taggitext/tests.py
... ... @@ -0,0 +1,23 @@
  1 +from django.core.urlresolvers import reverse
  2 +from django.test import TestCase
  3 +from django.test.client import Client
  4 +
  5 +from taggit.models import Tag
  6 +from taggitext.views import search_tags
  7 +
  8 +
  9 +class SearchViewTest(TestCase):
  10 + fixtures = ['test.json']
  11 +
  12 + def setUp(self):
  13 + self.client = Client()
  14 + self.view = reverse('taggitext-search')
  15 +
  16 + def test_can_query(self):
  17 + response = self.client.get(self.view, {'q': 'matrix'})
  18 + self.assertEqual(response.status_code, 200)
  19 + self.assertEqual(response.content, '["The Matrix"]')
  20 +
  21 + def test_bad_request_on_empty_query(self):
  22 + response = self.client.get(self.view, {})
  23 + self.assertEqual(response.status_code, 400)
2  taggitext/views.py
@@ -4,8 +4,10 @@
4 4
5 5 from taggit.models import Tag
6 6
  7 +
7 8 RESULTS = getattr(settings, 'TAGGITEXT_RESULTS_LIMIT', 20)
8 9
  10 +
9 11 # TODO: Cache the results
10 12 def search_tags(request):
11 13 try:
16 taggitext_dev/sample/tests.py
... ... @@ -1,16 +0,0 @@
1   -"""
2   -This file demonstrates writing tests using the unittest module. These will pass
3   -when you run "manage.py test".
4   -
5   -Replace this with more appropriate tests for your application.
6   -"""
7   -
8   -from django.test import TestCase
9   -
10   -
11   -class SimpleTest(TestCase):
12   - def test_basic_addition(self):
13   - """
14   - Tests that 1 + 1 always equals 2.
15   - """
16   - self.assertEqual(1 + 1, 2)

0 comments on commit 4d71061

Please sign in to comment.
Something went wrong with that request. Please try again.