Skip to content
This repository has been archived by the owner on May 24, 2023. It is now read-only.

Commit

Permalink
Tests: getting latests release
Browse files Browse the repository at this point in the history
* OSBS-6688

Signed-off-by: Martin Bašti <mbasti@redhat.com>
  • Loading branch information
MartinBasti committed Feb 20, 2019
1 parent 433f8cc commit 0df0344
Showing 1 changed file with 40 additions and 3 deletions.
43 changes: 40 additions & 3 deletions tests/test_quay.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
# see the LICENSE file for license
#

from flexmock import flexmock
import operatorcourier.api
import requests_mock
import pytest

from omps.errors import OMPSOrganizationNotFound, QuayLoginError
from omps.errors import (
OMPSOrganizationNotFound,
QuayPackageNotFound,
QuayLoginError
)
from omps.quay import QuayOrganizationManager, QuayOrganization, ReleaseVersion
from omps.settings import TestConfig, Config

Expand Down Expand Up @@ -118,3 +121,37 @@ def test_push_operator_manifest(self, mocked_op_courier_push):

qo = QuayOrganization(org, token)
qo.push_operator_manifest(repo, version, source_dir)

def test_get_latest_release_version(self):
"""Test getting the latest release version"""
org = "test_org"
repo = "test_repo"

with requests_mock.Mocker() as m:
m.get(
'/cnr/api/v1/packages/{}/{}'.format(org, repo),
json=[
{'release': "1.0.0"},
{'release': "1.2.0"},
{'release': "1.0.1"},
]
)

qo = QuayOrganization(org, "token")
latest = qo.get_latest_release_version(repo)
assert str(latest) == "1.2.0"

def test_get_latest_release_version_not_found(self):
"""Test if proper exception is raised when no package is not found"""
org = "test_org"
repo = "test_repo"

with requests_mock.Mocker() as m:
m.get(
'/cnr/api/v1/packages/{}/{}'.format(org, repo),
status_code=404,
)

qo = QuayOrganization(org, "token")
with pytest.raises(QuayPackageNotFound):
qo.get_latest_release_version(repo)

0 comments on commit 0df0344

Please sign in to comment.