Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
packages:
- "@typespec/http-client-python"
---

Add test cases for flatten property with unknown type and read-only properties scenarios.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import pytest
from specs.azure.clientgenerator.core.flattenproperty.aio import FlattenPropertyClient
from specs.azure.clientgenerator.core.flattenproperty.models import (
FlattenModel,
ChildFlattenModel,
ChildModel,
FlattenModel,
FlattenUnknownModel,
NestedFlattenModel,
ChildFlattenModel,
Solution,
)


Expand Down Expand Up @@ -46,6 +48,22 @@ async def test_put_nested_flatten_model(client: FlattenPropertyClient):
)


@pytest.mark.asyncio
async def test_put_flatten_unknown_model(client: FlattenPropertyClient):
result = await client.put_flatten_unknown_model(FlattenUnknownModel(name="foo"))
assert result.name == "test"
assert result.properties == {"key1": "value1", "key2": "value2"}


@pytest.mark.asyncio
async def test_put_flatten_read_only_model(client: FlattenPropertyClient):
result = await client.put_flatten_read_only_model(Solution({"name": "foo"}))
assert result.name == "foo"
assert result["solutionId"] == "solution1"
assert result["title"] == "Solution Title"
assert result["content"] == "Solution Content"


@pytest.mark.asyncio # ============test for compatibility ============
async def test_dpg_model_common():
flatten_model = FlattenModel(name="hello", properties=ChildModel(age=0, description="test"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import pytest
from specs.azure.clientgenerator.core.flattenproperty import FlattenPropertyClient
from specs.azure.clientgenerator.core.flattenproperty.models import (
FlattenModel,
ChildFlattenModel,
ChildModel,
FlattenModel,
FlattenUnknownModel,
NestedFlattenModel,
ChildFlattenModel,
Solution,
)


Expand Down Expand Up @@ -41,6 +43,20 @@ def test_put_nested_flatten_model(client: FlattenPropertyClient):
)


def test_put_flatten_unknown_model(client: FlattenPropertyClient):
result = client.put_flatten_unknown_model(FlattenUnknownModel(name="foo"))
assert result.name == "test"
assert result.properties == {"key1": "value1", "key2": "value2"}


def test_put_flatten_read_only_model(client: FlattenPropertyClient):
result = client.put_flatten_read_only_model(Solution({"name": "foo"}))
assert result.name == "foo"
assert result["solutionId"] == "solution1"
assert result["title"] == "Solution Title"
assert result["content"] == "Solution Content"


# ============test for compatibility ============
def test_dpg_model_common():
flatten_model = FlattenModel(name="hello", properties=ChildModel(age=0, description="test"))
Expand Down
8 changes: 4 additions & 4 deletions packages/http-client-python/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/http-client-python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"@azure-tools/typespec-azure-resource-manager": "~0.65.0",
"@azure-tools/typespec-azure-rulesets": "~0.65.0",
"@azure-tools/typespec-client-generator-core": "~0.65.3",
"@azure-tools/azure-http-specs": "0.1.0-alpha.38-dev.2",
"@azure-tools/azure-http-specs": "0.1.0-alpha.38-dev.4",
"@typespec/compiler": "^1.9.0",
"@typespec/http": "^1.9.0",
"@typespec/openapi": "^1.9.0",
Expand Down