88from sqlalchemy .exc import DisconnectionError
99
1010from iib .web .api_v1 import _get_unique_bundles
11- from iib .web .models import Image , RequestAdd , RequestRm , RequestCreateEmptyIndex
11+ from iib .web .models import (
12+ Image ,
13+ RequestAdd ,
14+ RequestRm ,
15+ RequestCreateEmptyIndex ,
16+ RequestFbcOperations ,
17+ )
1218
1319
1420def test_get_build (app , auth_env , client , db ):
@@ -96,7 +102,8 @@ def test_get_build(app, auth_env, client, db):
96102def test_get_builds (app , auth_env , client , db ):
97103 total_create_requests = 5
98104 total_add_requests = 50
99- total_requests = total_create_requests + total_add_requests
105+ total_fbc_operations_requests = 5
106+ total_requests = total_create_requests + total_add_requests + total_fbc_operations_requests
100107 # flask_login.current_user is used in RequestAdd.from_json, which requires a request context
101108 with app .test_request_context (environ_base = auth_env ):
102109 for i in range (total_add_requests ):
@@ -116,6 +123,14 @@ def test_get_builds(app, auth_env, client, db):
116123 }
117124 request2 = RequestCreateEmptyIndex .from_json (data )
118125 db .session .add (request2 )
126+ for i in range (total_fbc_operations_requests ):
127+ data = {
128+ 'binary_image' : 'quay.io/namespace/binary_image:latest' ,
129+ 'from_index' : f'quay.io/namespace/repo:{ i } ' ,
130+ 'fbc_fragment' : f'quay.io/namespace/fbcfragment:{ i } ' ,
131+ }
132+ request2 = RequestFbcOperations .from_json (data )
133+ db .session .add (request2 )
119134 db .session .commit ()
120135
121136 rv_json = client .get ('/api/v1/builds?page=2' ).json
@@ -151,6 +166,10 @@ def test_get_builds(app, auth_env, client, db):
151166 assert rv_json ['meta' ]['total' ] == total_add_requests
152167 assert rv_json ['items' ][0 ]['request_type' ] == 'add'
153168
169+ rv_json = client .get ('/api/v1/builds?request_type=fbc-operations' ).json
170+ assert rv_json ['meta' ]['total' ] == total_fbc_operations_requests
171+ assert rv_json ['items' ][0 ]['request_type' ] == 'fbc-operations'
172+
154173 rv_json = client .get ('/api/v1/builds?request_type=create-empty-index' ).json
155174 assert rv_json ['meta' ]['total' ] == total_create_requests
156175 assert rv_json ['items' ][0 ]['request_type' ] == 'create-empty-index'
@@ -160,14 +179,22 @@ def test_get_builds(app, auth_env, client, db):
160179 assert rv_json ['items' ][0 ]['user' ] == 'tbrady@DOMAIN.LOCAL'
161180
162181
163- def test_index_image_filter (app , client , db , minimal_request_add , minimal_request_rm ):
182+ def test_index_image_filter (
183+ app , client , db , minimal_request_add , minimal_request_rm , minimal_request_fbc_operations
184+ ):
164185 minimal_request_add .add_state ('in_progress' , 'Starting things up!' )
165186 minimal_request_add .index_image = Image .get_or_create ('quay.io/namespace/index@sha256:fghijk' )
166187 minimal_request_add .add_state ('complete' , 'The request is complete' )
167188
168189 minimal_request_rm .add_state ('in_progress' , 'Starting things up!' )
169190 minimal_request_rm .index_image = Image .get_or_create ('quay.io/namespace/index@sha256:123456' )
170191 minimal_request_rm .add_state ('complete' , 'The request is complete' )
192+
193+ minimal_request_fbc_operations .add_state ('in_progress' , 'Starting things up!' )
194+ minimal_request_fbc_operations .index_image = Image .get_or_create (
195+ 'quay.io/namespace/index@sha256:fbcop'
196+ )
197+ minimal_request_fbc_operations .add_state ('complete' , 'The request is complete' )
171198 db .session .commit ()
172199
173200 rv_json = client .get ('/api/v1/builds?index_image=quay.io/namespace/index@sha256:fghijk' ).json
@@ -176,6 +203,9 @@ def test_index_image_filter(app, client, db, minimal_request_add, minimal_reques
176203 rv_json = client .get ('/api/v1/builds?index_image=quay.io/namespace/index@sha256:123456' ).json
177204 assert rv_json ['meta' ]['total' ] == 1
178205
206+ rv_json = client .get ('/api/v1/builds?index_image=quay.io/namespace/index@sha256:fbcop' ).json
207+ assert rv_json ['meta' ]['total' ] == 1
208+
179209 rv = client .get ('/api/v1/builds?index_image=quay.io/namespace/index@sha256:abc' )
180210 assert rv .json == {'error' : ('quay.io/namespace/index@sha256:abc is not a valid index image' )}
181211
0 commit comments