Files
galaxy/test/integration/test_model_store_scripts.py
T
Nicola Soranzo c35d8f2a06 Replace `unittest.TestCase` with pytest-based partial re-implementation
Also:
- Rename `FooBarTestCase` test classes as `TestFooBar`. These were collected
  by pytest only because they were `unittest.TestCase` derived, but normally
  pytest collects only test classes whose name starts with `Test`, see
  https://docs.pytest.org/en/7.1.x/reference/reference.html#confval-python_classes
2022-09-27 03:34:58 +01:00

41 lines
1.6 KiB
Python

import json
import os
from galaxy.model.store.load_objects import main
from galaxy.model.unittest_utils.store_fixtures import (
history_model_store_dict,
one_hda_model_store_dict,
TEST_HISTORY_NAME,
)
from galaxy_test.base.populators import DatasetPopulator
from galaxy_test.driver.integration_util import IntegrationTestCase
class TestModelStoreScriptsIntegration(IntegrationTestCase):
# TODO: test build_objects also...
dataset_populator: DatasetPopulator
def setUp(self):
super().setUp()
self.dataset_populator = DatasetPopulator(self.galaxy_interactor)
self.json_store_path = os.path.join(self._tempdir, "store.json")
def test_import_contents_from_json(self):
self._write_store_json(one_hda_model_store_dict())
history_id = self.dataset_populator.new_history()
script_args = ["-t", history_id, "-u", self.url, "-k", self.galaxy_interactor.api_key, self.json_store_path]
main(script_args)
def test_import_history_from_json(self):
self._write_store_json(history_model_store_dict())
script_args = ["-u", self.url, "-k", self.galaxy_interactor.api_key, self.json_store_path]
history_names = [h["name"] for h in self.dataset_populator.get_histories()]
assert TEST_HISTORY_NAME not in history_names
main(script_args)
history_names = [h["name"] for h in self.dataset_populator.get_histories()]
assert TEST_HISTORY_NAME in history_names
def _write_store_json(self, as_dict) -> None:
with open(self.json_store_path, "w") as f:
json.dump(as_dict, f)