test reorganized, launch them with setup.py test
This commit is contained in:
parent
058b50556b
commit
1f18782007
@ -6,7 +6,7 @@ import pylab
|
||||
|
||||
from django.db.models import F
|
||||
|
||||
from euscanwww import settings
|
||||
from django.conf import settings
|
||||
from djeuscan.models import Package
|
||||
|
||||
|
||||
|
@ -1,2 +1,32 @@
|
||||
from .models import *
|
||||
from .views import *
|
||||
from urllib import urlencode
|
||||
|
||||
from django.utils import unittest
|
||||
from django.test.client import Client
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
|
||||
class SystemTestCase(unittest.TestCase):
|
||||
"""
|
||||
Base class for system tests
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
self.client = Client()
|
||||
|
||||
def get(self, url_name, *args, **kwargs):
|
||||
param = kwargs.pop("param", None)
|
||||
if param:
|
||||
url = "%s?%s" % (reverse(url_name, args=args, kwargs=kwargs),
|
||||
urlencode(param))
|
||||
else:
|
||||
url = reverse(url_name, args=args, kwargs=kwargs)
|
||||
return self.client.get(url)
|
||||
|
||||
def post(self, url_name, *args, **kwargs):
|
||||
data = kwargs.pop("data", {})
|
||||
url = reverse(url_name, args=args, kwargs=kwargs)
|
||||
return self.client.post(url, data)
|
||||
|
||||
|
||||
from test_models import *
|
||||
from test_views import *
|
||||
|
14
euscanwww/djeuscan/tests/test_views.py
Normal file
14
euscanwww/djeuscan/tests/test_views.py
Normal file
@ -0,0 +1,14 @@
|
||||
from euscanwww.djeuscan.tests import SystemTestCase
|
||||
|
||||
|
||||
class NavigationTest(SystemTestCase):
|
||||
"""
|
||||
Test main pages
|
||||
"""
|
||||
|
||||
def test_index(self):
|
||||
"""
|
||||
Test index
|
||||
"""
|
||||
response = self.get("index")
|
||||
self.assertEqual(response.status_code, 200)
|
@ -1,12 +0,0 @@
|
||||
"""
|
||||
tests for models
|
||||
"""
|
||||
|
||||
from django.utils import unittest
|
||||
from django.test.client import RequestFactory
|
||||
|
||||
from djeuscan.views import index
|
||||
|
||||
|
||||
class ViewsTests(unittest.TestCase):
|
||||
pass
|
@ -207,4 +207,3 @@ except ImportError, ex:
|
||||
("settings.py: error importing local settings file:\n" + \
|
||||
"\t%s\n" + \
|
||||
"Do you have a local_settings.py module?\n") % str(ex))
|
||||
raise
|
||||
|
@ -1,45 +0,0 @@
|
||||
"""
|
||||
System tests for euscanwww
|
||||
"""
|
||||
|
||||
from urllib import urlencode
|
||||
|
||||
from django.utils import unittest
|
||||
from django.test.client import Client
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
|
||||
class SystemTestCase(unittest.TestCase):
|
||||
"""
|
||||
Base class for system tests
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
self.client = Client()
|
||||
|
||||
def get(self, url_name, *args, **kwargs):
|
||||
param = kwargs.pop("param", None)
|
||||
if param:
|
||||
url = "%s?%s" % (reverse(url_name, args=args, kwargs=kwargs),
|
||||
urlencode(param))
|
||||
else:
|
||||
url = reverse(url_name, args=args, kwargs=kwargs)
|
||||
return self.client.get(url)
|
||||
|
||||
def post(self, url_name, *args, **kwargs):
|
||||
data = kwargs.pop("data", {})
|
||||
url = reverse(url_name, args=args, kwargs=kwargs)
|
||||
return self.client.post(url, data)
|
||||
|
||||
|
||||
class NavigationTest(SystemTestCase):
|
||||
"""
|
||||
Test main pages
|
||||
"""
|
||||
|
||||
def test_index(self):
|
||||
"""
|
||||
Test index
|
||||
"""
|
||||
response = self.get("index")
|
||||
self.assertEqual(response.status_code, 200)
|
30
euscanwww/runtests.py
Normal file
30
euscanwww/runtests.py
Normal file
@ -0,0 +1,30 @@
|
||||
"""
|
||||
Runner for tests
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
from os.path import dirname, abspath
|
||||
from django.conf import settings
|
||||
|
||||
settings.configure(
|
||||
DATABASES={
|
||||
'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory;'}
|
||||
},
|
||||
INSTALLED_APPS=['euscanwww', 'djeuscan'],
|
||||
ROOT_URLCONF='euscanwww.euscanwww.urls',
|
||||
EUSCAN_ROOT=os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
|
||||
)
|
||||
|
||||
|
||||
def runtests():
|
||||
import django.test.utils
|
||||
|
||||
parent = dirname(abspath(__file__))
|
||||
sys.path.insert(0, parent)
|
||||
|
||||
runner_class = django.test.utils.get_runner(settings)
|
||||
test_runner = runner_class(verbosity=1, interactive=True)
|
||||
failures = test_runner.run_tests(['djeuscan'])
|
||||
|
||||
sys.exit(failures)
|
9
setup.py
9
setup.py
@ -68,6 +68,10 @@ packages = [
|
||||
if '__init__.py' in files
|
||||
]
|
||||
|
||||
tests_require = [
|
||||
'factory_boy',
|
||||
]
|
||||
|
||||
setup(
|
||||
name='euscan',
|
||||
version=__version__,
|
||||
@ -82,7 +86,7 @@ setup(
|
||||
('master' if __version__ == '9999' else ('euscan-%s' % __version__))
|
||||
),
|
||||
install_requires=['Django==1.4', 'django-annoying', 'South',
|
||||
'django-piston', 'matplotlib', 'BeautifulSoup'],
|
||||
'django-piston', 'BeautifulSoup'],
|
||||
package_dir={'': 'pym'},
|
||||
packages=packages,
|
||||
package_data={},
|
||||
@ -94,4 +98,7 @@ setup(
|
||||
cmdclass={
|
||||
'set_version': set_version,
|
||||
},
|
||||
tests_require=tests_require,
|
||||
extras_require={'test': tests_require},
|
||||
test_suite='euscanwww.runtests.runtests',
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user