Commits

Anonymous committed fd72104

added tests for app itself

Comments (0)

Files changed (14)

django-smoke-admin/management/commands/smoke_admin_test.py

 from django.core.management.base import BaseCommand
-import runtests
+from runtests import runtests
+import StringIO
+from django.core import management
+
 
 class Command(BaseCommand):
 
     def handle(self, *args, **options):
-        runtests()
+#        runtests()
+        result = StringIO.StringIO()
+#        management.call_command('test', '../../test_integrational/test_integrational.py', verbosity=0, stdout=result)

django-smoke-admin/runtests.py

-#!/usr/bin/env python
-import os, sys
-
-os.environ.setdefault("DJANGO_SETTINGS_MODULE", 'test_app.test_settings')
-
-from optparse import OptionParser
-from django_nose.runner import NoseTestSuiteRunner
-
-
-def runtests(*test_args, **kwargs):
-
-    if not test_args:
-        test_args = ['tests']
-    test_args.append('--with-spec')
-    test_args.append('--spec-color')
-    kwargs.setdefault('interactive', False)
-    test_runner = NoseTestSuiteRunner(**kwargs)
-
-    failures = test_runner.run_tests(test_args)
-    sys.exit(failures)
-
-
-if __name__ == '__main__':
-    parser = OptionParser()
-    parser.add_option('--verbosity', dest='verbosity', action='store', default=1, type=int)
-    parser.add_options(NoseTestSuiteRunner.options)
-    (options, args) = parser.parse_args()
-
-    runtests(*args, **options.__dict__)
-
-
-if __name__ == '__main__':
-    runtests()

django-smoke-admin/test_app/__init__.py

Empty file removed.

django-smoke-admin/test_app/admin.py

-from django.contrib import admin
-from test_app.models import TestModel
-
-admin.site.register(TestModel)

django-smoke-admin/test_app/models.py

-from django.db import models
-
-
-class TestModel(models.Model):
-    test_field = models.BooleanField()

django-smoke-admin/test_app/test_settings.py

-import django
-
-DATABASES = {
-    'default': {
-        'ENGINE': 'django.db.backends.sqlite3',
-        'NAME': ':memory:',
-        },
-    }
-
-SECRET_KEY = '_'
-INSTALLED_APPS = (# required for admin
-                  'django.contrib.auth',
-                  'django.contrib.contenttypes',
-                  'django.contrib.admin',
-                  'django.contrib.sessions',
-
-                  'test_app',)
-TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
-ROOT_URLCONF = 'test_app.urls'

django-smoke-admin/test_app/urls.py

-from django.conf.urls import patterns, include, url
-from django.contrib import admin
-
-
-admin.autodiscover()
-
-urlpatterns = patterns('',
-    url(r'^admin/', include(admin.site.urls)),
-)

django-smoke-admin/tests/test_smoke_admin.py

 # -*- coding: utf-8 -*-
-from django.test import TestCase
+from django.test import TestCase, TransactionTestCase
 from django.contrib.auth.models import User
-from nose.tools import nottest
 from django.contrib import admin
 from django.core.urlresolvers import reverse
 from django_dynamic_fixture import G
 
+
 class SmokeAdminTest(TestCase):
     def setUp(self):
         User.objects.create_superuser('John', 'myemail@test.com', 'pwd')
         self.model_objects = dict()
         for model in self.registered_models:
             self.model_objects[model] = G(model)
-            print type(self.model_objects[model])
 
     def test_changelist_pages_avalible(self):
         """List pages of all registered models responds correctly"""
         for model in self.registered_models:
-            yield self.assertModelsChangelistAvalible, model
-        self.assertEqual(1, 2)
-
-    def assertModelsChangelistAvalible(self, model):
-        print model
-        response = self.client.get(reverse('admin:%s_%s_changelist'%(model._meta.app_label, model._meta.module_name)))
-        self.assertEqual(response.status_code, 2000)
+            response = self.client.get(reverse('admin:%s_%s_changelist'%(model._meta.app_label, model._meta.module_name)))
+            self.assertEqual(response.status_code, 200)
 
     def test_add_pages_avalible(self):
         """Add pages of all registered models responds correctly"""

test_app/__init__.py

Empty file added.

test_app/admin.py

+from django.contrib import admin
+from test_app.models import TestModel
+
+admin.site.register(TestModel)

test_app/models.py

+from django.db import models
+
+
+class TestModel(models.Model):
+    test_field = models.BooleanField()

test_app/runtests.py

+#!/usr/bin/env python
+import os, sys
+
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", 'test_app.test_settings')
+
+from optparse import OptionParser
+from django_nose.runner import NoseTestSuiteRunner
+
+
+def runtests(*test_args, **kwargs):
+
+    if not test_args:
+        test_args = ['tests']
+    print test_args
+    test_args += ('--with-spec', '--spec-color')
+#    test_args.append('--spec-color')
+    kwargs.setdefault('interactive', False)
+    test_runner = NoseTestSuiteRunner(**kwargs)
+
+    failures = test_runner.run_tests(test_args)
+    sys.exit(failures)
+
+
+if __name__ == '__main__':
+    parser = OptionParser()
+    parser.add_option('--verbosity', dest='verbosity', action='store', default=1, type=int)
+    parser.add_options(NoseTestSuiteRunner.options)
+    (options, args) = parser.parse_args()
+
+    runtests(*args, **options.__dict__)

test_app/test_settings.py

+import django
+
+DATABASES = {
+    'default': {
+        'ENGINE': 'django.db.backends.sqlite3',
+        'NAME': ':memory:',
+        },
+    }
+
+SECRET_KEY = '_'
+INSTALLED_APPS = (# required for admin
+                  'django.contrib.auth',
+                  'django.contrib.contenttypes',
+                  'django.contrib.admin',
+                  'django.contrib.sessions',
+
+#                  'django-smoke-admin',
+#                  'test_app',
+#                  'tests_intergational'
+    )
+TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
+NOSE_ARGS = ['--nocapture',]
+ROOT_URLCONF = 'test_app.urls'
+from django.conf.urls import patterns, include, url
+from django.contrib import admin
+
+
+admin.autodiscover()
+
+urlpatterns = patterns('',
+    url(r'^admin/', include(admin.site.urls)),
+)