40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
import pytest
|
|
|
|
from data import model
|
|
from data.registry_model.registry_pre_oci_model import PreOCIModel
|
|
from data.registry_model.datatypes import RepositoryReference
|
|
from test.fixtures import *
|
|
|
|
@pytest.fixture()
|
|
def pre_oci_model(initialized_db):
|
|
return PreOCIModel()
|
|
|
|
|
|
@pytest.mark.parametrize('names, expected', [
|
|
(['unknown'], None),
|
|
(['latest'], 'latest'),
|
|
(['latest', 'prod'], 'latest'),
|
|
(['foo', 'prod'], 'prod'),
|
|
])
|
|
def test_find_matching_tag(names, expected, pre_oci_model):
|
|
repo = model.repository.get_repository('devtable', 'simple')
|
|
repository_ref = RepositoryReference.for_repo_obj(repo)
|
|
found = pre_oci_model.find_matching_tag(repository_ref, names)
|
|
if expected is None:
|
|
assert found is None
|
|
else:
|
|
assert found.name == expected
|
|
|
|
|
|
@pytest.mark.parametrize('repo_namespace, repo_name, expected', [
|
|
('devtable', 'simple', 'latest'),
|
|
('buynlarge', 'orgrepo', 'latest'),
|
|
])
|
|
def test_get_most_recent_tag(repo_namespace, repo_name, expected, pre_oci_model):
|
|
repo = model.repository.get_repository(repo_namespace, repo_name)
|
|
repository_ref = RepositoryReference.for_repo_obj(repo)
|
|
found = pre_oci_model.get_most_recent_tag(repository_ref)
|
|
if expected is None:
|
|
assert found is None
|
|
else:
|
|
assert found.name == expected
|