Revision 2c5283e2
Utilisation de unittest.TestCase dans les tests de VigiGraph.
git-svn-id: https://vigilo-dev.si.c-s.fr/svn@2570 b22e2e97-25c9-44ff-b637-2e5ceca36478
vigigraph/tests/__init__.py | ||
---|---|---|
4 | 4 |
from os import path |
5 | 5 |
import sys |
6 | 6 |
|
7 |
import unittest |
|
7 | 8 |
from tg import config |
8 | 9 |
from paste.deploy import loadapp |
9 | 10 |
from paste.script.appinstall import SetupCommand |
10 | 11 |
from routes import url_for |
11 | 12 |
from webtest import TestApp |
12 |
from nose.tools import eq_ |
|
13 | 13 |
|
14 | 14 |
from vigilo.models.session import metadata, DBSession |
15 | 15 |
|
... | ... | |
27 | 27 |
engine = config['pylons.app_globals'].sa_engine |
28 | 28 |
metadata.drop_all(engine) |
29 | 29 |
|
30 |
class TestController(object):
|
|
30 |
class TestController(unittest.TestCase):
|
|
31 | 31 |
""" |
32 | 32 |
Base functional test case for the controllers. |
33 | 33 |
|
... | ... | |
46 | 46 |
|
47 | 47 |
application_under_test = 'main_without_authn' |
48 | 48 |
|
49 |
def __init__(self): |
|
50 |
object.__init__(self) |
|
51 |
|
|
52 | 49 |
def setUp(self): |
53 | 50 |
"""Method called by nose before running each test""" |
54 | 51 |
# Loading the application: |
55 |
setup_db() |
|
56 | 52 |
conf_dir = config.here |
57 | 53 |
wsgiapp = loadapp('config:test.ini#%s' % self.application_under_test, |
58 | 54 |
relative_to=conf_dir) |
vigigraph/tests/functional/test_nagiosproxy.py | ||
---|---|---|
69 | 69 |
|
70 | 70 |
def getServer(host): |
71 | 71 |
'''Server''' |
72 |
|
|
73 |
server = None |
|
74 |
|
|
75 | 72 |
result = DBSession.query(VigiloServer.name) \ |
76 | 73 |
.filter(VigiloServer.idvigiloserver == Ventilation.idvigiloserver) \ |
77 | 74 |
.filter(Ventilation.idhost == Host.idhost) \ |
78 | 75 |
.filter(Ventilation.idapp == Application.idapp) \ |
79 | 76 |
.filter(Host.name == host) \ |
80 | 77 |
.filter(Application.name == u'nagios') \ |
81 |
.first() |
|
82 |
|
|
83 |
if result is not None: |
|
84 |
server = result[0] |
|
78 |
.scalar() |
|
85 | 79 |
|
86 |
return server
|
|
80 |
return result
|
|
87 | 81 |
|
88 | 82 |
|
89 | 83 |
class NagiosProxy_without_nagios(NagiosProxy): |
... | ... | |
148 | 142 |
class TestNagiosProxy_bd(TestController): |
149 | 143 |
""" Test Gestion Valeur Nagios """ |
150 | 144 |
|
151 |
def setup(self):
|
|
145 |
def setUp(self):
|
|
152 | 146 |
'''setup''' |
153 | 147 |
super(TestNagiosProxy_bd, self).setUp() |
154 | 148 |
|
Also available in: Unified diff