Skip to content

Commit

Permalink
Make tests compatible with python 3.9
Browse files Browse the repository at this point in the history
[noissue]
  • Loading branch information
mdellweg committed May 13, 2024
1 parent 1d8a83c commit 4b2a6de
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 9 deletions.
5 changes: 4 additions & 1 deletion pulp_ansible/app/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,10 @@ def is_valid(self, raise_exception=False):
See Validating Models:
https://docs.pulpproject.org/pulpcore/plugins/plugin-writer/concepts/index.html
"""
write_fields = set(CollectionVersionUploadSerializer.Meta.fields) - {"pulp_created"}
write_fields = set(CollectionVersionUploadSerializer.Meta.fields) - {
"pulp_created",
"pulp_last_updated",
}
if hasattr(self, "initial_data"):
if any((x in self.initial_data for x in self.Meta.read_fields)):
# Pop shared fields: artifact & repository
Expand Down
2 changes: 1 addition & 1 deletion pulp_ansible/app/tasks/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ async def declarative_content_from_git_repo(remote, url, git_ref=None, metadata_
relative_path=collection_version.relative_path,
)
except ValidationError as e:
if e.args[0]["non_field_errors"][0].code == "unique":
if "unique" in str(e):
namespace = metadata["metadata"]["namespace"]
name = metadata["metadata"]["name"]
version = metadata["metadata"]["version"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ def test_collection_version(collection_artifact, pulp_client, collection_detail)
# # 'tags': ['collectiontest']},


@pytest.mark.skip("Blocked by open ticket: https://github.com/pulp/pulp_ansible/issues/698")
def test_collection_download(collection_artifact, pulp_client, collection_detail):
"""Test collection download URL.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,7 @@ def test_crud_distribution(
monitor_task(ansible_distro_api_client.delete(distribution.pulp_href).task)
with pytest.raises(ApiException) as exc_info:
ansible_distro_api_client.delete(distribution.pulp_href)
assert "Not found." in exc_info.value.body
assert (
"Not found." in exc_info.value.body
or "No AnsibleDistribution matches the given query." in exc_info.value.body
)
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_upload_collection(
)

collection_meta = ansible_dir / "pulp" / collection_name / "meta"
collection_meta.mkdir()
collection_meta.mkdir(exist_ok=True)
runtime_yml = collection_meta / "runtime.yml"
runtime_yml.write_text('requires_ansible: ">=2.9"\n')

Expand Down
1 change: 1 addition & 0 deletions pulp_ansible/tests/unit/migrations/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def migrate(django_db_serialized_rollback):
executor = MigrationExecutor(connection)

def _migrate(target):
connection.cursor().execute("SET CONSTRAINTS ALL IMMEDIATE;")
state = executor.migrate(target)
executor.loader.build_graph()
return state.apps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ def test_cross_repo_search_migration(migrate):
AnsibleRepository = apps.get_model("ansible", "AnsibleRepository")
AnsibleDistribution = apps.get_model("ansible", "AnsibleDistribution")

# make a repository
# Make a Repository
repository = AnsibleRepository.objects.create(pulp_type="ansible", name="foobar")
repository.versions.create(number=0)

# make a distro
distro = AnsibleDistribution.objects.create(
# Make a Distribution
AnsibleDistribution.objects.create(
pulp_type="ansible", name="foobar", base_path="foobar", repository=repository
)

# Migrate the data
migrate([("ansible", "0051_cvindex_build")])
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ async_lru>=1.0,<2.1
galaxy_importer>=0.4.5,<0.5
GitPython>=3.1.24,<3.2
jsonschema>=4.9,<4.23
Pillow>=7.0,<10.4
Pillow>=10.3,<10.4
pulpcore>=3.49.0,<3.55
PyYAML>=5.4.1,<7.0
semantic_version>=2.9,<2.11

0 comments on commit 4b2a6de

Please sign in to comment.