def invoked(self, ns): QML_SHELL_PATH = os.path.join(get_plainbox_dir(), 'qml_shell', 'qml_shell.qml') QML_MODULES_PATH = os.path.join(get_plainbox_dir(), 'data', 'plainbox-qml-modules') test_result_object_prefix = "qml: __test_result_object:" test_res = None p = subprocess.Popen([ 'qmlscene', '-I', QML_MODULES_PATH, '--job', os.path.abspath(ns.QML_FILE), QML_SHELL_PATH ], stderr=subprocess.PIPE) for line in iter(p.stderr.readline, ''): line = line.decode(sys.stderr.encoding) if not line: break if line.startswith(test_result_object_prefix): obj_json = line[len(test_result_object_prefix):] test_res = json.loads(obj_json) else: print(line) if not test_res: return _("Job did not return any result") print(_("Test outcome: {}").format(test_res['outcome'])) return test_res['outcome'] != "pass"
def load_unit_tests(): """ Load all unit tests and return a TestSuite object """ # Discover all unit tests. By simple convention those are kept in # python modules that start with the word 'test_' . return defaultTestLoader.discover(get_plainbox_dir())
def load_unit_tests(): """ Load all unit tests and return a TestSuite object """ # Discover all unit tests. By simple convention those are kept in # python modules that start with the word 'test_' . start_dir = os.path.normpath(os.path.join(get_plainbox_dir(), '..')) return defaultTestLoader.discover(start_dir)
def load_integration_tests(): """ Load all integration tests and return a TestSuite object """ # Discover all integration tests. By simple convention those are kept in # python modules that start with the word 'integration_' . return defaultTestLoader.discover(get_plainbox_dir(), pattern="integration_*.py")
def _get_plainbox_qml_modules_path(self): try: from plainbox.impl import get_plainbox_dir return os.path.join(get_plainbox_dir(), 'data', 'plainbox-qml-modules') except ImportError: return os.path.join(self._get_path_to_app_source(), 'lib', 'py', 'plainbox', 'data', 'plainbox-qml-modules')
def test_suite(): """ Test suite function used by setuptools test loader. Uses unittest test discovery system to get a list of test cases defined inside plainbox. See setup.py setup(test_suite=...) for a matching entry """ return defaultTestLoader.discover(get_plainbox_dir())
def load_integration_tests(): """ Load all integration tests and return a TestSuite object """ # Discover all integration tests. By simple convention those are kept in # python modules that start with the word 'integration_' . return defaultTestLoader.discover( get_plainbox_dir(), pattern="integration_*.py")
def _source_dir(self): """ Return the root directory of the checkbox source checkout This only works when plainbox is 'setup.py develop'ed and the checkbox submodule has been loaded. """ return os.path.normpath( os.path.join( get_plainbox_dir(), "..", "checkbox"))
def invoked(self, ns): # Use standard unittest runner, it has somewhat annoying way of # displaying test progress but is well-known and will do for now. runner = TextTestRunner(verbosity=ns.verbosity, failfast=ns.fail_fast) loader = TestLoader() # Discover all integration tests tests = loader.discover(get_plainbox_dir(), pattern="integration_*.py") result = runner.run(tests) # Forward the successfulness of the test suite as the exit code return 0 if result.wasSuccessful() else 1
def _source_dir(self): """ Return the root directory of the checkbox source checkout Historically plainbox used a git submodule with checkbox tree (converted to git). This ended with the merge of plainbox into the checkbox tree. Now it's the other way around and the checkbox tree can be located two directories "up" from the plainbox module. """ return os.path.normpath( os.path.join( get_plainbox_dir(), "..", ".."))
def _get_checkbox_dir(): """ Return the root directory of the checkbox source checkout Historically plainbox used a git submodule with checkbox tree (converted to git). This ended with the merge of plainbox into the checkbox tree. Now it's the other way around and the checkbox tree can be located two directories "up" from the plainbox module, in a checkbox-old directory. """ return os.path.normpath( os.path.join(get_plainbox_dir(), "..", "..", "checkbox-old"))
def get_categories_def(): """ Get a Provider1Definition for the provider that knows all the categories """ categories_def = Provider1Definition() categories_def.name = "com.canonical.plainbox:categories" categories_def.version = "1.0" categories_def.description = N_("Common test category definitions") categories_def.secure = False categories_def.gettext_domain = "plainbox-provider-categories" categories_def.location = os.path.join( get_plainbox_dir(), "impl/providers/categories") return categories_def
def get_stubbox_def(): """ Get a Provider1Definition for stubbox """ stubbox_def = Provider1Definition() stubbox_def.name = "com.canonical.plainbox:stubbox" stubbox_def.version = "1.0" stubbox_def.description = N_("StubBox (dummy data for development)") stubbox_def.secure = False stubbox_def.gettext_domain = "plainbox-provider-stubbox" stubbox_def.location = os.path.join( get_plainbox_dir(), "impl/providers/stubbox") return stubbox_def
def get_stubbox_def(): """ Get a Provider1Definition for stubbox """ stubbox_def = Provider1Definition() stubbox_def.name = "2013.com.canonical.plainbox:stubbox" stubbox_def.version = "1.0" stubbox_def.description = N_("StubBox (dummy data for development)") stubbox_def.secure = False stubbox_def.gettext_domain = "stubbox" stubbox_def.location = os.path.join( get_plainbox_dir(), "impl/providers/stubbox") return stubbox_def
def get_exporters_def(): """ Get a Provider1Definition for the provider that handles the exporters machinery. """ exporters_def = Provider1Definition() exporters_def.name = "com.canonical.plainbox:exporters" exporters_def.version = "1.0" exporters_def.description = N_("Exporters Provider") exporters_def.secure = False exporters_def.gettext_domain = "plainbox-provider-exporters" exporters_def.location = os.path.join( get_plainbox_dir(), "impl/providers/exporters") return exporters_def
def get_manifest_def(): """ Get a Provider1Definition for the provider that handles the manifest machinery. """ manifest_def = Provider1Definition() manifest_def.name = "com.canonical.plainbox:manifest" manifest_def.version = "1.0" manifest_def.description = N_("Hardware Manifest Provider") manifest_def.secure = False manifest_def.gettext_domain = "plainbox-provider-manifest" manifest_def.location = os.path.join( get_plainbox_dir(), "impl/providers/manifest") return manifest_def
def __init__(self): super(StubBoxProvider, self).__init__( os.path.join(get_plainbox_dir(), "impl/providers/stubbox"), "stubbox", "StubBox (dummy data for development)")