Skip to content

Commit

Permalink
add CollectionData.from_artifactory_path test
Browse files Browse the repository at this point in the history
  • Loading branch information
briantist committed Oct 8, 2023
1 parent bac1e33 commit 1e124e8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ dependencies = [
tests = [
"pytest>=7.1,<8",
"pytest-cov",
"pytest-mock",
"coverage",
# "pytest-docker-compose",
# "ansible-runner",
Expand Down
21 changes: 20 additions & 1 deletion tests/unit/models/test_collectiondata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@

import pytest

from datetime import datetime, timedelta, timezone
import semver
from datetime import datetime, timedelta, timezone
from pytest_mock import MockFixture

from artifactory import ArtifactoryPath

from galactory.models import CollectionData

Expand Down Expand Up @@ -139,3 +142,19 @@ def test_collectiondata_compare_versioninfo(
assert (col < ver) == (col.semver < ver)
else:
assert (col < ver) == (col.is_prerelease)

def test_from_artifactory_repository(mocker: MockFixture, repository: ArtifactoryPath):
spy = mocker.spy(CollectionData, '__init__')

col = None
for item in repository.iterdir():
if item.is_dir():
continue

Check warning on line 152 in tests/unit/models/test_collectiondata.py

View check run for this annotation

Codecov / codecov/patch

tests/unit/models/test_collectiondata.py#L152

Added line #L152 was not covered by tests
if item.name.endswith('.tar.gz'):
props = item.properties
stat = item.stat()
col = CollectionData.from_artifactory_path(path=item, properties=props, stat=stat)
spy.assert_called_once()
spy.reset_mock()

assert col is not None, "Error, no collections found."

0 comments on commit 1e124e8

Please sign in to comment.