Skip to content

Commit

Permalink
Fix type annotation of test_0000_basic_repository_features.py
Browse files Browse the repository at this point in the history
  • Loading branch information
nsoranzo committed Oct 23, 2023
1 parent 2f9b93d commit d279027
Showing 1 changed file with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import logging

from ..base import common
from ..base.api import skip_if_api_v2
from ..base.twilltestcase import (
common,
ShedTwillTestCase,
)
from ..base.twilltestcase import ShedTwillTestCase

repository_name = "filtering_0000"
repository_description = "Galaxy's filtering tool for test 0000"
Expand Down Expand Up @@ -44,6 +42,7 @@ def test_0015_create_repository(self):
"""Create the filtering repository"""
self.login(email=common.test_user_1_email, username=common.test_user_1_name)
category = self.populator.get_category_with_name("Test 0000 Basic Repository Features 1")
assert category
strings_displayed = self.expect_repo_created_strings(repository_name)
self.get_or_create_repository(
name=repository_name,
Expand All @@ -57,6 +56,7 @@ def test_0015_create_repository(self):
def test_0020_edit_repository(self):
"""Edit the repository name, description, and long description"""
repository = self._get_repository_by_name_and_owner(repository_name, common.test_user_1_name)
assert repository
new_name = "renamed_filtering"
new_description = "Edited filtering tool"
new_long_description = "Edited long description"
Expand All @@ -67,6 +67,7 @@ def test_0020_edit_repository(self):
def test_0025_change_repository_category(self):
"""Change the categories associated with the filtering repository"""
repository = self._get_repository_by_name_and_owner(repository_name, common.test_user_1_name)
assert repository
self.edit_repository_categories(
repository,
categories_to_add=["Test 0000 Basic Repository Features 2"],
Expand All @@ -77,19 +78,22 @@ def test_0025_change_repository_category(self):
def test_0030_grant_write_access(self):
"""Grant write access to another user"""
repository = self._get_repository_by_name_and_owner(repository_name, common.test_user_1_name)
assert repository
self.grant_write_access(repository, usernames=[common.test_user_2_name])
self.revoke_write_access(repository, common.test_user_2_name)

def test_0035_upload_filtering_1_1_0(self):
"""Upload filtering_1.1.0.tar to the repository"""
repository = self._get_repository_by_name_and_owner(repository_name, common.test_user_1_name)
assert repository
self.commit_tar_to_repository(
repository, "filtering/filtering_1.1.0.tar", commit_message="Uploaded filtering 1.1.0"
)

def test_0040_verify_repository(self):
"""Display basic repository pages"""
repository = self._get_repository_by_name_and_owner(repository_name, common.test_user_1_name)
assert repository
latest_changeset_revision = self.get_repository_tip(repository)
self.check_for_valid_tools(repository, strings_displayed=["Filter1"])
self.check_count_of_metadata_revisions_associated_with_repository(repository, metadata_count=1)
Expand Down Expand Up @@ -129,6 +133,7 @@ def test_0040_verify_repository(self):
def test_0045_alter_repository_states(self):
"""Test toggling the malicious and deprecated repository flags."""
repository = self._get_repository_by_name_and_owner(repository_name, common.test_user_1_name)
assert repository
self.login(email=common.admin_email, username=common.admin_username)
self.set_repository_malicious(
repository, set_malicious=True, strings_displayed=["The repository tip has been defined as malicious."]
Expand Down Expand Up @@ -172,13 +177,15 @@ def test_0050_display_repository_tip_file(self):
def test_0055_upload_filtering_txt_file(self):
"""Upload filtering.txt file associated with tool version 1.1.0."""
repository = self._get_repository_by_name_and_owner(repository_name, common.test_user_1_name)
assert repository
self.add_file_to_repository(repository, "filtering/filtering_0000.txt")
expected = self._escape_page_content_if_needed("Readme file for filtering 1.1.0")
self.display_manage_repository_page(repository, strings_displayed=[expected])

def test_0060_upload_filtering_test_data(self):
"""Upload filtering test data."""
repository = self._get_repository_by_name_and_owner(repository_name, common.test_user_1_name)
assert repository
self.add_tar_to_repository(repository, "filtering/filtering_test_data.tar")
if self._browser.is_twill:
# probably not porting this functionality - just test
Expand All @@ -195,11 +202,13 @@ def test_0060_upload_filtering_test_data(self):
def test_0065_upload_filtering_2_2_0(self):
"""Upload filtering version 2.2.0"""
repository = self._get_repository_by_name_and_owner(repository_name, common.test_user_1_name)
assert repository
self.add_tar_to_repository(repository, "filtering/filtering_2.2.0.tar")

def test_0070_verify_filtering_repository(self):
"""Verify the new tool versions and repository metadata."""
repository = self._get_repository_by_name_and_owner(repository_name, common.test_user_1_name)
assert repository
tip = self.get_repository_tip(repository)
self.check_for_valid_tools(repository)
if self.is_v2:
Expand Down Expand Up @@ -228,6 +237,7 @@ def test_0070_verify_filtering_repository(self):
def test_0075_upload_readme_txt_file(self):
"""Upload readme.txt file associated with tool version 2.2.0."""
repository = self._get_repository_by_name_and_owner(repository_name, common.test_user_1_name)
assert repository
self.add_file_to_repository(repository, "readme.txt")
content = self._escape_page_content_if_needed("This is a readme file.")
self.display_manage_repository_page(repository, strings_displayed=[content])
Expand All @@ -244,6 +254,7 @@ def test_0075_upload_readme_txt_file(self):
def test_0080_delete_readme_txt_file(self):
"""Delete the readme.txt file."""
repository = self._get_repository_by_name_and_owner(repository_name, common.test_user_1_name)
assert repository
self.delete_files_from_repository(repository, filenames=["readme.txt"])
self.check_count_of_metadata_revisions_associated_with_repository(repository, metadata_count=2)
readme_content = self._escape_page_content_if_needed("Readme file for filtering 1.1.0")
Expand All @@ -253,6 +264,7 @@ def test_0080_delete_readme_txt_file(self):
def test_0085_search_for_valid_filter_tool(self):
"""Search for the filtering tool by tool ID, name, and version."""
repository = self._get_repository_by_name_and_owner(repository_name, common.test_user_1_name)
assert repository
tip_changeset = self.get_repository_tip(repository)
search_fields = dict(tool_id="Filter1", tool_name="filter", tool_version="2.2.0")
self.search_for_valid_tools(
Expand All @@ -262,11 +274,13 @@ def test_0085_search_for_valid_filter_tool(self):
def test_0090_verify_repository_metadata(self):
"""Verify that resetting the metadata does not change it."""
repository = self._get_repository_by_name_and_owner(repository_name, common.test_user_1_name)
assert repository
self.verify_unchanged_repository_metadata(repository)

def test_0095_verify_reserved_repository_name_handling(self):
"""Check that reserved repository names are handled correctly."""
category = self.populator.get_category_with_name("Test 0000 Basic Repository Features 1")
assert category
error_message = (
"The term 'repos' is a reserved word in the Tool Shed, so it cannot be used as a repository name."
)
Expand Down Expand Up @@ -301,9 +315,10 @@ def test_0105_contact_repository_owner(self):
def test_0110_delete_filtering_repository(self):
"""Delete the filtering_0000 repository and verify that it no longer has any downloadable revisions."""
repository = self._get_repository_by_name_and_owner(repository_name, common.test_user_1_name)
assert repository
self.login(email=common.admin_email, username=common.admin_username)
self.delete_repository(repository)
metadata = self._populator.get_metadata(repository, downloadable_only=False)
metadata = self.populator.get_metadata(repository, downloadable_only=False)
for _, value in metadata.__root__.items():
assert not value.downloadable
# Explicitly reload all metadata revisions from the database, to ensure that we have the current status of the downloadable flag.
Expand All @@ -316,6 +331,7 @@ def test_0110_delete_filtering_repository(self):
def test_0115_undelete_filtering_repository(self):
"""Undelete the filtering_0000 repository and verify that it now has two downloadable revisions."""
repository = self._get_repository_by_name_and_owner(repository_name, common.test_user_1_name)
assert repository
self.login(email=common.admin_email, username=common.admin_username)
self.undelete_repository(repository)
# Explicitly reload all metadata revisions from the database, to ensure that we have the current status of the downloadable flag.
Expand All @@ -333,13 +349,15 @@ def test_0120_enable_email_notifications(self):
self.login(email=common.test_user_2_email, username=common.test_user_2_name)
# Get the repository, so we can pass the encoded repository id and browse_repositories method to the set_email_alerts method.
repository = self._get_repository_by_name_and_owner(repository_name, common.test_user_1_name)
assert repository
strings_displayed = ["Total alerts added: 1, total alerts removed: 0"]
self.enable_email_alerts(repository, strings_displayed=strings_displayed)

def test_0125_upload_new_readme_file(self):
"""Upload a new readme file to the filtering_0000 repository and verify that there is no error."""
self.login(email=common.test_user_1_email, username=common.test_user_1_name)
repository = self._get_repository_by_name_and_owner(repository_name, common.test_user_1_name)
assert repository
# Upload readme.txt to the filtering_0000 repository and verify that it is now displayed.
self.add_file_to_repository(repository, "filtering/readme.txt")
content = self._escape_page_content_if_needed("These characters should not")
Expand All @@ -348,6 +366,7 @@ def test_0125_upload_new_readme_file(self):
def test_0130_verify_handling_of_invalid_characters(self):
"""Load the above changeset in the change log and confirm that there is no server error displayed."""
repository = self._get_repository_by_name_and_owner(repository_name, common.test_user_1_name)
assert repository
changeset_revision = self.get_repository_tip(repository)
repository_id = repository.id
changelog_tuples = self.get_repository_changelog_tuples(repository)
Expand All @@ -374,13 +393,16 @@ def test_0130_verify_handling_of_invalid_characters(self):
def test_0135_api_get_repositories_in_category(self):
"""Load the api endpoint for repositories in a category."""
categories = []
categories.append(self.populator.get_category_with_name("Test 0000 Basic Repository Features 1"))
categories.append(self.populator.get_category_with_name("Test 0000 Basic Repository Features 2"))
for name in ("Test 0000 Basic Repository Features 1", "Test 0000 Basic Repository Features 2"):
category = self.populator.get_category_with_name(name)
assert category
categories.append(category)
self.get_repositories_category_api(categories)

def test_0140_view_invalid_changeset(self):
"""View repository using an invalid changeset"""
repository = self._get_repository_by_name_and_owner(repository_name, common.test_user_1_name)
assert repository
encoded_repository_id = repository.id
assert encoded_repository_id
strings_displayed = ["Invalid+changeset+revision"]
Expand Down

0 comments on commit d279027

Please sign in to comment.