Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/alicevision/meshroom.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYann Lanthony <yann.lanthony@gmail.com>2018-01-11 19:30:26 +0300
committerYann Lanthony <yann.lanthony@gmail.com>2018-01-12 15:59:08 +0300
commit1bc6168814fd04fa5cc45d2e04ca48347213c251 (patch)
tree921f612ca9eaa34633b895466b00fd91bbfe6d18 /tests
parente391d76a82da8ff9d8d0a3da0b28a4bef1d9b308 (diff)
[graph] add helper methods to get nodes by type and sort them by name
Diffstat (limited to 'tests')
-rw-r--r--tests/test_graph.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_graph.py b/tests/test_graph.py
index caa5bd81..cf4e07dd 100644
--- a/tests/test_graph.py
+++ b/tests/test_graph.py
@@ -186,3 +186,21 @@ def test_graph_reverse_dfs():
# Get all nodes from C (order guaranteed)
nodes = graph.nodesFromNode(C)[0]
assert nodes == [C, E, F]
+
+
+def test_graph_nodes_sorting():
+ graph = Graph('')
+
+ ls0 = graph.addNewNode('Ls')
+ ls1 = graph.addNewNode('Ls')
+ ls2 = graph.addNewNode('Ls')
+
+ assert graph.nodesByType('Ls', sortedByIndex=True) == [ls0, ls1, ls2]
+
+ graph = Graph('')
+ # 'Random' creation order (what happens when loading a file)
+ ls2 = graph.addNewNode('Ls', name='Ls_2')
+ ls0 = graph.addNewNode('Ls', name='Ls_0')
+ ls1 = graph.addNewNode('Ls', name='Ls_1')
+
+ assert graph.nodesByType('Ls', sortedByIndex=True) == [ls0, ls1, ls2]