Skip to content

Commit

Permalink
Add some tests for a when clause based on an enum of names
Browse files Browse the repository at this point in the history
The new tests, test the handling of a when clause based on an
enum with string values. The code should translate the enum name string
into the internal database numeric value for the enum so the comparison
works.
  • Loading branch information
gcampbell512 authored and carlgsmith committed Oct 15, 2024
1 parent c3c1e9f commit 5422b5d
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,47 @@ def test_restconf_when_condition_false():
""")


def test_restconf_when_condition_translate_true():
tree = """
{
"cage": [
"box"
]
}
"""
response = requests.post("{}{}/data/test/animals/animal/cat/cages".format(server_uri, docroot),
auth=server_auth, headers=set_restconf_headers, data=tree)
assert response.status_code == 201
assert len(response.content) == 0
assert apteryx.get("/test/animals/animal/cat/cages/cage/box") == "box"


def test_restconf_when_condition_translate_false():
tree = """
{
"cage": [
"box"
]
}
"""
response = requests.post("{}{}/data/test/animals/animal/mouse/cages".format(server_uri, docroot),
auth=server_auth, headers=set_restconf_headers, data=tree)
assert response.status_code == 404
assert response.json() == json.loads("""
{
"ietf-restconf:errors" : {
"error" : [
{
"error-message": "uri path not found",
"error-type" : "application",
"error-tag" : "invalid-value"
}
]
}
}
""")


def test_restconf_must_condition_true():
data = """{"friend": "ben"}"""
response = requests.post("{}{}/data/test/animals/animal/dog".format(server_uri, docroot),
Expand Down

0 comments on commit 5422b5d

Please sign in to comment.