|
25 | 25 |
|
26 | 26 | class TabCompletionTest(testutils.BaseTestCase): |
27 | 27 |
|
28 | | - def testCompletionScript(self): |
29 | | - # A sanity check test to make sure the completion script satisfies some |
30 | | - # basic assumptions. |
| 28 | + def testCompletionBashScript(self): |
| 29 | + # A sanity check test to make sure the bash completion script satisfies |
| 30 | + # some basic assumptions. |
31 | 31 | commands = [ |
32 | 32 | ['run'], |
33 | 33 | ['halt'], |
34 | 34 | ['halt', '--now'], |
35 | 35 | ] |
36 | | - script = completion._Script(name='command', commands=commands) # pylint: disable=protected-access |
| 36 | + script = completion._BashScript(name='command', commands=commands) # pylint: disable=protected-access |
37 | 37 | self.assertIn('command', script) |
38 | 38 | self.assertIn('halt', script) |
39 | 39 | self.assertIn('"$start" == "command"', script) |
40 | 40 |
|
| 41 | + def testCompletionFishScript(self): |
| 42 | + # A sanity check test to make sure the fish completion script satisfies |
| 43 | + # some basic assumptions. |
| 44 | + commands = [ |
| 45 | + ['run'], |
| 46 | + ['halt'], |
| 47 | + ['halt', '--now'], |
| 48 | + ] |
| 49 | + script = completion._FishScript(name='command', commands=commands) # pylint: disable=protected-access |
| 50 | + self.assertIn('command', script) |
| 51 | + self.assertIn('halt', script) |
| 52 | + self.assertIn('-l now', script) |
| 53 | + |
41 | 54 | def testFnCompletions(self): |
42 | 55 | def example(one, two, three): |
43 | 56 | return one, two, three |
@@ -113,6 +126,29 @@ def testClassScript(self): |
113 | 126 | self.assertIn('--alpha', script) |
114 | 127 | self.assertIn('--beta', script) |
115 | 128 |
|
| 129 | + def testDeepDictFishScript(self): |
| 130 | + deepdict = {'level1': {'level2': {'level3': {'level4': {}}}}} |
| 131 | + script = completion.Script('deepdict', deepdict, shell='fish') |
| 132 | + self.assertIn('level1', script) |
| 133 | + self.assertIn('level2', script) |
| 134 | + self.assertIn('level3', script) |
| 135 | + self.assertNotIn('level4', script) # The default depth is 3. |
| 136 | + |
| 137 | + def testFnFishScript(self): |
| 138 | + script = completion.Script('identity', tc.identity, shell='fish') |
| 139 | + self.assertIn('arg1', script) |
| 140 | + self.assertIn('arg2', script) |
| 141 | + self.assertIn('arg3', script) |
| 142 | + self.assertIn('arg4', script) |
| 143 | + |
| 144 | + def testClassFishScript(self): |
| 145 | + script = completion.Script('', tc.MixedDefaults, shell='fish') |
| 146 | + self.assertIn('ten', script) |
| 147 | + self.assertIn('sum', script) |
| 148 | + self.assertIn('identity', script) |
| 149 | + self.assertIn('alpha', script) |
| 150 | + self.assertIn('beta', script) |
| 151 | + |
116 | 152 | def testNonStringDictCompletions(self): |
117 | 153 | completions = completion.Completions({ |
118 | 154 | 10: 'green', |
|
0 commit comments