@@ -565,6 +565,134 @@ def test_raises_error_on_invalid_json(self):
565565 if os .path .exists (config_path ):
566566 os .remove (config_path )
567567
568+ def test_update_config_updates_entrypoint (self ):
569+ """
570+ Test that update_config() updates the entryPoint field
571+ when scanning a renamed file.
572+ """
573+ content = textwrap .dedent (
574+ """
575+ from datacustomcode.client import Client
576+
577+ client = Client()
578+ df = client.read_dlo("input_dlo")
579+ client.write_to_dlo("output_dlo", df, "overwrite")
580+ """
581+ )
582+
583+ temp_path = create_test_script (content )
584+ file_dir = os .path .dirname (temp_path )
585+ config_path = os .path .join (file_dir , "config.json" )
586+
587+ try :
588+ sdk_config_path = create_sdk_config (file_dir , "script" )
589+
590+ initial_config = {
591+ "sdkVersion" : "1.0.0" ,
592+ "entryPoint" : "old_entrypoint.py" ,
593+ "dataspace" : "custom_dataspace" ,
594+ "permissions" : {
595+ "read" : {"dlo" : ["old_dlo" ]},
596+ "write" : {"dlo" : ["old_output" ]},
597+ },
598+ }
599+ with open (config_path , "w" ) as f :
600+ json .dump (initial_config , f )
601+
602+ updated_config = update_config (temp_path )
603+
604+ assert updated_config ["entryPoint" ] == os .path .basename (temp_path )
605+ assert updated_config ["dataspace" ] == "custom_dataspace"
606+ assert updated_config ["permissions" ]["read" ]["dlo" ] == ["input_dlo" ]
607+ assert updated_config ["permissions" ]["write" ]["dlo" ] == ["output_dlo" ]
608+
609+ finally :
610+ os .remove (temp_path )
611+ if os .path .exists (config_path ):
612+ os .remove (config_path )
613+ if os .path .exists (sdk_config_path ):
614+ os .remove (sdk_config_path )
615+ os .rmdir (os .path .dirname (sdk_config_path ))
616+
617+ def test_update_entrypoint_with_absolute_path (self ):
618+ """Test that entryPoint uses basename even when file_path is absolute."""
619+ content = textwrap .dedent (
620+ """
621+ from datacustomcode.client import Client
622+
623+ client = Client()
624+ df = client.read_dlo("input_dlo")
625+ client.write_to_dlo("output_dlo", df, "overwrite")
626+ """
627+ )
628+
629+ temp_path = create_test_script (content )
630+ assert os .path .isabs (temp_path ), "Test requires absolute path"
631+
632+ file_dir = os .path .dirname (temp_path )
633+ config_path = os .path .join (file_dir , "config.json" )
634+
635+ try :
636+ sdk_config_path = create_sdk_config (file_dir , "script" )
637+
638+ initial_config = {
639+ "sdkVersion" : "1.0.0" ,
640+ "entryPoint" : "old.py" ,
641+ "dataspace" : "default" ,
642+ "permissions" : {"read" : {}, "write" : {}},
643+ }
644+ with open (config_path , "w" ) as f :
645+ json .dump (initial_config , f )
646+
647+ updated_config = update_config (temp_path )
648+
649+ assert updated_config ["entryPoint" ] == os .path .basename (temp_path )
650+ assert "/" not in updated_config ["entryPoint" ]
651+
652+ finally :
653+ os .remove (temp_path )
654+ if os .path .exists (config_path ):
655+ os .remove (config_path )
656+ if os .path .exists (sdk_config_path ):
657+ os .remove (sdk_config_path )
658+ os .rmdir (os .path .dirname (sdk_config_path ))
659+
660+ def test_update_entrypoint_preserves_function_type (self ):
661+ """Test that entryPoint update works for 'function' package type."""
662+ content = textwrap .dedent (
663+ """
664+ from datacustomcode.client import Client
665+
666+ def my_function(event, context):
667+ return {"statusCode": 200}
668+ """
669+ )
670+
671+ temp_path = create_test_script (content )
672+ file_dir = os .path .dirname (temp_path )
673+ config_path = os .path .join (file_dir , "config.json" )
674+
675+ try :
676+ sdk_config_path = create_sdk_config (file_dir , "function" )
677+
678+ initial_config = {
679+ "entryPoint" : "old_function.py" ,
680+ }
681+ with open (config_path , "w" ) as f :
682+ json .dump (initial_config , f )
683+
684+ updated_config = update_config (temp_path )
685+
686+ assert updated_config ["entryPoint" ] == os .path .basename (temp_path )
687+
688+ finally :
689+ os .remove (temp_path )
690+ if os .path .exists (config_path ):
691+ os .remove (config_path )
692+ if os .path .exists (sdk_config_path ):
693+ os .remove (sdk_config_path )
694+ os .rmdir (os .path .dirname (sdk_config_path ))
695+
568696
569697class TestDataAccessLayerCalls :
570698 """Tests for the DataAccessLayerCalls class directly."""
0 commit comments