Move shared test setup to lib/galaxy_test/driver/integration_setup.py

This commit is contained in:
mvdbeek
2021-05-03 16:18:21 +02:00
parent 35b200cd5a
commit 2edb301654
4 changed files with 72 additions and 66 deletions
@@ -0,0 +1,68 @@
"""
Test classes that should be shared between test scenarios.
"""
import os
import shutil
from tempfile import mkdtemp
REQUIRED_ROLE = "user@bx.psu.edu"
REQUIRED_GROUP = "fs_test_group"
def get_posix_file_source_config(root_dir: str, roles: str, groups: str) -> str:
return f"""
- type: posix
id: posix_test
label: Posix
doc: Files from local path
root: {root_dir}
writable: true
requires_roles: {roles}
requires_groups: {groups}
"""
def create_file_source_config_file_on(temp_dir, root_dir):
file_contents = get_posix_file_source_config(root_dir, REQUIRED_ROLE, REQUIRED_GROUP)
file_path = os.path.join(temp_dir, "file_sources_conf_posix.yml")
with open(file_path, "w") as f:
f.write(file_contents)
return file_path
class PosixFileSourceSetup:
@classmethod
def handle_galaxy_config_kwds(cls, config):
temp_dir = os.path.realpath(mkdtemp())
cls._test_driver.temp_directories.append(temp_dir)
cls.root_dir = os.path.join(temp_dir, "root")
file_sources_config_file = create_file_source_config_file_on(temp_dir, cls.root_dir)
config["file_sources_config_file"] = file_sources_config_file
# Disable all stock plugins
config["ftp_upload_dir"] = None
config["library_import_dir"] = None
config["user_library_import_dir"] = None
def _write_file_fixtures(self):
root = self.root_dir
if os.path.exists(root):
shutil.rmtree(root)
os.mkdir(root)
with open(os.path.join(root, "a"), "w") as f:
f.write("a\n")
subdir1 = os.path.join(root, "subdir1")
os.mkdir(subdir1)
with open(os.path.join(subdir1, "b"), "w") as f:
f.write("b\n")
return root
def setUp(self):
super().setUp()
self._write_file_fixtures()
View File
+1 -63
View File
@@ -3,77 +3,15 @@
# Apache Docker host (shown next) doesn't work because displayname not set in response.
# docker run -v `pwd`/test/integration/webdav:/var/lib/dav -e AUTH_TYPE=Basic -e USERNAME=alice -e PASSWORD=secret1234 -e LOCATION=/ -p 7083:80 bytemark/webdav
import os
import shutil
from tempfile import mkdtemp
from galaxy_test.base import api_asserts
from galaxy_test.base.populators import DatasetPopulator
from galaxy_test.driver import integration_util
from galaxy_test.driver.integration_setup import PosixFileSourceSetup
REQUIRED_ROLE = "user@bx.psu.edu"
REQUIRED_GROUP = "fs_test_group"
def get_posix_file_source_config(root_dir: str, roles: str, groups: str) -> str:
return f"""
- type: posix
id: posix_test
label: Posix
doc: Files from local path
root: {root_dir}
writable: true
requires_roles: {roles}
requires_groups: {groups}
"""
def create_file_source_config_file_on(temp_dir, root_dir):
file_contents = get_posix_file_source_config(root_dir, REQUIRED_ROLE, REQUIRED_GROUP)
file_path = os.path.join(temp_dir, "file_sources_conf_posix.yml")
with open(file_path, "w") as f:
f.write(file_contents)
return file_path
class PosixFileSourceSetup:
@classmethod
def handle_galaxy_config_kwds(cls, config):
temp_dir = os.path.realpath(mkdtemp())
cls._test_driver.temp_directories.append(temp_dir)
cls.root_dir = os.path.join(temp_dir, "root")
file_sources_config_file = create_file_source_config_file_on(temp_dir, cls.root_dir)
config["file_sources_config_file"] = file_sources_config_file
# Disable all stock plugins
config["ftp_upload_dir"] = None
config["library_import_dir"] = None
config["user_library_import_dir"] = None
def _write_file_fixtures(self):
root = self.root_dir
if os.path.exists(root):
shutil.rmtree(root)
os.mkdir(root)
with open(os.path.join(root, "a"), "w") as f:
f.write("a\n")
subdir1 = os.path.join(root, "subdir1")
os.mkdir(subdir1)
with open(os.path.join(subdir1, "b"), "w") as f:
f.write("b\n")
return root
def setUp(self):
super().setUp()
self._write_file_fixtures()
class PosixFileSourceIntegrationTestCase(PosixFileSourceSetup, integration_util.IntegrationTestCase):
def setUp(self):
@@ -1,10 +1,10 @@
from galaxy_test.driver.integration_setup import (
PosixFileSourceSetup,
)
from .framework import (
selenium_test,
SeleniumIntegrationTestCase,
)
from ..integration.test_remote_files_posix import (
PosixFileSourceSetup,
)
class PosixFileSourceSeleniumIntegrationTestCase(PosixFileSourceSetup, SeleniumIntegrationTestCase):