Permalink
Browse files

Fixed test running. #2

  • Loading branch information...
1 parent 4455e84 commit c7429cb8d68b1232f7ebdb5f83b7e026fb5d1221 @mitar mitar committed May 14, 2012
View
@@ -31,4 +31,10 @@
'django-tastypie>=0.9.11',
'mongoengine>=0.6.3',
),
+ test_suite = 'tests.runtests',
+ tests_require = (
+ 'Django>=1.4',
+ 'django-tastypie>=0.9.11',
+ 'mongoengine>=0.6.3',
+ ),
)
View
@@ -1,14 +1,9 @@
#!/usr/bin/env python
-from django.core.management import execute_manager
-import imp
-try:
- imp.find_module('settings') # Assumed to be in the same directory.
-except ImportError:
- import sys
- sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n" % __file__)
- sys.exit(1)
-
-import settings
+import os, sys
if __name__ == "__main__":
- execute_manager(settings)
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_project.settings")
+
+ from django.core.management import execute_from_command_line
+
+ execute_from_command_line(sys.argv)
View
@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+import os, sys
+
+if __name__ == "__main__":
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_project.settings")
+
+ from django.core.management import execute_from_command_line
+
+ argv = sys.argv + ['test']
+ execute_from_command_line(argv)
@@ -1,6 +1,4 @@
-# Django settings for tpme_tests project
-import os, sys
-sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
+# Django settings for test_project project
DEBUG = True
@@ -15,21 +13,21 @@
'django.contrib.messages.middleware.MessageMiddleware',
)
-ROOT_URLCONF = 'tests.urls'
+ROOT_URLCONF = 'test_project.urls'
AUTHENTICATION_BACKENDS = (
'mongoengine.django.auth.MongoEngineBackend',
)
SESSION_ENGINE = 'mongoengine.django.sessions'
-TEST_RUNNER = 'tests.test_runner.TPMETestSuiteRunner'
+TEST_RUNNER = 'test_project.test_runner.TPMETestSuiteRunner'
INSTALLED_APPS = (
'tastypie',
'tastypie_mongoengine',
- 'test_app',
+ 'test_project.test_app',
)
import mongoengine
-mongoengine.connect('tpme_tests')
+mongoengine.connect('test_project')
@@ -2,7 +2,7 @@
from tastypie_mongoengine import resources, fields
-from test_app import documents
+from test_project.test_app import documents
class PersonResource(resources.MongoEngineResource):
class Meta:
@@ -11,15 +11,15 @@ class Meta:
authorization = authorization.Authorization()
class CustomerResource(resources.MongoEngineResource):
- person = tastypie_fields.ForeignKey(to='test_app.api.resources.PersonResource', attribute='person', full=True)
+ person = tastypie_fields.ForeignKey(to='test_project.test_app.api.resources.PersonResource', attribute='person', full=True)
class Meta:
queryset = documents.Customer.objects.all()
allowed_methods = ('get', 'post', 'put', 'delete')
authorization = authorization.Authorization()
class EmbededDocumentFieldTestResource(resources.MongoEngineResource):
- customer = fields.EmbeddedDocumentField(embedded='test_app.api.resources.EmbeddedPersonResource', attribute='customer')
+ customer = fields.EmbeddedDocumentField(embedded='test_project.test_app.api.resources.EmbeddedPersonResource', attribute='customer')
class Meta:
queryset = documents.EmbededDocumentFieldTest.objects.all()
@@ -39,7 +39,7 @@ class Meta:
authorization = authorization.Authorization()
class EmbeddedSortedListFieldTestResource(resources.MongoEngineResource):
- embeddedlist = fields.EmbeddedSortedListField(of='test_app.api.resources.EmbeddedPersonListResource', attribute='embeddedlist', full=True)
+ embeddedlist = fields.EmbeddedSortedListField(of='test_project.test_app.api.resources.EmbeddedPersonListResource', attribute='embeddedlist', full=True)
class Meta:
queryset = documents.EmbeddedListFieldTest.objects.all()
@@ -53,4 +53,4 @@ class Meta:
authorization = authorization.Authorization()
class EmbeddedPersonListResource(EmbeddedPersonResource, resources.MongoEngineListResource):
- pass
+ pass
@@ -1,7 +1,7 @@
from django.utils import unittest
from django.test import client
-from test_app import documents
+from test_project.test_app import documents
class SimpleTest(unittest.TestCase):
apiUrl = '/api/v1/'
@@ -49,4 +49,3 @@ def test_creating_content(self):
response = self.c.post(self.makeUrl('embeddedsortedlistfieldtest'), '{"embeddedlist": [{"name": "Embeded person 1"}, {"name": "Embeded person 2"}]}', content_type='application/json')
self.assertEqual(response.status_code, 201)
-
File renamed without changes.
File renamed without changes.
@@ -2,7 +2,7 @@
from tastypie import api
-from test_app.api import resources
+from test_project.test_app.api import resources
v1_api = api.Api(api_name='v1')
v1_api.register(resources.PersonResource())

0 comments on commit c7429cb

Please sign in to comment.