new tests architecture
This commit is contained in:
parent
843db82d8a
commit
9c7f585753
7 changed files with 25 additions and 79 deletions
|
|
@ -1,18 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2010 Romain Bignon
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 3 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
from .weboobtests import WeboobTests
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2010 Romain Bignon
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 3 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
from nose import run
|
||||
|
||||
from weboob.tools.application.console import ConsoleApplication
|
||||
|
||||
__all__ = ['WeboobTests']
|
||||
|
||||
|
||||
class WeboobTests(ConsoleApplication):
|
||||
APPNAME = 'weboobtests'
|
||||
VERSION = '0.1'
|
||||
COPYRIGHT = 'Copyright(C) 2010 Romain Bignon'
|
||||
|
||||
def main(self, argv):
|
||||
return self.process_command(*argv[1:])
|
||||
|
||||
@ConsoleApplication.command('Run tests')
|
||||
def command_run(self):
|
||||
self.load_backends()
|
||||
self.load_configured_backends()
|
||||
|
||||
suite = []
|
||||
for backend in self.weboob.iter_backends():
|
||||
test = backend.get_test()
|
||||
if test:
|
||||
suite.append(test)
|
||||
|
||||
return run(suite=suite)
|
||||
|
|
@ -18,3 +18,5 @@
|
|||
|
||||
from .browser import DLFP
|
||||
from .backend import DLFPBackend
|
||||
|
||||
__all__ = ['DLFP', 'DLFPBackend']
|
||||
|
|
|
|||
|
|
@ -17,3 +17,6 @@
|
|||
|
||||
|
||||
from .bcall import CallErrors
|
||||
from .ouiboube import Weboob
|
||||
|
||||
__all__ = ['CallErrors', 'Weboob']
|
||||
|
|
|
|||
|
|
@ -82,13 +82,15 @@ class Weboob(object):
|
|||
self.backend_instances[backend_name] = loaded[backend_name] = backend_instance
|
||||
return loaded
|
||||
|
||||
def load_configured_backends(self, caps=None, names=None, storage=None):
|
||||
def load_configured_backends(self, caps=None, names=None, modules=None, storage=None):
|
||||
loaded = {}
|
||||
if storage is None:
|
||||
storage = self.storage
|
||||
|
||||
for instance_name, backend_name, params in self.backends_config.iter_backends():
|
||||
if '_enabled' in params and not params['_enabled']:
|
||||
if '_enabled' in params and not params['_enabled'] or \
|
||||
names is not None and instance_name not in names or \
|
||||
modules is not None and backend_name not in modules:
|
||||
continue
|
||||
backend = self.backends_loader.get_or_load_backend(backend_name)
|
||||
if backend is None:
|
||||
|
|
@ -96,8 +98,7 @@ class Weboob(object):
|
|||
'configuration file, but was not found. '
|
||||
'Hint: is it installed?' % backend_name)
|
||||
continue
|
||||
if caps is not None and not backend.has_caps(caps) or \
|
||||
names is not None and instance_name not in names:
|
||||
if caps is not None and not backend.has_caps(caps):
|
||||
continue
|
||||
backend_instance = backend.create_instance(self, instance_name, params, storage)
|
||||
self.backend_instances[instance_name] = loaded[instance_name] = backend_instance
|
||||
|
|
|
|||
|
|
@ -77,8 +77,6 @@ class BaseBackend(object):
|
|||
STORAGE = {}
|
||||
# Browser class
|
||||
BROWSER = None
|
||||
# Test class
|
||||
TEST = None
|
||||
# Supported objects to fill
|
||||
# The key is the class and the value the method to call to fill
|
||||
# Method prototype: method(object, fields)
|
||||
|
|
@ -194,11 +192,6 @@ class BaseBackend(object):
|
|||
return True
|
||||
return False
|
||||
|
||||
def get_test(self):
|
||||
if not self.TEST:
|
||||
return None
|
||||
return self.TEST(self)
|
||||
|
||||
def fillobj(self, obj, fields):
|
||||
missing_fields = []
|
||||
for field in fields:
|
||||
|
|
|
|||
22
scripts/weboob-tests → weboob/tools/test.py
Executable file → Normal file
22
scripts/weboob-tests → weboob/tools/test.py
Executable file → Normal file
|
|
@ -1,6 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
|
||||
|
||||
# Copyright(C) 2010 Romain Bignon
|
||||
#
|
||||
|
|
@ -17,9 +15,21 @@
|
|||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
from weboob.applications.weboobtests import WeboobTests
|
||||
from unittest import TestCase
|
||||
from weboob.core import Weboob
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
WeboobTests.run()
|
||||
__all__ = ['TestCase', 'BackendTest']
|
||||
|
||||
|
||||
class BackendTest(TestCase):
|
||||
BACKEND = None
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
TestCase.__init__(self, *args, **kwargs)
|
||||
|
||||
self.weboob = Weboob()
|
||||
if not self.weboob.load_configured_backends(modules=[self.BACKEND]):
|
||||
return None
|
||||
|
||||
self.backend = self.weboob.backend_instances.values()[0]
|
||||
Loading…
Add table
Add a link
Reference in a new issue