Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Moved tests from production project

  • Loading branch information...
commit 4d71061ecb0a46c45996e61e6f4992a75dc223b1 1 parent 7d1580d
@hcarvalhoalves authored
View
1  .gitignore
@@ -1,4 +1,5 @@
*.DS_Store
*.pyc
*.egg-info
+*.sublime*
build
View
0  manage.py 100644 → 100755
File mode changed
View
74 taggitext/fixtures/test.json
@@ -0,0 +1,74 @@
+[
+ {
+ "pk": 1,
+ "model": "taggit.tag",
+ "fields": {
+ "name": "The Matrix",
+ "slug": "the-matrix"
+ }
+ },
+ {
+ "pk": 2,
+ "model": "taggit.tag",
+ "fields": {
+ "name": "Keanu Reeves",
+ "slug": "keanu-reeves"
+ }
+ },
+ {
+ "pk": 3,
+ "model": "taggit.tag",
+ "fields": {
+ "name": "Laurence Fishburne",
+ "slug": "laurence-fishburne"
+ }
+ },
+ {
+ "pk": 4,
+ "model": "taggit.tag",
+ "fields": {
+ "name": "Carrie-Anne Moss",
+ "slug": "carrie-anne-moss"
+ }
+ },
+ {
+ "pk": 5,
+ "model": "taggit.tag",
+ "fields": {
+ "name": "Wachowski Brothers",
+ "slug": "wachowski-brothers"
+ }
+ },
+ {
+ "pk": 6,
+ "model": "taggit.tag",
+ "fields": {
+ "name": "Neo",
+ "slug": "neo"
+ }
+ },
+ {
+ "pk": 7,
+ "model": "taggit.tag",
+ "fields": {
+ "name": "Morpheus",
+ "slug": "morpheus"
+ }
+ },
+ {
+ "pk": 8,
+ "model": "taggit.tag",
+ "fields": {
+ "name": "Trinity",
+ "slug": "trinity"
+ }
+ },
+ {
+ "pk": 9,
+ "model": "taggit.tag",
+ "fields": {
+ "name": "Agent Smith",
+ "slug": "agent-smith"
+ }
+ }
+]
View
3  taggitext/managers.py
@@ -1,4 +1,3 @@
-from django.contrib.admin.widgets import AdminTextInputWidget
from django.utils.translation import ugettext_lazy as _
from django.utils.simplejson import loads
@@ -24,7 +23,5 @@ def formfield(self, form_class=AutocompleteTagField, **kwargs):
"help_text": "",
}
defaults.update(kwargs)
-
kwargs['widget'] = TagAutocomplete
-
return form_class(**kwargs)
View
0  taggitext/models.py
No changes.
View
23 taggitext/tests.py
@@ -0,0 +1,23 @@
+from django.core.urlresolvers import reverse
+from django.test import TestCase
+from django.test.client import Client
+
+from taggit.models import Tag
+from taggitext.views import search_tags
+
+
+class SearchViewTest(TestCase):
+ fixtures = ['test.json']
+
+ def setUp(self):
+ self.client = Client()
+ self.view = reverse('taggitext-search')
+
+ def test_can_query(self):
+ response = self.client.get(self.view, {'q': 'matrix'})
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(response.content, '["The Matrix"]')
+
+ def test_bad_request_on_empty_query(self):
+ response = self.client.get(self.view, {})
+ self.assertEqual(response.status_code, 400)
View
2  taggitext/views.py
@@ -4,8 +4,10 @@
from taggit.models import Tag
+
RESULTS = getattr(settings, 'TAGGITEXT_RESULTS_LIMIT', 20)
+
# TODO: Cache the results
def search_tags(request):
try:
View
16 taggitext_dev/sample/tests.py
@@ -1,16 +0,0 @@
-"""
-This file demonstrates writing tests using the unittest module. These will pass
-when you run "manage.py test".
-
-Replace this with more appropriate tests for your application.
-"""
-
-from django.test import TestCase
-
-
-class SimpleTest(TestCase):
- def test_basic_addition(self):
- """
- Tests that 1 + 1 always equals 2.
- """
- self.assertEqual(1 + 1, 2)
Please sign in to comment.
Something went wrong with that request. Please try again.