@@ -630,15 +630,7 @@ def test_get_manager_dependency_name(dependency, expected_name):
630630 (True , [{compilesketches .CompileSketches .dependency_source_path_key : pathlib .Path ("Foo" )}])]
631631)
632632def test_install_platforms_from_path (capsys , mocker , path_exists , platform_list ):
633- class PlatformInstallationPath :
634- def __init__ (self ):
635- self .parent = pathlib .PurePath ()
636- self .name = pathlib .PurePath ()
637-
638- platform_installation_path = PlatformInstallationPath ()
639- platform_installation_path .base = pathlib .Path ("/foo/PlatformInstallationPathParent" )
640- platform_installation_path .platform = pathlib .Path ("PlatformInstallationPathName" )
641- symlink_source_path = pathlib .Path ("/foo/SymlinkSourcePath" )
633+ platform_installation_path = pathlib .Path ("/foo/PlatformInstallationPathParent/PlatformInstallationPathName" )
642634
643635 compile_sketches = get_compilesketches_object ()
644636
@@ -647,7 +639,6 @@ def __init__(self):
647639 autospec = True ,
648640 return_value = platform_installation_path )
649641 mocker .patch .object (pathlib .Path , "mkdir" , autospec = True )
650- mocker .patch .object (pathlib .Path , "joinpath" , autospec = True , return_value = symlink_source_path )
651642 mocker .patch .object (pathlib .Path , "symlink_to" , autospec = True )
652643
653644 if not path_exists :
@@ -664,17 +655,14 @@ def __init__(self):
664655 compile_sketches .install_platforms_from_path (platform_list = platform_list )
665656
666657 get_platform_installation_path_calls = []
667- joinpath_calls = []
668658 mkdir_calls = []
669659 symlink_to_calls = []
670660 for platform in platform_list :
671661 get_platform_installation_path_calls .append (unittest .mock .call (compile_sketches , platform = platform ))
672- mkdir_calls .append (unittest .mock .call (platform_installation_path .base , parents = True , exist_ok = True ))
673- joinpath_calls .append (unittest .mock .call (platform_installation_path .base ,
674- platform_installation_path .platform ))
662+ mkdir_calls .append (unittest .mock .call (platform_installation_path .parent , parents = True , exist_ok = True ))
675663 symlink_to_calls .append (
676664 unittest .mock .call (
677- symlink_source_path ,
665+ platform_installation_path ,
678666 target = compilesketches .absolute_path (
679667 platform [compilesketches .CompileSketches .dependency_source_path_key ]
680668 ),
@@ -684,35 +672,29 @@ def __init__(self):
684672
685673 # noinspection PyUnresolvedReferences
686674 pathlib .Path .mkdir .assert_has_calls (calls = mkdir_calls )
687- # noinspection PyUnresolvedReferences
688- pathlib .Path .joinpath .assert_has_calls (calls = joinpath_calls )
689675 pathlib .Path .symlink_to .assert_has_calls (calls = symlink_to_calls )
690676
691677
692678@pytest .mark .parametrize (
693679 "platform,"
694680 "command_data_stdout,"
695- "expected_installation_path_base,"
696- "expected_installation_path_platform,"
681+ "expected_installation_path,"
697682 "expected_rmtree" ,
698683 # No match to previously installed platforms
699684 [({compilesketches .CompileSketches .dependency_name_key : "foo:bar" },
700685 "[{\" ID\" : \" asdf:zxcv\" }]" ,
701- pathlib .PurePath ("/foo/UserPlatformsPath" ),
702- pathlib .PurePath ("foo/bar" ),
686+ pathlib .PurePath ("/foo/UserPlatformsPath/foo/bar" ),
703687 False ),
704688 # Match with previously installed platform
705689 ({compilesketches .CompileSketches .dependency_name_key : "foo:bar" },
706690 "[{\" ID\" : \" foo:bar\" , \" Installed\" : \" 1.2.3\" }]" ,
707- pathlib .PurePath ("/foo/BoardManagerPlatformsPath" ),
708- pathlib .PurePath ("foo/hardware/bar/1.2.3" ),
691+ pathlib .PurePath ("/foo/BoardManagerPlatformsPath/foo/hardware/bar/1.2.3" ),
709692 True )]
710693)
711694def test_get_platform_installation_path (mocker ,
712695 platform ,
713696 command_data_stdout ,
714- expected_installation_path_base ,
715- expected_installation_path_platform ,
697+ expected_installation_path ,
716698 expected_rmtree ):
717699 class CommandData :
718700 def __init__ (self , stdout ):
@@ -728,8 +710,7 @@ def __init__(self, stdout):
728710 compile_sketches .board_manager_platforms_path = pathlib .PurePath ("/foo/BoardManagerPlatformsPath" )
729711
730712 platform_installation_path = compile_sketches .get_platform_installation_path (platform = platform )
731- assert platform_installation_path .base == expected_installation_path_base
732- assert platform_installation_path .platform == expected_installation_path_platform
713+ assert platform_installation_path == expected_installation_path
733714
734715 run_arduino_cli_command_calls = [unittest .mock .call (compile_sketches , command = ["core" , "update-index" ]),
735716 unittest .mock .call (compile_sketches , command = ["core" , "list" , "--format" , "json" ])]
@@ -739,7 +720,7 @@ def __init__(self, stdout):
739720 if expected_rmtree is True :
740721 # noinspection PyUnresolvedReferences
741722 shutil .rmtree .assert_called_once_with (
742- path = platform_installation_path . base . joinpath ( platform_installation_path . platform )
723+ path = platform_installation_path
743724 )
744725 else :
745726 # noinspection PyUnresolvedReferences
@@ -756,14 +737,7 @@ def test_install_platforms_from_repository(mocker):
756737
757738 git_ref = unittest .mock .sentinel .git_ref
758739
759- class PlatformInstallationPath :
760- def __init__ (self ):
761- self .base = pathlib .PurePath ()
762- self .platform = pathlib .PurePath ()
763-
764- platform_installation_path = PlatformInstallationPath ()
765- platform_installation_path .base = pathlib .Path ("/foo/PlatformInstallationPathParent" )
766- platform_installation_path .platform = pathlib .Path ("PlatformInstallationPathName" )
740+ platform_installation_path = pathlib .Path ("/foo/PlatformInstallationPathParent/PlatformInstallationPathName" )
767741
768742 expected_source_path_list = [unittest .mock .sentinel .source_path , "." ]
769743 expected_destination_name_list = [unittest .mock .sentinel .destination_name , None ]
@@ -791,8 +765,8 @@ def __init__(self):
791765 url = platform [compilesketches .CompileSketches .dependency_source_url_key ],
792766 git_ref = git_ref ,
793767 source_path = expected_source_path ,
794- destination_parent_path = platform_installation_path .base ,
795- destination_name = platform_installation_path .platform )
768+ destination_parent_path = platform_installation_path .parent ,
769+ destination_name = platform_installation_path .name )
796770 )
797771
798772 compile_sketches .get_repository_dependency_ref .assert_has_calls (calls = get_repository_dependency_ref_calls )
@@ -817,14 +791,7 @@ def test_install_platforms_from_download(mocker):
817791 {compilesketches .CompileSketches .dependency_source_url_key : unittest .mock .sentinel .source_url2 }
818792 ]
819793
820- class PlatformInstallationPath :
821- def __init__ (self ):
822- self .base = pathlib .PurePath ()
823- self .platform = pathlib .PurePath ()
824-
825- platform_installation_path = PlatformInstallationPath ()
826- platform_installation_path .parent = pathlib .Path ("/foo/PlatformInstallationPathParent" )
827- platform_installation_path .name = pathlib .Path ("PlatformInstallationPathName" )
794+ platform_installation_path = pathlib .Path ("/foo/PlatformInstallationPathParent/PlatformInstallationPathName" )
828795
829796 expected_source_path_list = [unittest .mock .sentinel .source_path , "." ]
830797
@@ -844,8 +811,8 @@ def __init__(self):
844811 install_platforms_from_download_calls .append (
845812 unittest .mock .call (url = platform [compilesketches .CompileSketches .dependency_source_url_key ],
846813 source_path = expected_source_path ,
847- destination_parent_path = platform_installation_path .base ,
848- destination_name = platform_installation_path .platform )
814+ destination_parent_path = platform_installation_path .parent ,
815+ destination_name = platform_installation_path .name )
849816 )
850817 compilesketches .install_from_download .assert_has_calls (calls = install_platforms_from_download_calls )
851818
0 commit comments