2626 CreateDeploymentResponse ,
2727 DataTransformConfig ,
2828 DeploymentsResponse ,
29- _get_package_type_for_directory ,
3029 _make_api_call ,
3130 _retrieve_access_token ,
3231 _retrieve_access_token_from_sf_cli ,
@@ -446,66 +445,6 @@ def join_side_effect(*args):
446445 mock_docker_run_cmd .assert_called_once_with ("default" , "/tmp/test_dir" )
447446
448447
449- class TestGetPackageTypeForDirectory :
450- @patch ("datacustomcode.deploy.get_package_type" )
451- @patch ("datacustomcode.deploy.find_base_directory" )
452- def test_get_package_type_function (
453- self , mock_find_base , mock_get_package_type
454- ):
455- """Test _get_package_type_for_directory returns function type."""
456- mock_find_base .return_value = "/project/root"
457- mock_get_package_type .return_value = "function"
458-
459- result = _get_package_type_for_directory ("/project/root/payload" )
460-
461- assert result == "function"
462- mock_find_base .assert_called_once ()
463- mock_get_package_type .assert_called_once_with ("/project/root" )
464-
465- @patch ("datacustomcode.deploy.get_package_type" )
466- @patch ("datacustomcode.deploy.find_base_directory" )
467- def test_get_package_type_script (self , mock_find_base , mock_get_package_type ):
468- """Test _get_package_type_for_directory returns script type."""
469- mock_find_base .return_value = "/project/root"
470- mock_get_package_type .return_value = "script"
471-
472- result = _get_package_type_for_directory ("/project/root/payload" )
473-
474- assert result == "script"
475- mock_find_base .assert_called_once ()
476- mock_get_package_type .assert_called_once_with ("/project/root" )
477-
478- @patch ("datacustomcode.deploy.get_package_type" )
479- @patch ("datacustomcode.deploy.find_base_directory" )
480- def test_get_package_type_file_not_found (
481- self , mock_find_base , mock_get_package_type
482- ):
483- """Test _get_package_type_for_directory defaults to script when config not found."""
484- mock_find_base .return_value = "/project/root"
485- mock_get_package_type .side_effect = FileNotFoundError ("Config not found" )
486-
487- result = _get_package_type_for_directory ("/project/root/payload" )
488-
489- assert result == "script"
490- mock_find_base .assert_called_once ()
491- mock_get_package_type .assert_called_once_with ("/project/root" )
492-
493- @patch ("datacustomcode.deploy.get_package_type" )
494- @patch ("datacustomcode.deploy.find_base_directory" )
495- def test_get_package_type_value_error (
496- self , mock_find_base , mock_get_package_type
497- ):
498- """Test _get_package_type_for_directory defaults to script on ValueError."""
499- mock_find_base .return_value = "/project/root"
500- mock_get_package_type .side_effect = ValueError ("Invalid type" )
501-
502- result = _get_package_type_for_directory ("/project/root/payload" )
503-
504- assert result == "script"
505- mock_find_base .assert_called_once ()
506- mock_get_package_type .assert_called_once_with ("/project/root" )
507-
508-
509448class TestHasNonemptyRequirementsFile :
510449 @patch ("datacustomcode.deploy.os.path.dirname" )
511450 @patch ("datacustomcode.deploy.os.path.isfile" )
@@ -806,7 +745,7 @@ def test_zip_with_requirements(
806745 ("/test/dir/subdir" , [], ["file3.py" ]),
807746 ]
808747
809- zip ("/test/dir" , "default" )
748+ zip ("/test/dir" , "default" , "script" )
810749
811750 mock_has_requirements .assert_called_once_with ("/test/dir" )
812751 mock_prepare .assert_called_once_with ("/test/dir" , "default" , "script" )
@@ -834,7 +773,7 @@ def test_zip_without_requirements(
834773 ("/test/dir/subdir" , [], ["file3.py" ]),
835774 ]
836775
837- zip ("/test/dir" , "default" )
776+ zip ("/test/dir" , "default" , "script" )
838777
839778 mock_has_requirements .assert_called_once_with ("/test/dir" )
840779 mock_prepare .assert_not_called ()
@@ -843,7 +782,6 @@ def test_zip_without_requirements(
843782 )
844783 assert mock_zipfile_instance .write .call_count == 3 # One call per file
845784
846- @patch ("datacustomcode.deploy._get_package_type_for_directory" )
847785 @patch ("datacustomcode.deploy.has_nonempty_requirements_file" )
848786 @patch ("datacustomcode.deploy.prepare_dependency_archive" )
849787 @patch ("zipfile.ZipFile" )
@@ -854,11 +792,9 @@ def test_zip_with_function_package_type(
854792 mock_zipfile ,
855793 mock_prepare ,
856794 mock_has_requirements ,
857- mock_get_package_type ,
858795 ):
859796 """Test zipping a directory with function package type."""
860797 mock_has_requirements .return_value = True
861- mock_get_package_type .return_value = "function"
862798 mock_zipfile_instance = MagicMock ()
863799 mock_zipfile .return_value .__enter__ .return_value = mock_zipfile_instance
864800 mock_zipfile_instance .write = MagicMock ()
@@ -869,10 +805,9 @@ def test_zip_with_function_package_type(
869805 ("/test/dir/subdir" , [], ["file3.py" ]),
870806 ]
871807
872- zip ("/test/dir" , "default" )
808+ zip ("/test/dir" , "default" , "function" )
873809
874810 mock_has_requirements .assert_called_once_with ("/test/dir" )
875- mock_get_package_type .assert_called_once_with ("/test/dir" )
876811 mock_prepare .assert_called_once_with ("/test/dir" , "default" , "function" )
877812 mock_zipfile .assert_called_once_with (
878813 "deployment.zip" , "w" , zipfile .ZIP_DEFLATED
@@ -1167,7 +1102,7 @@ def test_deploy_full(
11671102 mock_retrieve_token .assert_called_once_with (credentials )
11681103 mock_get_config .assert_called_once_with ("/test/dir" )
11691104 mock_create_deployment .assert_called_once_with (access_token , metadata )
1170- mock_zip .assert_called_once_with ("/test/dir" , "default" )
1105+ mock_zip .assert_called_once_with ("/test/dir" , "default" , "script" )
11711106 mock_upload_zip .assert_called_once_with ("https://upload.example.com" )
11721107 mock_wait .assert_called_once_with (access_token , metadata , callback )
11731108 mock_create_transform .assert_called_once_with (
@@ -1231,7 +1166,7 @@ def test_deploy_full_client_credentials(
12311166 mock_retrieve_token .assert_called_once_with (credentials )
12321167 mock_get_config .assert_called_once_with ("/test/dir" )
12331168 mock_create_deployment .assert_called_once_with (access_token , metadata )
1234- mock_zip .assert_called_once_with ("/test/dir" , "default" )
1169+ mock_zip .assert_called_once_with ("/test/dir" , "default" , "script" )
12351170 mock_upload_zip .assert_called_once_with ("https://upload.example.com" )
12361171 mock_wait .assert_called_once_with (access_token , metadata , callback )
12371172 mock_create_transform .assert_called_once_with (
@@ -1337,7 +1272,7 @@ def test_deploy_full_happy_path(
13371272 mock_retrieve_token .assert_called_once_with (credentials )
13381273 mock_get_config .assert_called_once_with ("/test/dir" )
13391274 mock_create_deployment .assert_called_once_with (access_token , metadata )
1340- mock_zip .assert_called_once_with ("/test/dir" , "default" )
1275+ mock_zip .assert_called_once_with ("/test/dir" , "default" , "script" )
13411276 mock_upload_zip .assert_called_once_with ("https://upload.example.com" )
13421277 mock_wait .assert_called_once_with (access_token , metadata , callback )
13431278 mock_create_transform .assert_called_once_with (
0 commit comments