diff --git a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_encode_array_async.py b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_encode_array_async.py index 27cae3caa0..925780cd4a 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_encode_array_async.py +++ b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_encode_array_async.py @@ -41,3 +41,99 @@ async def test_newline_delimited(client: ArrayClient): body = models.NewlineDelimitedArrayProperty(value=["blue", "red", "green"]) result = await client.property.newline_delimited(body) assert result.value == ["blue", "red", "green"] + + +@pytest.mark.asyncio +async def test_enum_comma_delimited(client: ArrayClient): + body = models.CommaDelimitedEnumArrayProperty(value=[models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN]) + result = await client.property.enum_comma_delimited(body) + assert result.value == [models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN] + + +@pytest.mark.asyncio +async def test_enum_space_delimited(client: ArrayClient): + body = models.SpaceDelimitedEnumArrayProperty(value=[models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN]) + result = await client.property.enum_space_delimited(body) + assert result.value == [models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN] + + +@pytest.mark.asyncio +async def test_enum_pipe_delimited(client: ArrayClient): + body = models.PipeDelimitedEnumArrayProperty(value=[models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN]) + result = await client.property.enum_pipe_delimited(body) + assert result.value == [models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN] + + +@pytest.mark.asyncio +async def test_enum_newline_delimited(client: ArrayClient): + body = models.NewlineDelimitedEnumArrayProperty(value=[models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN]) + result = await client.property.enum_newline_delimited(body) + assert result.value == [models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN] + + +@pytest.mark.asyncio +async def test_extensible_enum_comma_delimited(client: ArrayClient): + body = models.CommaDelimitedExtensibleEnumArrayProperty( + value=[ + models.ColorsExtensibleEnum.BLUE, + models.ColorsExtensibleEnum.RED, + models.ColorsExtensibleEnum.GREEN, + ] + ) + result = await client.property.extensible_enum_comma_delimited(body) + assert result.value == [ + models.ColorsExtensibleEnum.BLUE, + models.ColorsExtensibleEnum.RED, + models.ColorsExtensibleEnum.GREEN, + ] + + +@pytest.mark.asyncio +async def test_extensible_enum_space_delimited(client: ArrayClient): + body = models.SpaceDelimitedExtensibleEnumArrayProperty( + value=[ + models.ColorsExtensibleEnum.BLUE, + models.ColorsExtensibleEnum.RED, + models.ColorsExtensibleEnum.GREEN, + ] + ) + result = await client.property.extensible_enum_space_delimited(body) + assert result.value == [ + models.ColorsExtensibleEnum.BLUE, + models.ColorsExtensibleEnum.RED, + models.ColorsExtensibleEnum.GREEN, + ] + + +@pytest.mark.asyncio +async def test_extensible_enum_pipe_delimited(client: ArrayClient): + body = models.PipeDelimitedExtensibleEnumArrayProperty( + value=[ + models.ColorsExtensibleEnum.BLUE, + models.ColorsExtensibleEnum.RED, + models.ColorsExtensibleEnum.GREEN, + ] + ) + result = await client.property.extensible_enum_pipe_delimited(body) + assert result.value == [ + models.ColorsExtensibleEnum.BLUE, + models.ColorsExtensibleEnum.RED, + models.ColorsExtensibleEnum.GREEN, + ] + + +@pytest.mark.asyncio +async def test_extensible_enum_newline_delimited(client: ArrayClient): + body = models.NewlineDelimitedExtensibleEnumArrayProperty( + value=[ + models.ColorsExtensibleEnum.BLUE, + models.ColorsExtensibleEnum.RED, + models.ColorsExtensibleEnum.GREEN, + ] + ) + result = await client.property.extensible_enum_newline_delimited(body) + assert result.value == [ + models.ColorsExtensibleEnum.BLUE, + models.ColorsExtensibleEnum.RED, + models.ColorsExtensibleEnum.GREEN, + ] diff --git a/packages/typespec-python/test/generic_mock_api_tests/test_encode_array.py b/packages/typespec-python/test/generic_mock_api_tests/test_encode_array.py index 3e1b48c908..a09a05a793 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/test_encode_array.py +++ b/packages/typespec-python/test/generic_mock_api_tests/test_encode_array.py @@ -36,3 +36,91 @@ def test_newline_delimited(client: ArrayClient): body = models.NewlineDelimitedArrayProperty(value=["blue", "red", "green"]) result = client.property.newline_delimited(body) assert result.value == ["blue", "red", "green"] + + +def test_enum_comma_delimited(client: ArrayClient): + body = models.CommaDelimitedEnumArrayProperty(value=[models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN]) + result = client.property.enum_comma_delimited(body) + assert result.value == [models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN] + + +def test_enum_space_delimited(client: ArrayClient): + body = models.SpaceDelimitedEnumArrayProperty(value=[models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN]) + result = client.property.enum_space_delimited(body) + assert result.value == [models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN] + + +def test_enum_pipe_delimited(client: ArrayClient): + body = models.PipeDelimitedEnumArrayProperty(value=[models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN]) + result = client.property.enum_pipe_delimited(body) + assert result.value == [models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN] + + +def test_enum_newline_delimited(client: ArrayClient): + body = models.NewlineDelimitedEnumArrayProperty(value=[models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN]) + result = client.property.enum_newline_delimited(body) + assert result.value == [models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN] + + +def test_extensible_enum_comma_delimited(client: ArrayClient): + body = models.CommaDelimitedExtensibleEnumArrayProperty( + value=[ + models.ColorsExtensibleEnum.BLUE, + models.ColorsExtensibleEnum.RED, + models.ColorsExtensibleEnum.GREEN, + ] + ) + result = client.property.extensible_enum_comma_delimited(body) + assert result.value == [ + models.ColorsExtensibleEnum.BLUE, + models.ColorsExtensibleEnum.RED, + models.ColorsExtensibleEnum.GREEN, + ] + + +def test_extensible_enum_space_delimited(client: ArrayClient): + body = models.SpaceDelimitedExtensibleEnumArrayProperty( + value=[ + models.ColorsExtensibleEnum.BLUE, + models.ColorsExtensibleEnum.RED, + models.ColorsExtensibleEnum.GREEN, + ] + ) + result = client.property.extensible_enum_space_delimited(body) + assert result.value == [ + models.ColorsExtensibleEnum.BLUE, + models.ColorsExtensibleEnum.RED, + models.ColorsExtensibleEnum.GREEN, + ] + + +def test_extensible_enum_pipe_delimited(client: ArrayClient): + body = models.PipeDelimitedExtensibleEnumArrayProperty( + value=[ + models.ColorsExtensibleEnum.BLUE, + models.ColorsExtensibleEnum.RED, + models.ColorsExtensibleEnum.GREEN, + ] + ) + result = client.property.extensible_enum_pipe_delimited(body) + assert result.value == [ + models.ColorsExtensibleEnum.BLUE, + models.ColorsExtensibleEnum.RED, + models.ColorsExtensibleEnum.GREEN, + ] + + +def test_extensible_enum_newline_delimited(client: ArrayClient): + body = models.NewlineDelimitedExtensibleEnumArrayProperty( + value=[ + models.ColorsExtensibleEnum.BLUE, + models.ColorsExtensibleEnum.RED, + models.ColorsExtensibleEnum.GREEN, + ] + ) + result = client.property.extensible_enum_newline_delimited(body) + assert result.value == [ + models.ColorsExtensibleEnum.BLUE, + models.ColorsExtensibleEnum.RED, + models.ColorsExtensibleEnum.GREEN, + ]