Skip to content

Commit 3fa6c8f

Browse files
committed
adding unit tests
1 parent 80df0e2 commit 3fa6c8f

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

tests/unit/sagemaker/jumpstart/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9813,7 +9813,7 @@
98139813
"ComponentNames": ["variant1"],
98149814
"BenchmarkMetrics": {
98159815
"ml.g5.12xlarge": [
9816-
{"Name": "latency", "Unit": "sec", "Value": "0.19", "Concurrency": "1"},
9816+
{"name": "latency", "unit": "sec", "value": "0.19", "concurrency": "1"},
98179817
]
98189818
},
98199819
},

tests/unit/sagemaker/jumpstart/hub/test_utils.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ def test_walk_and_apply_json():
264264
"CamelCaseObjectChildTwo": "value2",
265265
},
266266
"IgnoreMyChildren": {"ShouldNotBeTouchedOne": "const1", "ShouldNotBeTouchedTwo": "const2"},
267+
"ShouldNotIgnoreMyChildren": {"NopeNope": "no"}
267268
}
268269

269270
result = parser_utils.walk_and_apply_json(
@@ -279,4 +280,35 @@ def test_walk_and_apply_json():
279280
"ShouldNotBeTouchedOne": "const1",
280281
"ShouldNotBeTouchedTwo": "const2",
281282
},
283+
"should_not_ignore_my_children": { "nope_nope": "no"}
284+
}
285+
286+
def test_walk_and_apply_json_no_stop():
287+
test_json = {
288+
"CamelCaseKey": "value",
289+
"CamelCaseObjectKey": {
290+
"CamelCaseObjectChildOne": "value1",
291+
"CamelCaseObjectChildTwo": "value2",
292+
},
293+
"CamelCaseObjectListKey": {
294+
"instance.ml.type.xlarge": [
295+
{"ShouldChangeMe": "string"}
296+
]
297+
}
298+
}
299+
300+
result = parser_utils.walk_and_apply_json(
301+
test_json, parser_utils.camel_to_snake
302+
)
303+
assert result == {
304+
"camel_case_key": "value",
305+
"camel_case_object_key": {
306+
"camel_case_object_child_one": "value1",
307+
"camel_case_object_child_two": "value2",
308+
},
309+
"camel_case_object_list_key": {
310+
"instance.ml.type.xlarge": [
311+
{ "should_change_me": "string" }
312+
]
313+
},
282314
}

0 commit comments

Comments
 (0)