Skip to content

Commit

Permalink
chore: update pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
abn committed Nov 12, 2024
1 parent abf9702 commit af4504f
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 16 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 19.10b0
rev: 24.10.0
hooks:
- id: black
exclude: &exclude |
Expand All @@ -9,14 +9,14 @@ repos:
| ^src/gnmi/proto/_legacy/.*
)

- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3
- repo: https://github.com/pycqa/flake8
rev: 7.1.1
hooks:
- id: flake8
exclude: *exclude

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.1.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
exclude: *exclude
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ def service_unauthenticated(channel) -> gnmi.proto.gNMIStub:

@pytest.fixture
def service_legacy(target, channel_legacy) -> gnmi.proto.legacy.gNMIStub:
return gnmi.proto.legacy.gNMIStub(channel_legacy,)
return gnmi.proto.legacy.gNMIStub(
channel_legacy,
)


@pytest.fixture
Expand Down
25 changes: 19 additions & 6 deletions tests/integration/test_integration_gnmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@

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


@pytest.fixture
def get_request_interfaces() -> gnmi.proto.GetRequest:
return gnmi.proto.GetRequest(
path=[gnmi.proto.Path(elem=[gnmi.proto.PathElem(name="interfaces")])],
)


async def test_integration_permission_denied(service_unauthenticated, get_request_interfaces):
async def test_integration_permission_denied(
service_unauthenticated, get_request_interfaces
):
with pytest.raises(grpclib.exceptions.GRPCError) as e:
await service_unauthenticated.get(get_request_interfaces)

Expand Down Expand Up @@ -54,10 +57,14 @@ async def test_integration_update_set_string(service):
update = gnmi.proto.Update(
path=path, val=gnmi.proto.TypedValue(string_val=new_password)
)
response = await service.set(gnmi.proto.SetRequest(update=[update]),)
response = await service.set(
gnmi.proto.SetRequest(update=[update]),
)
assert isinstance(response, gnmi.proto.SetResponse)

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


Expand All @@ -67,10 +74,14 @@ async def test_integration_update_set_json(service):
update = gnmi.proto.Update(
path=path, val=gnmi.proto.TypedValue(json_ietf_val=json.dumps(config).encode())
)
response = await service.set(gnmi.proto.SetRequest(update=[update]),)
response = await service.set(
gnmi.proto.SetRequest(update=[update]),
)
assert isinstance(response, gnmi.proto.SetResponse)

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


Expand All @@ -79,5 +90,7 @@ async def test_integration_delete(service):

await service.set(gnmi.proto.SetRequest(delete=[path]))

response = await service.get(gnmi.proto.GetRequest(path=create_path("system/clock")),)
response = await service.get(
gnmi.proto.GetRequest(path=create_path("system/clock")),
)
validate_response_get(response=response, value={})
23 changes: 18 additions & 5 deletions tests/integration/test_integration_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ def test_integration_legacy_capabilities(service_legacy):

def test_integration__legacy_get(service_legacy, metadata_legacy):
response = service_legacy.Get(
gnmi.proto.legacy.GetRequest(path=[create_legacy_path("interfaces")],),
gnmi.proto.legacy.GetRequest(
path=[create_legacy_path("interfaces")],
),
metadata=metadata_legacy,
)

Expand All @@ -44,7 +46,10 @@ def _update(
metadata: List[Tuple[str, str]],
) -> gnmi.proto.legacy.SetResponse:
response = service_legacy.Set(
gnmi.proto.legacy.SetRequest(update=[update],), metadata=metadata,
gnmi.proto.legacy.SetRequest(
update=[update],
),
metadata=metadata,
)
assert isinstance(response, gnmi.proto.legacy.SetResponse)
return response
Expand All @@ -61,7 +66,10 @@ def test_integration_legacy_update_set_string(service_legacy, metadata_legacy):
_update(update, service_legacy, metadata_legacy)

response = service_legacy.Get(
gnmi.proto.legacy.GetRequest(path=[path],), metadata=metadata_legacy,
gnmi.proto.legacy.GetRequest(
path=[path],
),
metadata=metadata_legacy,
)
validate_response_get(response=response, value=new_password)

Expand All @@ -76,7 +84,10 @@ def test_integration_legacy_update_set_json(service_legacy, metadata_legacy):
_update(update, service_legacy, metadata_legacy)

response = service_legacy.Get(
gnmi.proto.legacy.GetRequest(path=[path],), metadata=metadata_legacy,
gnmi.proto.legacy.GetRequest(
path=[path],
),
metadata=metadata_legacy,
)
validate_response_get(response=response, value=config)

Expand All @@ -89,7 +100,9 @@ def test_integration_legacy_delete(service_legacy, metadata_legacy):
)

response = service_legacy.Get(
gnmi.proto.legacy.GetRequest(path=[create_legacy_path("system/clock")],),
gnmi.proto.legacy.GetRequest(
path=[create_legacy_path("system/clock")],
),
metadata=metadata_legacy,
)
validate_response_get(response=response, value={})

0 comments on commit af4504f

Please sign in to comment.