diff --git a/weboob/applications/weboobtests/__init__.py b/weboob/applications/weboobtests/__init__.py deleted file mode 100644 index 2833ddee..00000000 --- a/weboob/applications/weboobtests/__init__.py +++ /dev/null @@ -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 diff --git a/weboob/applications/weboobtests/weboobtests.py b/weboob/applications/weboobtests/weboobtests.py deleted file mode 100644 index 5e1af689..00000000 --- a/weboob/applications/weboobtests/weboobtests.py +++ /dev/null @@ -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) diff --git a/weboob/backends/dlfp/__init__.py b/weboob/backends/dlfp/__init__.py index ec6ed081..280ed21d 100644 --- a/weboob/backends/dlfp/__init__.py +++ b/weboob/backends/dlfp/__init__.py @@ -18,3 +18,5 @@ from .browser import DLFP from .backend import DLFPBackend + +__all__ = ['DLFP', 'DLFPBackend'] diff --git a/weboob/core/__init__.py b/weboob/core/__init__.py index 45f70083..40f458c9 100644 --- a/weboob/core/__init__.py +++ b/weboob/core/__init__.py @@ -17,3 +17,6 @@ from .bcall import CallErrors +from .ouiboube import Weboob + +__all__ = ['CallErrors', 'Weboob'] diff --git a/weboob/core/ouiboube.py b/weboob/core/ouiboube.py index c7ffaffd..1578e8e3 100644 --- a/weboob/core/ouiboube.py +++ b/weboob/core/ouiboube.py @@ -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 diff --git a/weboob/tools/backend.py b/weboob/tools/backend.py index 236db2bc..e8cab303 100644 --- a/weboob/tools/backend.py +++ b/weboob/tools/backend.py @@ -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: diff --git a/scripts/weboob-tests b/weboob/tools/test.py old mode 100755 new mode 100644 similarity index 62% rename from scripts/weboob-tests rename to weboob/tools/test.py index 3d698f0b..19f7e51e --- a/scripts/weboob-tests +++ b/weboob/tools/test.py @@ -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]