Skip to content

Commit

Permalink
Add test for dynamic list input
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronvg committed Jul 18, 2024
1 parent 9ee66ed commit 626acbe
Showing 1 changed file with 37 additions and 5 deletions.
42 changes: 37 additions & 5 deletions integ-tests/python/tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,13 @@ async def test_should_work_with_image_url():
)
assert_that(res.lower()).matches(r"(green|yellow|shrek|ogre)")


@pytest.mark.asyncio
async def test_should_work_with_vertex():
res = await b.TestVertex(
"donkey kong"

)
res = await b.TestVertex("donkey kong")
assert_that("donkey kong" in res.lower())



@pytest.mark.asyncio
async def test_should_work_with_image_base64():
res = await b.TestImageInput(img=baml_py.Image.from_base64("image/png", image_b64))
Expand Down Expand Up @@ -558,6 +555,41 @@ async def test_stream_dynamic_class_output():
assert final.hair_color == "black"


@pytest.mark.asyncio
async def test_dynamic_inputs_list():
tb = TypeBuilder()
tb.DynInputOutput.add_property("new_key", tb.string().optional())
custom_class = tb.add_class("MyBlah")
custom_class.add_property("nestedKey1", tb.string())
tb.DynInputOutput.add_property("blah", custom_class.type())

res = await b.DynamicListInputOutput(
[
{
"new_key": "hi",
"testKey": "myTest",
"blah": {
"nestedKey1": "nestedVal",
},
},
{
"new_key": "hi",
"testKey": "myTest",
"blah": {
"nestedKey1": "nestedVal",
},
},
],
{"tb": tb},
)
assert res[0].new_key == "hi"
assert res[0].testKey == "myTest"
assert res[0].blah["nestedKey1"] == "nestedVal"
assert res[1].new_key == "hi"
assert res[1].testKey == "myTest"
assert res[1].blah["nestedKey1"] == "nestedVal"


@pytest.mark.asyncio
async def test_nested_class_streaming():
stream = b.stream.FnOutputClassNested(
Expand Down

0 comments on commit 626acbe

Please sign in to comment.