Skip to content

[Bug] test: restore strict assertion for backend_metrics in test_metric.py #326

@Muawiya-contact

Description

@Muawiya-contact

Bug Type (问题类型)

None

Before submit

  • I had searched in the issues and found no similar issues.

Environment (环境信息)

Environment

Item Detail
HugeGraph Server 1.7.0
Module python-client
File hugegraph-python-client/src/tests/test_metric.py

Expected & Actual behavior (期望与实际表现)


Expected & Actual Behavior

Problem

test_metrics_operations (L78–79) contains an if "hugegraph" in backend_metrics: guard that effectively no-ops the backend metrics assertion when running against HugeGraph 1.7.0.

This means shape drift in the API response goes completely undetected — the test passes silently even if the backend metrics structure changes.

Expected

The test should pin the actual 1.7.0 response shape and assert against it deterministically. Any deviation from the known shape should surface as a test failure.

Actual

The guard short-circuits the assertion. On HugeGraph 1.7.0, the block inside the if is never entered, so the backend metrics structure is never validated.


Suggested Fix

  1. Document the actual backend_metrics response shape returned by HugeGraph 1.7.0.
  2. Replace the open-ended guard with a version-gated deterministic assertion — e.g.:
# Before (no-op guard)
if "hugegraph" in backend_metrics:
    assert ...

# After (strict, version-aware assertion)
assert "hugegraph" in backend_metrics, (
    f"Expected 'hugegraph' key in backend_metrics, got: {list(backend_metrics.keys())}"
)
assert backend_metrics["hugegraph"] == EXPECTED_SHAPE_1_7_0

Vertex/Edge example (问题点 / 边数据举例)

Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions