Horst Gutmann avatar Horst Gutmann committed 96b8eea

Moved the whole test environment into tests/

Comments (0)

Files changed (28)

bootstrap.py

-##############################################################################
-#
-# Copyright (c) 2006 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Bootstrap a buildout-based project
-
-Simply run this script in a directory containing a buildout.cfg.
-The script accepts buildout command-line options, so you can
-use the -c option to specify an alternate configuration file.
-
-$Id$
-"""
-
-import os, shutil, sys, tempfile, urllib2
-
-tmpeggs = tempfile.mkdtemp()
-
-is_jython = sys.platform.startswith('java')
-
-try:
-    import pkg_resources
-except ImportError:
-    ez = {}
-    exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
-                         ).read() in ez
-    ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
-
-    import pkg_resources
-
-if sys.platform == 'win32':
-    def quote(c):
-        if ' ' in c:
-            return '"%s"' % c # work around spawn lamosity on windows
-        else:
-            return c
-else:
-    def quote (c):
-        return c
-
-cmd = 'from setuptools.command.easy_install import main; main()'
-ws  = pkg_resources.working_set
-
-if len(sys.argv) > 2 and sys.argv[1] == '--version':
-    VERSION = ' == %s' % sys.argv[2]
-    args = sys.argv[3:] + ['bootstrap']
-else:
-    VERSION = ''
-    args = sys.argv[1:] + ['bootstrap']
-
-if is_jython:
-    import subprocess
-
-    assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd',
-           quote(tmpeggs), 'zc.buildout' + VERSION],
-           env=dict(os.environ,
-               PYTHONPATH=
-               ws.find(pkg_resources.Requirement.parse('setuptools')).location
-               ),
-           ).wait() == 0
-
-else:
-    assert os.spawnle(
-        os.P_WAIT, sys.executable, quote (sys.executable),
-        '-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout' + VERSION,
-        dict(os.environ,
-            PYTHONPATH=
-            ws.find(pkg_resources.Requirement.parse('setuptools')).location
-            ),
-        ) == 0
-
-ws.add_entry(tmpeggs)
-ws.require('zc.buildout' + VERSION)
-import zc.buildout.buildout
-zc.buildout.buildout.main(args)
-shutil.rmtree(tmpeggs)

buildout.cfg

-[buildout]
-parts = django
-develop = .
-eggs = 
-    django-piston
-
-[django]
-recipe = djangorecipe
-version = 1.0.2
-project = test_project
-settings = settings
-test = testapp
-eggs = ${buildout:eggs}
Add a comment to this file

test_project/__init__.py

Empty file removed.

Add a comment to this file

test_project/apps/__init__.py

Empty file removed.

Add a comment to this file

test_project/apps/testapp/__init__.py

Empty file removed.

test_project/apps/testapp/handlers.py

-from django.core.paginator import Paginator
-
-from piston.handler import BaseHandler
-from piston.utils import rc, validate
-
-from .models import TestModel
-
-class EntryHandler(BaseHandler):
-    model = TestModel
-    allowed_methods = ['GET']
-
-    def read(self, request, pk=None):
-        if pk is not None:
-            return TestModel.objects.get(pk=int(pk))
-        paginator = Paginator(TestModel.objects.all(), 25)
-        return paginator.page(int(request.GET.get('page', 1))).object_list
-

test_project/apps/testapp/models.py

-from django.db import models
-
-class TestModel(models.Model):
-    test1 = models.CharField(max_length=1, blank=True, null=True)
-    test2 = models.CharField(max_length=1, blank=True, null=True)
-    pass

test_project/apps/testapp/tests.py

-from django.test import TestCase
-from django.contrib.auth.models import User
-import base64
-
-from test_project.apps.testapp.models import TestModel
-
-
-class MainTests(TestCase):
-    def setUp(self):
-        self.user = User.objects.create_user('admin', 'admin@world.com', 'admin')
-        self.user.is_staff = True
-        self.user.is_superuser = True
-        self.user.is_active = True
-        self.user.save()
-        self.auth_string = 'Basic %s' % base64.encodestring('admin:admin').rstrip()
-        self.t1_data = TestModel()
-        self.t1_data.save()
-        self.t2_data = TestModel()
-        self.t2_data.save()
-
-    def tearDown(self):
-        self.user.delete()
- 
-    def test_multixml(self):
-        expected = '<?xml version="1.0" encoding="utf-8"?>\n<response><resource><test1>None</test1><test2>None</test2></resource><resource><test1>None</test1><test2>None</test2></resource></response>'
-        result = self.client.get('/api/entries.xml',
-                HTTP_AUTHORIZATION=self.auth_string).content
-        self.assertEquals(expected, result)
-
-    def test_singlexml(self):
-        obj = TestModel.objects.all()[0]
-        expected = '<?xml version="1.0" encoding="utf-8"?>\n<response><test1>None</test1><test2>None</test2></response>'
-        result = self.client.get('/api/entry-%d.xml' % (obj.pk,),
-                HTTP_AUTHORIZATION=self.auth_string).content
-        self.assertEquals(expected, result)
-    def test_single(self):
-        pass

test_project/apps/testapp/urls.py

-from django.conf.urls.defaults import *
-from piston.resource import Resource
-from piston.authentication import HttpBasicAuthentication
-
-from test_project.apps.testapp.handlers import EntryHandler
-
-auth = HttpBasicAuthentication(realm='TestApplication')
-
-entries = Resource(handler=EntryHandler, authentication=auth)
-
-urlpatterns = patterns('',
-    url(r'^entries/$', entries),
-    url(r'^entries/(?P<pk>.+)/$', entries),
-    url(r'^entries\.(?P<emitter_format>.+)', entries),
-    url(r'^entry-(?P<pk>.+)\.(?P<emitter_format>.+)', entries),
-)
-
-

test_project/settings.py

-import os
-DEBUG = True
-DATABASE_ENGINE = 'sqlite3'
-DATABASE_NAME = '/tmp/piston.db'
-INSTALLED_APPS = (
-    'django.contrib.auth', 
-    'django.contrib.contenttypes', 
-    'django.contrib.sessions', 
-    'piston',
-    'test_project.apps.testapp',
-)
-TEMPLATE_DIRS = (
-    os.path.join(os.path.dirname(__file__), 'templates'),
-)
-ROOT_URLCONF = 'test_project.urls'
Add a comment to this file

test_project/templates/404.html

Empty file removed.

Add a comment to this file

test_project/templates/500.html

Empty file removed.

Add a comment to this file

test_project/templates/admin/login.html

Empty file removed.

test_project/urls.py

-from django.conf.urls.defaults import *
-
-
-urlpatterns = patterns('',
-    url(r'api/', include('test_project.apps.testapp.urls'))
-)

tests/bootstrap.py

+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id$
+"""
+
+import os, shutil, sys, tempfile, urllib2
+
+tmpeggs = tempfile.mkdtemp()
+
+is_jython = sys.platform.startswith('java')
+
+try:
+    import pkg_resources
+except ImportError:
+    ez = {}
+    exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+                         ).read() in ez
+    ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+    import pkg_resources
+
+if sys.platform == 'win32':
+    def quote(c):
+        if ' ' in c:
+            return '"%s"' % c # work around spawn lamosity on windows
+        else:
+            return c
+else:
+    def quote (c):
+        return c
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+ws  = pkg_resources.working_set
+
+if len(sys.argv) > 2 and sys.argv[1] == '--version':
+    VERSION = ' == %s' % sys.argv[2]
+    args = sys.argv[3:] + ['bootstrap']
+else:
+    VERSION = ''
+    args = sys.argv[1:] + ['bootstrap']
+
+if is_jython:
+    import subprocess
+
+    assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd',
+           quote(tmpeggs), 'zc.buildout' + VERSION],
+           env=dict(os.environ,
+               PYTHONPATH=
+               ws.find(pkg_resources.Requirement.parse('setuptools')).location
+               ),
+           ).wait() == 0
+
+else:
+    assert os.spawnle(
+        os.P_WAIT, sys.executable, quote (sys.executable),
+        '-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout' + VERSION,
+        dict(os.environ,
+            PYTHONPATH=
+            ws.find(pkg_resources.Requirement.parse('setuptools')).location
+            ),
+        ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout' + VERSION)
+import zc.buildout.buildout
+zc.buildout.buildout.main(args)
+shutil.rmtree(tmpeggs)

tests/buildout.cfg

+[buildout]
+parts = django
+develop = ..
+eggs = 
+    django-piston
+
+[django]
+recipe = djangorecipe
+version = 1.0.2
+project = test_project
+settings = settings
+test = testapp
+eggs = ${buildout:eggs}
Add a comment to this file

tests/test_project/__init__.py

Empty file added.

Add a comment to this file

tests/test_project/apps/__init__.py

Empty file added.

Add a comment to this file

tests/test_project/apps/testapp/__init__.py

Empty file added.

tests/test_project/apps/testapp/handlers.py

+from django.core.paginator import Paginator
+
+from piston.handler import BaseHandler
+from piston.utils import rc, validate
+
+from .models import TestModel
+
+class EntryHandler(BaseHandler):
+    model = TestModel
+    allowed_methods = ['GET']
+
+    def read(self, request, pk=None):
+        if pk is not None:
+            return TestModel.objects.get(pk=int(pk))
+        paginator = Paginator(TestModel.objects.all(), 25)
+        return paginator.page(int(request.GET.get('page', 1))).object_list
+

tests/test_project/apps/testapp/models.py

+from django.db import models
+
+class TestModel(models.Model):
+    test1 = models.CharField(max_length=1, blank=True, null=True)
+    test2 = models.CharField(max_length=1, blank=True, null=True)
+    pass

tests/test_project/apps/testapp/tests.py

+from django.test import TestCase
+from django.contrib.auth.models import User
+import base64
+
+from test_project.apps.testapp.models import TestModel
+
+
+class MainTests(TestCase):
+    def setUp(self):
+        self.user = User.objects.create_user('admin', 'admin@world.com', 'admin')
+        self.user.is_staff = True
+        self.user.is_superuser = True
+        self.user.is_active = True
+        self.user.save()
+        self.auth_string = 'Basic %s' % base64.encodestring('admin:admin').rstrip()
+        self.t1_data = TestModel()
+        self.t1_data.save()
+        self.t2_data = TestModel()
+        self.t2_data.save()
+
+    def tearDown(self):
+        self.user.delete()
+ 
+    def test_multixml(self):
+        expected = '<?xml version="1.0" encoding="utf-8"?>\n<response><resource><test1>None</test1><test2>None</test2></resource><resource><test1>None</test1><test2>None</test2></resource></response>'
+        result = self.client.get('/api/entries.xml',
+                HTTP_AUTHORIZATION=self.auth_string).content
+        self.assertEquals(expected, result)
+
+    def test_singlexml(self):
+        obj = TestModel.objects.all()[0]
+        expected = '<?xml version="1.0" encoding="utf-8"?>\n<response><test1>None</test1><test2>None</test2></response>'
+        result = self.client.get('/api/entry-%d.xml' % (obj.pk,),
+                HTTP_AUTHORIZATION=self.auth_string).content
+        self.assertEquals(expected, result)
+    def test_single(self):
+        pass

tests/test_project/apps/testapp/urls.py

+from django.conf.urls.defaults import *
+from piston.resource import Resource
+from piston.authentication import HttpBasicAuthentication
+
+from test_project.apps.testapp.handlers import EntryHandler
+
+auth = HttpBasicAuthentication(realm='TestApplication')
+
+entries = Resource(handler=EntryHandler, authentication=auth)
+
+urlpatterns = patterns('',
+    url(r'^entries/$', entries),
+    url(r'^entries/(?P<pk>.+)/$', entries),
+    url(r'^entries\.(?P<emitter_format>.+)', entries),
+    url(r'^entry-(?P<pk>.+)\.(?P<emitter_format>.+)', entries),
+)
+
+

tests/test_project/settings.py

+import os
+DEBUG = True
+DATABASE_ENGINE = 'sqlite3'
+DATABASE_NAME = '/tmp/piston.db'
+INSTALLED_APPS = (
+    'django.contrib.auth', 
+    'django.contrib.contenttypes', 
+    'django.contrib.sessions', 
+    'piston',
+    'test_project.apps.testapp',
+)
+TEMPLATE_DIRS = (
+    os.path.join(os.path.dirname(__file__), 'templates'),
+)
+ROOT_URLCONF = 'test_project.urls'
Add a comment to this file

tests/test_project/templates/404.html

Empty file added.

Add a comment to this file

tests/test_project/templates/500.html

Empty file added.

Add a comment to this file

tests/test_project/templates/admin/login.html

Empty file added.

tests/test_project/urls.py

+from django.conf.urls.defaults import *
+
+
+urlpatterns = patterns('',
+    url(r'api/', include('test_project.apps.testapp.urls'))
+)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.