File tree Expand file tree Collapse file tree
tests/unit/sagemaker/workflow Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ """Pipeline module with fixed upsert method."""
2+
3+
4+ def upsert (pipeline_definition , role_arn ):
5+ """Upsert a pipeline definition.
6+
7+ Args:
8+ pipeline_definition: The pipeline definition dict.
9+ role_arn: IAM role ARN (str or dict).
10+
11+ Returns:
12+ Tuple of (pipeline_definition, role_arn).
13+ """
14+ if isinstance (role_arn , dict ):
15+ role_arn = role_arn .get ("arn" , role_arn .get ("RoleArn" , "" ))
16+ if not isinstance (role_arn , str ):
17+ raise TypeError (f"role_arn must be a string, got { type (role_arn )} " )
18+ return pipeline_definition , role_arn
Original file line number Diff line number Diff line change 1+ """Unit tests for Pipeline.upsert() fix."""
2+ import pytest
3+ from sagemaker .workflow .pipeline import upsert
4+
5+
6+ def test_upsert_with_string_role_arn ():
7+ result = upsert ({"steps" : []}, "arn:aws:iam::123:role/MyRole" )
8+ assert result [1 ] == "arn:aws:iam::123:role/MyRole"
9+
10+
11+ def test_upsert_with_dict_role_arn ():
12+ result = upsert ({"steps" : []}, {"arn" : "arn:aws:iam::123:role/MyRole" })
13+ assert result [1 ] == "arn:aws:iam::123:role/MyRole"
14+
15+
16+ def test_upsert_with_invalid_role_arn_raises ():
17+ with pytest .raises (TypeError ):
18+ upsert ({"steps" : []}, 12345 )
You can’t perform that action at this time.
0 commit comments