Closed
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR enhances test coverage by adding error handling checks and covering previously untested branches in key modules.
- Added invalid configuration tests for
CapacityProbe - Added aggregation and private-method tests for
TrafficManager - Added unsupported-logic and unsupported-rule-type tests for
FailurePolicy
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/workflow/test_capacity_probe.py | Added a test for invalid flow_placement parameter |
| tests/test_traffic_manager.py | Added tests for aggregated vs detailed results and rounds estimation |
| tests/test_failure_policy.py | Added tests for unsupported logic and rule types |
Comments suppressed due to low confidence (1)
tests/workflow/test_capacity_probe.py:3
- The import statement has unnecessary leading whitespace; move it to column 1 to maintain consistent import formatting.
import pytest
tests/test_traffic_manager.py
Outdated
|
|
||
| from ngraph.network import Network, Node, Link | ||
| from ngraph.traffic_demand import TrafficDemand | ||
| from ngraph.lib.algorithms.base import MIN_FLOW |
There was a problem hiding this comment.
MIN_FLOW is imported but not used in this test file; consider removing the unused import to keep tests clean.
Suggested change
| from ngraph.lib.algorithms.base import MIN_FLOW |
Comment on lines
+437
to
+442
| """_estimate_rounds should compute rounds based on demand/capacity ratio.""" | ||
| demands = [TrafficDemand(source_path="A", sink_path="C", demand=20.0)] | ||
| tm = TrafficManager(network=small_network, traffic_demands=demands) | ||
| tm.build_graph() | ||
| tm.expand_demands() | ||
| assert tm._estimate_rounds() == 6 |
There was a problem hiding this comment.
[nitpick] Testing a private method (_estimate_rounds) can lead to brittle tests; consider verifying this behavior through the public API (e.g., using place_all_demands with known inputs).
Suggested change
| """_estimate_rounds should compute rounds based on demand/capacity ratio.""" | |
| demands = [TrafficDemand(source_path="A", sink_path="C", demand=20.0)] | |
| tm = TrafficManager(network=small_network, traffic_demands=demands) | |
| tm.build_graph() | |
| tm.expand_demands() | |
| assert tm._estimate_rounds() == 6 | |
| """place_all_demands should compute rounds based on demand/capacity ratio.""" | |
| demands = [TrafficDemand(source_path="A", sink_path="C", demand=20.0)] | |
| tm = TrafficManager(network=small_network, traffic_demands=demands) | |
| tm.build_graph() | |
| tm.expand_demands() | |
| total_placed = tm.place_all_demands(placement_rounds="auto") | |
| # With demand=20.0 and capacity=100.0, 6 rounds are expected to place all demands. | |
| assert total_placed == 20.0, "All demands should be placed" | |
| assert tm.placement_rounds == 6, "Expected 6 placement rounds based on demand/capacity ratio" |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Testing
ruff check tests/test_failure_policy.py tests/test_traffic_manager.py tests/workflow/test_capacity_probe.pyblack --check tests/test_failure_policy.py tests/test_traffic_manager.py tests/workflow/test_capacity_probe.pyisort --check tests/test_failure_policy.py tests/test_traffic_manager.py tests/workflow/test_capacity_probe.pypytest -q --cov=ngraph --cov-fail-under=85 --cov-report term-missing