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