Skip to content

Commit

Permalink
Progress toward exercising less of the tool shed upload API.
Browse files Browse the repository at this point in the history
So we can kill it.
  • Loading branch information
jmchilton committed Sep 26, 2023
1 parent 7ba099a commit 8852f07
Show file tree
Hide file tree
Showing 94 changed files with 5,666 additions and 2,058 deletions.
1 change: 1 addition & 0 deletions .ci/flake8_ignorelist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ database
doc/build
eggs
lib/galaxy/web/proxy/js/node_modules
lib/tool_shed/test/test_data/repos
static/maps
static/scripts
test/functional/tools/cwl_tools/v1.?/
Expand Down
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
# W503 is line breaks before binary operators, which has been reversed in PEP 8.
# D** are docstring linting - which we mostly ignore except D302. (Hopefully we will solve more over time).
ignore = B008,E203,E402,E501,W503,D100,D101,D102,D103,D104,D105,D106,D107,D200,D201,D202,D204,D205,D206,D207,D208,D209,D210,D211,D300,D301,D400,D401,D402,D403,D412,D413
exclude = lib/tool_shed/test/test_data/repos
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ profile=black
reverse_relative=true
skip_gitignore=true
# Make isort run faster by skipping database
skip_glob=database/*
skip_glob=database/*,lib/tool_shed/test/test_data/repos/*
src_paths=lib
15 changes: 13 additions & 2 deletions lib/tool_shed/test/base/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ShedBaseTestCase(DrivenFunctionalTestCase):
@property
def populator(self) -> ToolShedPopulator:
if self._populator is None:
self._populator = ToolShedPopulator(self.admin_api_interactor, self.api_interactor)
self._populator = self._get_populator(self.api_interactor)
return self._populator

@property
Expand All @@ -50,7 +50,18 @@ def api_interactor(self) -> ShedApiInteractor:
password = "testpassword"
ensure_user_with_email(self.admin_api_interactor, email, password)
user_api_key = self._api_key(email, password)
return ShedApiInteractor(self.url, user_api_key)
return self._api_interactor(user_api_key)

def _api_interactor_by_credentials(self, email: str, password: str) -> ShedApiInteractor:
ensure_user_with_email(self.admin_api_interactor, email, password)
user_api_key = self._api_key(email, password)
return self._api_interactor(user_api_key)

def _api_interactor(self, api_key: str) -> ShedApiInteractor:
return ShedApiInteractor(self.url, api_key)

def _get_populator(self, user_api_interactor) -> ToolShedPopulator:
return ToolShedPopulator(self.admin_api_interactor, user_api_interactor)

def _api_key(self, email: str, password: str) -> str:
headers = baseauth_headers(email, password)
Expand Down
55 changes: 43 additions & 12 deletions lib/tool_shed/test/base/populators.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,52 @@ def __init__(self, admin_api_interactor: ShedApiInteractor, api_interactor: Shed
self._admin_api_interactor = admin_api_interactor
self._api_interactor = api_interactor

def setup_test_data_repo(self, test_data_path: str) -> Repository:
prefix = test_data_path.replace("_", "")
category_id = self.new_category(prefix=prefix).id
repository = self.new_repository(category_id, prefix=prefix)
repository_id = repository.id
def setup_bismark_repo(self, repository_id: HasRepositoryId, end: Optional[int] = None):
self.setup_test_data_repo_by_id("bismark", repository_id, assert_ok=False, end=end)

def setup_test_data_repo_by_id(
self,
test_data_path: str,
repository_id: Optional[HasRepositoryId] = None,
assert_ok=True,
start: int = 0,
end: Optional[int] = None,
) -> HasRepositoryId:
if repository_id is None:
prefix = test_data_path.replace("_", "")
category_id = self.new_category(prefix=prefix).id
repository = self.new_repository(category_id, prefix=prefix)
repository_id = repository.id

assert repository_id

for index, repo_tar in enumerate(repo_tars(test_data_path)):
if index < start:
continue

if end and index >= end:
break

commit_message = f"Updating {test_data_path} with index {index} with tar {repo_tar}"
response = self.upload_revision(
repository_id,
repo_tar,
commit_message=commit_message,
)
assert response.is_ok
response = self.upload_revision_raw(repository_id, repo_tar, commit_message)
if assert_ok:
api_asserts.assert_status_code_is_ok(response)
assert RepositoryUpdate(__root__=response.json()).is_ok
return repository_id

def setup_test_data_repo(
self,
test_data_path: str,
repository: Optional[Repository] = None,
assert_ok=True,
start: int = 0,
end: Optional[int] = None,
) -> Repository:
if repository is None:
prefix = test_data_path.replace("_", "")
category_id = self.new_category(prefix=prefix).id
repository = self.new_repository(category_id, prefix=prefix)
self.setup_test_data_repo_by_id(test_data_path, repository, assert_ok=assert_ok, start=start, end=end)
return repository

def setup_column_maker_repo(self, prefix=DEFAULT_PREFIX) -> Repository:
Expand Down Expand Up @@ -152,7 +183,7 @@ def upload_revision_raw(
def upload_revision(
self, repository: HasRepositoryId, path: Traversable, commit_message: str = DEFAULT_COMMIT_MESSAGE
):
response = self.upload_revision_raw(repository, path, commit_message)
response = self.upload_revision_raw(repository, path, commit_message=commit_message)
if response.status_code != 200:
response_json = None
err_msg = None
Expand Down
Loading

0 comments on commit 8852f07

Please sign in to comment.