Skip to content

Commit

Permalink
tests: add set of string/json values
Browse files Browse the repository at this point in the history
  • Loading branch information
abn committed Jul 24, 2020
1 parent 6bbe544 commit a76fa56
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion tests/integration/test_integration_gnmi.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import json
import uuid

import gnmi.proto
import grpclib.client
import pytest

# noinspection SpellCheckingInspection
from tests.integration.validation import validate_default_interfaces_get
from tests.integration.validation import (
validate_default_interfaces_get,
validate_response_get,
)

pytestmark = [pytest.mark.asyncio, pytest.mark.integration]

Expand Down Expand Up @@ -36,3 +42,40 @@ async def test_integration_get(service):
)
assert isinstance(response, gnmi.proto.GetResponse)
validate_default_interfaces_get(response)


async def test_integration_update_set_string(service):
new_password = str(uuid.uuid4())
path = gnmi.proto.Path(
elem=[
gnmi.proto.PathElem(name="system"),
gnmi.proto.PathElem(name="aaa"),
gnmi.proto.PathElem(name="authentication"),
gnmi.proto.PathElem(name="admin-user"),
gnmi.proto.PathElem(name="config"),
gnmi.proto.PathElem(name="admin-password"),
],
)
update = gnmi.proto.Update(
path=path, val=gnmi.proto.TypedValue(string_val=new_password)
)
response = await service.set(update=[update],)
assert isinstance(response, gnmi.proto.SetResponse)

response = await service.get(path=path,)
validate_response_get(response=response, value=new_password)


async def test_integration_update_set_json(service):
config = {"config": {"timezone-name": "Europe/Berlin"}}
path = gnmi.proto.Path(
elem=[gnmi.proto.PathElem(name="system"), gnmi.proto.PathElem(name="clock")],
)
update = gnmi.proto.Update(
path=path, val=gnmi.proto.TypedValue(json_ietf_val=json.dumps(config).encode())
)
response = await service.set(update=[update],)
assert isinstance(response, gnmi.proto.SetResponse)

response = await service.get(path=path,)
validate_response_get(response=response, value=config)

0 comments on commit a76fa56

Please sign in to comment.