@@ -354,10 +354,10 @@ def test_manager_migration(package_manager, fake_db_for_migration):
354
354
call ('test-package-3=1.6.0' ),
355
355
# test-package-4 was not present in DB at all, but it is present and installed in
356
356
# fake_db_for_migration, thus asserting that it is going to be installed.
357
- call (' test-package-4= 1.5.0' ),
357
+ call (None , 'Azure/docker- test-4: 1.5.0' , name = 'test-package-4 ' ),
358
358
# test-package-5 1.5.0 was installed in fake_db_for_migration but the default
359
359
# in current db is 1.9.0, assert that migration will install the newer version.
360
- call (' test-package-5= 1.9.0' ),
360
+ call (None , 'Azure/docker- test-5: 1.9.0' , name = 'test-package-5 ' ),
361
361
# test-package-6 2.0.0 was installed in fake_db_for_migration but the default
362
362
# in current db is 1.5.0, assert that migration will install the newer version.
363
363
call ('test-package-6=2.0.0' )],
@@ -385,12 +385,12 @@ def save(self, named):
385
385
return DockerClient (dockerd_sock )
386
386
387
387
388
- # def test_manager_migration_dockerd(package_manager, fake_db_for_migration, mock_docker_api):
389
- # package_manager.install = Mock()
390
- # package_manager.get_docker_client = Mock(side_effect=mock_get_docker_client)
391
- # package_manager.migrate_packages(fake_db_for_migration, '/var/run/docker.sock')
392
- # package_manager.get_docker_client.assert_has_calls([
393
- # call('/var/run/docker.sock')], any_order=True)
388
+ def test_manager_migration_dockerd (package_manager , fake_db_for_migration , mock_docker_api ):
389
+ package_manager .install = Mock ()
390
+ package_manager .get_docker_client = Mock (side_effect = mock_get_docker_client )
391
+ package_manager .migrate_packages (fake_db_for_migration , '/var/run/docker.sock' )
392
+ package_manager .get_docker_client .assert_has_calls ([
393
+ call ('/var/run/docker.sock' )], any_order = True )
394
394
395
395
396
396
def test_create_package_manifest_default_manifest (package_manager ):
@@ -478,29 +478,18 @@ def test_manifests_update_command(package_manager):
478
478
mock_echo .assert_called_with ("Manifest 'test_manifest' updated successfully." )
479
479
480
480
481
- def test_check_manifests_directory_existence (package_manager ):
482
- with patch ('click.echo' ) as mock_echo , \
483
- patch ('os.path.exists' ) as mock_exists :
484
-
485
- mock_exists .return_value = False
486
- result = package_manager .check_manifests_directory_existence ()
487
- mock_echo .assert_called_with ("Manifests files directory empty" )
488
- assert result == False
489
481
490
482
def test_delete_package_manifest (package_manager ):
491
483
with patch ('click.echo' ) as mock_echo , \
492
484
patch ('click.prompt' ) as mock_prompt , \
493
485
patch ('os.path.exists' ) as mock_exists , \
494
- patch ('os.remove' ) as mock_remove , \
495
- patch .object (package_manager , 'check_manifests_directory_existence' ) as mock_check_manifests :
496
-
486
+ patch ('os.remove' ) as mock_remove :
497
487
498
488
# Test case 1: deleting default manifest
499
489
package_manager .delete_package_manifest ("default_manifest" )
500
490
mock_echo .assert_called_with ("Default Manifest deletion is not allowed" )
501
491
mock_echo .reset_mock () # Reset the mock for the next test case
502
492
503
- mock_check_manifests .return_value = True
504
493
# Test case 2: manifest file doesn't exist
505
494
mock_exists .return_value = True
506
495
mock_exists .side_effect = lambda x : False if x .endswith ("test_manifest" ) else True
@@ -526,7 +515,6 @@ def test_show_package_manifest(package_manager):
526
515
with patch ('click.echo' ) as mock_echo , \
527
516
patch ('os.path.exists' ) as mock_exists , \
528
517
patch ('builtins.open' , unittest .mock .mock_open ()) as mock_open , \
529
- patch .object (package_manager , 'check_manifests_directory_existence' ) as mock_check_manifests , \
530
518
patch ('json.load' ) as mock_json_load :
531
519
532
520
mock_exists .return_value = True
@@ -543,18 +531,13 @@ def test_list_package_manifest(package_manager):
543
531
patch ('os.path.exists' ) as mock_exists , \
544
532
patch ('os.listdir' ) as mock_listdir :
545
533
546
- # Test case 1: manifest directory doesn't exist
547
- mock_exists .return_value = False
548
- package_manager .list_package_manifest ()
549
- mock_echo .assert_called_with ("Manifests files directory empty" )
550
-
551
- # Test case 2: no custom local manifest files found
534
+ # Test case 1: no custom local manifest files found
552
535
mock_exists .return_value = True
553
536
mock_listdir .return_value = []
554
537
package_manager .list_package_manifest ()
555
538
mock_echo .assert_called_with ("No custom local manifest files found." )
556
539
557
- # Test case 3 : custom local manifest files found
540
+ # Test case 2 : custom local manifest files found
558
541
mock_listdir .return_value = ["manifest1.json" , "manifest2.json" ]
559
542
package_manager .list_package_manifest ()
560
543
mock_echo .assert_any_call ("Custom Local Manifest files:" )
0 commit comments