Skip to content

Commit

Permalink
add back extra missing tests (#2574)
Browse files Browse the repository at this point in the history
  • Loading branch information
iscai-msft committed May 6, 2024
1 parent 1d0a31a commit 3b31b69
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 44 deletions.
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

0 comments on commit 3b31b69

Please sign in to comment.