55import socket
66
77from unittest import mock
8+ from unittest .mock import call
89
910from iib .exceptions import IIBError , AddressAlreadyInUse
1011from iib .workers .config import get_worker_config
@@ -36,6 +37,7 @@ def mock_config():
3637 mock_config .iib_grpc_max_port_tries = 3
3738 mock_config .iib_grpc_max_tries = 3
3839 mock_config .iib_deprecate_bundles_limit = 5
40+ mock_config .iib_max_number_of_bundles_as_cmd_argument = 1
3941 mc .return_value = mock_config
4042 yield mc
4143
@@ -462,6 +464,7 @@ def test_opm_registry_add(
462464@pytest .mark .parametrize ('overwrite_csv' , (True , False ))
463465@pytest .mark .parametrize ('container_tool' , (None , 'podwoman' ))
464466@pytest .mark .parametrize ('graph_update_mode' , (None , 'semver-skippatch' ))
467+ @mock .patch ('iib.workers.tasks.opm_operations._get_or_create_temp_index_db_file' )
465468@mock .patch ('iib.workers.tasks.opm_operations.create_dockerfile' )
466469@mock .patch ('iib.workers.tasks.opm_operations.opm_migrate' )
467470@mock .patch ('iib.workers.tasks.opm_operations._opm_registry_add' )
@@ -475,13 +478,15 @@ def test_opm_registry_add_fbc(
475478 mock_ora ,
476479 mock_om ,
477480 mock_ogd ,
481+ mock_get_db_file ,
478482 from_index ,
479483 bundles ,
480484 overwrite_csv ,
481485 container_tool ,
482486 graph_update_mode ,
483487 is_fbc ,
484488 tmpdir ,
489+ mock_config ,
485490):
486491 index_db_file = os .path .join (tmpdir , 'database/index.db' )
487492 fbc_dir = os .path .join (tmpdir , 'catalogs' )
@@ -491,6 +496,9 @@ def test_opm_registry_add_fbc(
491496 mock_om .return_value = (fbc_dir , cache_dir )
492497 mock_iifbc .return_value = is_fbc
493498
499+ index_db_file = os .path .join (tmpdir , 'database/index.db' )
500+ mock_get_db_file .return_value = index_db_file
501+
494502 opm_operations .opm_registry_add_fbc (
495503 base_dir = tmpdir ,
496504 bundles = bundles ,
@@ -500,15 +508,23 @@ def test_opm_registry_add_fbc(
500508 overwrite_csv = overwrite_csv ,
501509 container_tool = container_tool ,
502510 )
511+ max_bundles = mock_config .return_value .iib_max_number_of_bundles_as_cmd_argument
503512
504- mock_ora .assert_called_once_with (
505- base_dir = tmpdir ,
506- index_db = index_db_file ,
507- bundles = bundles ,
508- overwrite_csv = overwrite_csv ,
509- container_tool = container_tool ,
510- graph_update_mode = graph_update_mode ,
511- )
513+ if bundles :
514+ expected_calls = []
515+ for i in range (0 , len (bundles ), max_bundles ):
516+ chunk = bundles [i : i + max_bundles ]
517+ expected_calls .append (
518+ call (
519+ base_dir = tmpdir ,
520+ index_db = index_db_file ,
521+ bundles = chunk ,
522+ overwrite_csv = overwrite_csv ,
523+ container_tool = container_tool ,
524+ graph_update_mode = graph_update_mode ,
525+ )
526+ )
527+ mock_ora .assert_has_calls (expected_calls )
512528
513529 mock_om .assert_called_once_with (index_db = index_db_file , base_dir = tmpdir )
514530 mock_ogd .assert_called_once_with (
0 commit comments