mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
repro: move code around (#9701)
emphasizing on building the graph correctly, and preparing for being able to work with graph directly.
This commit is contained in:
@@ -2,7 +2,7 @@ import pytest
|
||||
from networkx import DiGraph
|
||||
from networkx.utils import graphs_equal
|
||||
|
||||
from dvc.repo.graph import get_steps, get_subgraph_of_nodes
|
||||
from dvc.repo.graph import get_subgraph_of_nodes
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -36,34 +36,3 @@ def test_subgraph_of_nodes(nodes, downstream, expected_edges):
|
||||
subgraph = get_subgraph_of_nodes(graph, nodes, downstream=downstream)
|
||||
expected = DiGraph(expected_edges)
|
||||
assert graphs_equal(expected, subgraph)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"nodes,downstream,expected_steps",
|
||||
[
|
||||
([], False, [4, 5, 2, 6, 7, 3, 1, 9, 8]),
|
||||
([1], False, [4, 5, 2, 6, 7, 3, 1]),
|
||||
([2], False, [4, 5, 2]),
|
||||
([3], False, [6, 7, 3]),
|
||||
([8], False, [9, 8]),
|
||||
([2, 3, 8], False, [4, 5, 2, 6, 7, 3, 9, 8]),
|
||||
([4], False, [4]),
|
||||
([], True, [4, 5, 2, 6, 7, 3, 1, 9, 8]),
|
||||
([1], True, [1]),
|
||||
([9], True, [9, 8]),
|
||||
([2], True, [2, 1]),
|
||||
([6], True, [6, 3, 1]),
|
||||
([2, 3, 8], True, [8, 2, 3, 1]),
|
||||
([4, 7], True, [4, 2, 7, 3, 1]),
|
||||
],
|
||||
)
|
||||
def test_steps(nodes, downstream, expected_steps):
|
||||
r"""
|
||||
1
|
||||
/ \
|
||||
2 3 8
|
||||
/ \ / \ |
|
||||
4 5 6 7 9
|
||||
"""
|
||||
graph = DiGraph({1: [2, 3], 2: [4, 5], 3: [6, 7], 8: [9]})
|
||||
assert get_steps(graph, nodes, downstream=downstream) == expected_steps
|
||||
|
||||
Reference in New Issue
Block a user