Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add back extra missing tests #2574

Merged
merged 2 commits into from
May 6, 2024
Merged
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
Expand Up @@ -74,6 +74,16 @@ async def test_nullable_float_value(client: DictionaryClient):
await client.nullable_float_value.put(value)


@pytest.mark.asyncio
async def test_recursive_model_value(client: DictionaryClient):
value = {
"k1": models.InnerModel(property="hello", children={}),
"k2": models.InnerModel(property="world", children={"k2.1": models.InnerModel(property="inner world")}),
}
assert await client.recursive_model_value.get() == value
await client.recursive_model_value.put(value)


@pytest.mark.asyncio
async def test_string_value(client: DictionaryClient):
value = {"k1": "hello", "k2": ""}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,6 @@ async def client():
yield client


@pytest.mark.asyncio
async def test_model_deserialization(client: ValueTypesClient):
body = models.ModelProperty(property={"property": "hello"})
assert body.property.property == body["property"]["property"]
await client.model.put(body)

resp = await client.model.get()
assert resp.property.property == resp["property"]["property"]

body = models.CollectionsModelProperty(property=[{"property": "hello"}, {"property": "world"}])
assert body.property[0].property == body["property"][0]["property"]
resp = await client.collections_model.get()
assert resp.property[1].property == resp["property"][1]["property"]


@pytest.mark.asyncio
async def test_enum_property():
for prop in ["ValueOne", models.FixedInnerEnum.VALUE_ONE]:
string_type = models.EnumProperty(property=prop)
assert isinstance(string_type.property, models.FixedInnerEnum)
assert isinstance(string_type["property"], str)


@pytest.mark.asyncio
async def test_boolean(client: ValueTypesClient):
body = models.BooleanProperty(property=True)
Expand Down Expand Up @@ -76,6 +53,8 @@ async def test_bytes(client: ValueTypesClient):
async def test_collections_int(client: ValueTypesClient):
body = models.CollectionsIntProperty(property=[1, 2])
assert body.property == body["property"]
await client.collections_int.put(body)

resp = await client.collections_int.get()
assert resp.property == resp["property"] == [1, 2]

Expand All @@ -84,6 +63,8 @@ async def test_collections_int(client: ValueTypesClient):
async def test_collections_model(client: ValueTypesClient):
body = models.CollectionsModelProperty(property=[{"property": "hello"}, {"property": "world"}])
assert body.property[0].property == body["property"][0]["property"]
await client.collections_model.put(body)

resp = await client.collections_model.get()
assert resp.property[1].property == resp["property"][1]["property"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ def test_nullable_float_value(client: DictionaryClient):
client.nullable_float_value.put(value)


def test_recursive_model_value(client: DictionaryClient):
value = {
"k1": models.InnerModel(property="hello", children={}),
"k2": models.InnerModel(property="world", children={"k2.1": models.InnerModel(property="inner world")}),
}
assert client.recursive_model_value.get() == value
client.recursive_model_value.put(value)


def test_string_value(client: DictionaryClient):
value = {"k1": "hello", "k2": ""}
assert client.string_value.get() == value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,6 @@ def client():
yield client


def test_model_deserialization(client: ValueTypesClient):
body = models.ModelProperty(property={"property": "hello"})
assert body.property.property == body["property"]["property"]
client.model.put(body)

resp = client.model.get()
assert resp.property.property == resp["property"]["property"]

body = models.CollectionsModelProperty(property=[{"property": "hello"}, {"property": "world"}])
assert body.property[0].property == body["property"][0]["property"]
resp = client.collections_model.get()
assert resp.property[1].property == resp["property"][1]["property"]


def test_enum_property():
for prop in ["ValueOne", models.FixedInnerEnum.VALUE_ONE]:
string_type = models.EnumProperty(property=prop)
assert isinstance(string_type.property, models.FixedInnerEnum)
assert isinstance(string_type["property"], str)


def test_boolean(client: ValueTypesClient):
body = models.BooleanProperty(property=True)
assert body.property == body["property"]
Expand Down Expand Up @@ -70,13 +49,17 @@ def test_bytes(client: ValueTypesClient):
def test_collections_int(client: ValueTypesClient):
body = models.CollectionsIntProperty(property=[1, 2])
assert body.property == body["property"]
client.collections_int.put(body)

resp = client.collections_int.get()
assert resp.property == resp["property"] == [1, 2]


def test_collections_model(client: ValueTypesClient):
body = models.CollectionsModelProperty(property=[{"property": "hello"}, {"property": "world"}])
assert body.property[0].property == body["property"][0]["property"]
client.collections_model.put(body)

resp = client.collections_model.get()
assert resp.property[1].property == resp["property"][1]["property"]

Expand Down
Loading