1
1
import unittest
2
2
3
- from contextshell .TreeRoot import TreeRoot , ActionArgsPack , OrderedDict , pack_argument_tree
3
+ from contextshell .ActionExecutor import ActionExecutor , ActionArgsPack , OrderedDict , pack_argument_tree
4
4
from contextshell .NodePath import NodePath
5
5
6
6
@@ -13,7 +13,7 @@ def np(representation):
13
13
return NodePath (representation )
14
14
15
15
16
- class FakeTreeRoot ( TreeRoot ):
16
+ class FakeActionExecutor ( ActionExecutor ):
17
17
def __init__ (self ):
18
18
self .execute_target = None
19
19
self .execute_action = None
@@ -30,14 +30,14 @@ def execute(self, target: NodePath, action: NodePath, args: ActionArgsPack = Non
30
30
class MountTests (unittest .TestCase ):
31
31
def test_relative_target (self ):
32
32
vt = create_virtual_tree ()
33
- tree_root = FakeTreeRoot ()
33
+ tree_root = FakeActionExecutor ()
34
34
35
35
with self .assertRaises (ValueError ):
36
36
vt .mount (np ("foo" ), tree_root )
37
37
38
38
def test_mount_visible_in_mapping (self ):
39
39
vt = create_virtual_tree ()
40
- tree_root = FakeTreeRoot ()
40
+ tree_root = FakeActionExecutor ()
41
41
42
42
vt .mount (np ("." ), tree_root )
43
43
@@ -46,14 +46,14 @@ def test_mount_visible_in_mapping(self):
46
46
def test_mount_on_same_path (self ):
47
47
vt = create_virtual_tree ()
48
48
mount_path = np ("." )
49
- vt .mount (mount_path , FakeTreeRoot ())
49
+ vt .mount (mount_path , FakeActionExecutor ())
50
50
51
51
with self .assertRaises (KeyError ):
52
- vt .mount (mount_path , FakeTreeRoot ())
52
+ vt .mount (mount_path , FakeActionExecutor ())
53
53
54
54
def test_umount_removes_mapping (self ):
55
55
vt = create_virtual_tree ()
56
- vt .mount (np ("." ), FakeTreeRoot ())
56
+ vt .mount (np ("." ), FakeActionExecutor ())
57
57
58
58
vt .umount (np ("." ))
59
59
@@ -63,22 +63,22 @@ def test_umount_removes_mapping(self):
63
63
class ExecuteTests (unittest .TestCase ):
64
64
def test_relative_target (self ):
65
65
vt = create_virtual_tree ()
66
- vt .mount (np ("." ), FakeTreeRoot ())
66
+ vt .mount (np ("." ), FakeActionExecutor ())
67
67
68
68
with self .assertRaises (ValueError ):
69
69
vt .execute (np ("foo" ), np ("action" ))
70
70
71
71
def test_no_matching_provider (self ):
72
72
vt = create_virtual_tree ()
73
- vt .mount (np (".foo" ), FakeTreeRoot ())
73
+ vt .mount (np (".foo" ), FakeActionExecutor ())
74
74
75
75
with self .assertRaises (RuntimeError ):
76
76
vt .execute (np (".bar" ), np ("action" ))
77
77
78
78
def test_target_remapping (self ):
79
79
"""Target path is remapped to match provider's root"""
80
80
vt = create_virtual_tree ()
81
- tree_root = FakeTreeRoot ()
81
+ tree_root = FakeActionExecutor ()
82
82
vt .mount (np (".foo" ), tree_root )
83
83
84
84
vt .execute (np (".foo.bar" ), np ("action" ))
@@ -87,7 +87,7 @@ def test_target_remapping(self):
87
87
88
88
def test_action_forwarding (self ):
89
89
vt = create_virtual_tree ()
90
- tree_root = FakeTreeRoot ()
90
+ tree_root = FakeActionExecutor ()
91
91
vt .mount (np ("." ), tree_root )
92
92
93
93
vt .execute (np ("." ), np ("action" ))
@@ -96,7 +96,7 @@ def test_action_forwarding(self):
96
96
97
97
def test_args_forwarding (self ):
98
98
vt = create_virtual_tree ()
99
- tree_root = FakeTreeRoot ()
99
+ tree_root = FakeActionExecutor ()
100
100
vt .mount (np ("." ), tree_root )
101
101
packed_args = pack_argument_tree ('foo' , 123 )
102
102
@@ -106,7 +106,7 @@ def test_args_forwarding(self):
106
106
107
107
def test_return_value_forwarding (self ):
108
108
vt = create_virtual_tree ()
109
- tree_root = FakeTreeRoot ()
109
+ tree_root = FakeActionExecutor ()
110
110
tree_root .execute_return = 'RETURN_VALUE'
111
111
vt .mount (np ("." ), tree_root )
112
112
@@ -116,8 +116,8 @@ def test_return_value_forwarding(self):
116
116
117
117
def test_most_specific_provider_is_matched (self ):
118
118
vt = create_virtual_tree ()
119
- short_path_root = FakeTreeRoot ()
120
- long_path_root = FakeTreeRoot ()
119
+ short_path_root = FakeActionExecutor ()
120
+ long_path_root = FakeActionExecutor ()
121
121
vt .mount (np (".foo" ), short_path_root )
122
122
vt .mount (np (".foo.bar" ), long_path_root )
123
123
0 commit comments