@@ -852,6 +852,28 @@ def test_push_project_pushes_library_encrypted_in_the_cloud_with_the_key_the_pro
852852 push_manager ._logger .warn .assert_not_called ()
853853
854854
855+ @pytest .mark .parametrize ("library_encrypted_locally" , [False , True ])
856+ def test_push_project_creates_nothing_when_an_unencrypted_library_uses_a_library_pushed_encrypted (
857+ library_encrypted_locally : bool ) -> None :
858+ api_client , project_path , library_path , encryption_key_path = _create_project_with_library_in_encrypted_cloud_project ()
859+ if library_encrypted_locally :
860+ _encrypt_project_locally (library_path , encryption_key_path )
861+ new_library_path = Path .cwd () / "Library/New Library"
862+ container .project_manager .create_new_project (new_library_path , QCLanguage .Python )
863+ container .library_manager .remove_lean_library_reference_from_project (project_path , library_path )
864+ container .library_manager .add_lean_library_reference_to_project (project_path , new_library_path )
865+ container .library_manager .add_lean_library_reference_to_project (new_library_path , library_path )
866+
867+ push_manager = _create_push_manager (api_client , container .project_manager )
868+ with pytest .raises (RuntimeError , match = "pushed without encryption" ) as error :
869+ push_manager .push_project (project_path , ActionType .ENCRYPT , encryption_key_path )
870+
871+ assert "'Library/New Library'" in str (error .value )
872+ api_client .projects .create .assert_not_called ()
873+ api_client .projects .update .assert_not_called ()
874+ assert container .project_config_manager .get_project_config (new_library_path ).get ("cloud-id" ) is None
875+
876+
855877def test_push_projects_decrypts_encrypted_cloud_library_pushed_on_its_own () -> None :
856878 api_client , _ , library_path , _ = _create_project_with_library_in_encrypted_cloud_project ()
857879
0 commit comments