Phase 1 of migrating APPR-specific tables to tables with the Appr
prefix
Fixes https://jira.coreos.com/browse/QUAY-950
This commit is contained in:
parent
6622f27c93
commit
113bb96f29
28 changed files with 699 additions and 176 deletions
|
@ -3,7 +3,9 @@ from collections import defaultdict
|
|||
from datetime import datetime, timedelta
|
||||
|
||||
from auth.permissions import ReadRepositoryPermission
|
||||
from data import model, appr_model
|
||||
from data import model
|
||||
from data.appr_model import channel as channel_model, release as release_model
|
||||
from endpoints.appr.models_cnr import model as appr_model
|
||||
from endpoints.api.repository_models_interface import RepositoryDataInterface, RepositoryBaseElement, Repository, \
|
||||
ApplicationRepository, ImageRepositoryRepository, Tag, Channel, Release, Count
|
||||
|
||||
|
@ -143,8 +145,8 @@ class PreOCIModel(RepositoryDataInterface):
|
|||
False, False, False)
|
||||
|
||||
if base.kind_name == 'application':
|
||||
channels = appr_model.channel.get_repo_channels(repo)
|
||||
releases = appr_model.release.get_release_objs(repo)
|
||||
channels = channel_model.get_repo_channels(repo, appr_model.models_ref)
|
||||
releases = release_model.get_release_objs(repo, appr_model.models_ref)
|
||||
releases_channels_map = defaultdict(list)
|
||||
return ApplicationRepository(
|
||||
base, [_create_channel(channel, releases_channels_map) for channel in channels], [
|
||||
|
|
|
@ -2,7 +2,9 @@ import pytest
|
|||
|
||||
from mock import patch, ANY, MagicMock
|
||||
|
||||
from data import model
|
||||
from data import model, database
|
||||
from data.appr_model import release, channel, blob
|
||||
from endpoints.appr.models_cnr import model as appr_model
|
||||
from endpoints.api.test.shared import conduct_api_call
|
||||
from endpoints.api.repository import RepositoryTrust, Repository, RepositoryList
|
||||
from endpoints.test.shared import client_with_identity
|
||||
|
@ -117,3 +119,26 @@ def test_create_repository(repo_name, expected_status, client):
|
|||
if expected_status == 201:
|
||||
assert result['name'] == repo_name
|
||||
assert model.repository.get_repository('devtable', repo_name).name == repo_name
|
||||
|
||||
|
||||
def test_get_app_repo(client, initialized_db):
|
||||
with client_with_identity('devtable', client) as cl:
|
||||
devtable = model.user.get_user('devtable')
|
||||
repo = model.repository.create_repository('devtable', 'someappr', devtable,
|
||||
repo_kind='application')
|
||||
|
||||
models_ref = appr_model.models_ref
|
||||
blob.get_or_create_blob('sha256:somedigest', 0, 'application/vnd.cnr.blob.v0.tar+gzip',
|
||||
['local_us'], models_ref)
|
||||
|
||||
release.create_app_release(repo, 'test',
|
||||
dict(mediaType='application/vnd.cnr.package-manifest.helm.v0.json'),
|
||||
'sha256:somedigest', models_ref, False)
|
||||
|
||||
channel.create_or_update_channel(repo, 'somechannel', 'test', models_ref)
|
||||
|
||||
params = {'repository': 'devtable/someappr'}
|
||||
response = conduct_api_call(cl, Repository, 'GET', params).json
|
||||
assert response['kind'] == 'application'
|
||||
assert response['channels']
|
||||
assert response['releases']
|
||||
|
|
|
@ -2,6 +2,7 @@ import pytest
|
|||
|
||||
from playhouse.test_utils import assert_query_count
|
||||
|
||||
from data import model, database
|
||||
from endpoints.api.search import ConductRepositorySearch, ConductSearch
|
||||
from endpoints.api.test.shared import conduct_api_call
|
||||
from endpoints.test.shared import client_with_identity
|
||||
|
@ -14,6 +15,10 @@ from test.fixtures import *
|
|||
('repository'),
|
||||
])
|
||||
def test_repository_search(query, client):
|
||||
# Prime the caches.
|
||||
database.Repository.kind.get_id('image')
|
||||
database.Repository.kind.get_name(1)
|
||||
|
||||
with client_with_identity('devtable', client) as cl:
|
||||
params = {'query': query}
|
||||
with assert_query_count(7):
|
||||
|
|
Reference in a new issue