mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-16 15:45:04 +08:00
In API tests, replace no more working `uses_test_history` decorator (because the `history_id` method parameter is interpreted as a fixture) with a real class-level pytest fixture. As a consequence, replace use of `self.history_id` in API tests because it interferes with the class-level `history_id` fixture. Also: - Some type annotations
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
from typing import (
|
|
Iterator,
|
|
Optional,
|
|
)
|
|
from unittest import SkipTest
|
|
|
|
import pytest
|
|
|
|
from galaxy_test.base.api import (
|
|
UsesApiTestCaseMixin,
|
|
UsesCeleryTasks,
|
|
)
|
|
from galaxy_test.base.populators import DatasetPopulator
|
|
from galaxy_test.base.testcase import FunctionalTestCase
|
|
|
|
try:
|
|
from galaxy_test.driver.driver_util import GalaxyTestDriver
|
|
except ImportError:
|
|
# Galaxy libraries and galaxy test driver not available, just assume we're
|
|
# targetting a remote Galaxy.
|
|
GalaxyTestDriver = None # type: ignore[misc,assignment]
|
|
|
|
|
|
class ApiTestCase(FunctionalTestCase, UsesApiTestCaseMixin, UsesCeleryTasks):
|
|
galaxy_driver_class = GalaxyTestDriver
|
|
_test_driver: Optional[GalaxyTestDriver]
|
|
dataset_populator: Optional[DatasetPopulator]
|
|
|
|
def setUp(self):
|
|
super().setUp()
|
|
self._setup_interactor()
|
|
|
|
def driver_or_skip_test_if_remote(self) -> GalaxyTestDriver:
|
|
if self._test_driver is None:
|
|
raise SkipTest("This test does not work with remote Galaxy instances.")
|
|
return self._test_driver
|
|
|
|
@pytest.fixture
|
|
def history_id(self) -> Iterator[str]:
|
|
assert self.dataset_populator
|
|
with self.dataset_populator.test_history() as history_id:
|
|
yield history_id
|
|
|
|
|
|
__all__ = ("ApiTestCase",)
|