2018-08-03 11:57:51 +00:00
|
|
|
import pytest
|
|
|
|
import os
|
|
|
|
from pathlib import Path
|
|
|
|
import sys
|
|
|
|
|
|
|
|
BASE_DIR = Path(__file__).parent.parent
|
|
|
|
PKG_DIR = BASE_DIR / 'packages'
|
|
|
|
|
|
|
|
# TODO: remove once we have a proper Python package for common functions
|
|
|
|
sys.path.append(str(BASE_DIR / 'tools'))
|
|
|
|
import common # noqa
|
|
|
|
|
|
|
|
|
|
|
|
def registered_packages():
|
2018-08-03 12:43:40 +00:00
|
|
|
"""Returns a list of registred package names"""
|
2018-08-03 11:57:51 +00:00
|
|
|
packages = [name for name in os.listdir(PKG_DIR)
|
|
|
|
if (PKG_DIR / name).is_dir()]
|
|
|
|
return packages
|
|
|
|
|
|
|
|
|
2018-08-03 12:43:40 +00:00
|
|
|
def registered_packages_meta():
|
|
|
|
"""Returns a dictionary with the contents of `meta.yaml`
|
|
|
|
for each registed package
|
|
|
|
"""
|
|
|
|
packages = registered_packages
|
|
|
|
return {name: common.parse_package(PKG_DIR / name / 'meta.yaml')
|
|
|
|
for name in packages}
|
|
|
|
|
|
|
|
|
2018-08-16 09:34:42 +00:00
|
|
|
UNSUPPORTED_PACKAGES = {'ChromeWrapper': ['pandas'],
|
|
|
|
'FirefoxWrapper': []}
|
|
|
|
|
|
|
|
|
2018-08-03 11:57:51 +00:00
|
|
|
@pytest.mark.parametrize('name', registered_packages())
|
2018-08-20 17:02:12 +00:00
|
|
|
def test_import(name, selenium_standalone):
|
2018-08-03 11:57:51 +00:00
|
|
|
# check that we can parse the meta.yaml
|
|
|
|
meta = common.parse_package(PKG_DIR / name / 'meta.yaml')
|
|
|
|
|
2018-08-20 17:02:12 +00:00
|
|
|
if name in UNSUPPORTED_PACKAGES[selenium_standalone.__class__.__name__]:
|
2018-08-16 09:34:42 +00:00
|
|
|
pytest.xfail(
|
2018-08-20 17:02:12 +00:00
|
|
|
'{} fails to load and is not supported on {}.'
|
|
|
|
.format(name,
|
|
|
|
selenium_standalone.__class__.__name__
|
|
|
|
.replace('Wrapper', '')))
|
2018-08-16 09:34:42 +00:00
|
|
|
|
2018-08-03 12:43:40 +00:00
|
|
|
for import_name in meta.get('test', {}).get('imports', []):
|
2018-08-20 17:02:12 +00:00
|
|
|
selenium_standalone.load_package(name)
|
|
|
|
selenium_standalone.run('import %s' % import_name)
|