Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed test running. #2

  • Loading branch information...
commit c7429cb8d68b1232f7ebdb5f83b7e026fb5d1221 1 parent 4455e84
@mitar mitar authored
View
6 setup.py
@@ -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
17 tests/manage.py
@@ -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
10 tests/runtests.py
@@ -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)
View
0  tests/test_app/api/__init__.py → tests/test_project/__init__.py
File renamed without changes
View
12 tests/settings.py → tests/test_project/settings.py
@@ -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,7 +13,7 @@
'django.contrib.messages.middleware.MessageMiddleware',
)
-ROOT_URLCONF = 'tests.urls'
+ROOT_URLCONF = 'test_project.urls'
AUTHENTICATION_BACKENDS = (
'mongoengine.django.auth.MongoEngineBackend',
@@ -23,13 +21,13 @@
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')
View
0  tests/test_app/__init__.py → tests/test_project/test_app/__init__.py
File renamed without changes
View
0  tests/test_project/test_app/api/__init__.py
No changes.
View
10 tests/test_app/api/resources.py → tests/test_project/test_app/api/resources.py
@@ -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,7 +11,7 @@ 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()
@@ -19,7 +19,7 @@ class Meta:
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
View
0  tests/test_app/documents.py → tests/test_project/test_app/documents.py
File renamed without changes
View
0  tests/test_app/models.py → tests/test_project/test_app/models.py
File renamed without changes
View
3  tests/test_app/tests.py → tests/test_project/test_app/tests.py
@@ -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)
-
View
0  tests/test_app/views.py → tests/test_project/test_app/views.py
File renamed without changes
View
0  tests/test_runner.py → tests/test_project/test_runner.py
File renamed without changes
View
2  tests/urls.py → tests/test_project/urls.py
@@ -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())
Please sign in to comment.
Something went wrong with that request. Please try again.