summary refs log tree commit diff stats
path: root/go.mod
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-05-19 03:02:35 -0400
committerBen Morrison <ben@gbmor.dev>2019-05-19 03:02:35 -0400
commit0f645e7fa9187eadbbbf12941e2902cbb8b6af41 (patch)
tree089d2b13ac11b8dfe3eb8cf0e200aaa5337dab5e /go.mod
parent1d0042985faf96f3afd9c26fadc719777cb681c3 (diff)
downloadgetwtxt-0f645e7fa9187eadbbbf12941e2902cbb8b6af41.tar.gz
updated template and adjusted styling
Diffstat (limited to 'go.mod')
0 files changed, 0 insertions, 0 deletions
list.py?h=v1.4.1&id=ccd3f3c3f8baccf700f7f5286d33156a6938edfe'>ccd3f3c3 ^
0654d6d0 ^
ccd3f3c3 ^


0bc410c5 ^
11ff42af ^
d8ea8d5f ^
0bc410c5 ^
11ff42af ^

0bc410c5 ^



11ff42af ^
0bc410c5 ^
11ff42af ^
d8ea8d5f ^
0bc410c5 ^

11ff42af ^
d8ea8d5f ^
0bc410c5 ^
698ba46a ^








ccd3f3c3 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100














                                                                       











                                                                 
                                    































                                                         




                                                                          

                                              
                                                            


                                                         
                                                       
                                      
                                  
 

                                                                      



                                     
                                                                      
 
                               
                                  

                                                          
                                             
 
                                                       








                                               
                                 
# Copyright (C) 2009, 2010  Roman Zimbelmann <romanz@lavabit.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

if __name__ == '__main__': from __init__ import init; init()

from unittest import TestCase, main
from ranger.container.commandlist import CommandList as CL

class Test(TestCase):
	def assertKeyError(self, obj, key):
		self.assertRaises(KeyError, obj.__getitem__, key)

	def test_commandist(self):
		cl = CL()
		fnc = lambda arg: 1
		fnc2 = lambda arg: 2
		dmy = cl.dummy_object

		cl.bind(fnc, 'aaaa')
		cl.rebuild_paths()

		self.assertEqual(dmy, cl['a'])
		self.assertEqual(dmy, cl['aa'])
		self.assertEqual(dmy, cl['aaa'])
		self.assertEqual(fnc, cl['aaaa'].execute)
		self.assertKeyError(cl, 'aabb')
		self.assertKeyError(cl, 'aaaaa')

		cl.bind(fnc, 'aabb')
		cl.rebuild_paths()

		self.assertEqual(dmy, cl['a'])
		self.assertEqual(dmy, cl['aa'])
		self.assertEqual(dmy, cl['aab'])
		self.assertEqual(fnc, cl['aabb'].execute)
		self.assertEqual(dmy, cl['aaa'])
		self.assertEqual(fnc, cl['aaaa'].execute)

		cl.unbind('aabb')
		cl.rebuild_paths()

		self.assertEqual(dmy, cl['a'])
		self.assertEqual(dmy, cl['aa'])
		self.assertKeyError(cl, 'aabb')
		self.assertKeyError(cl, 'aab')
		self.assertEqual(dmy, cl['aaa'])
		self.assertEqual(fnc, cl['aaaa'].execute)

		# Hints work different now.  Since a rework of this system
		# is planned anyway, there is no need to fix the test.
		# hint_text = 'some tip blablablba'
		# cl.hint(hint_text, 'aa')
		# cl.rebuild_paths()

		self.assertEqual(dmy, cl['a'])
		# self.assertEqual(hint_text, cl['aa'].text)
		self.assertEqual(dmy, cl['aaa'])
		self.assertEqual(fnc, cl['aaaa'].execute)

		# ------------------------ test aliases
		cl.alias('aaaa', 'cc')
		cl.rebuild_paths()

		self.assertEqual(dmy, cl['c'])
		self.assertEqual(cl['cc'].execute, cl['aaaa'].execute)

		cl.bind(fnc2, 'aaaa')
		cl.rebuild_paths()

		self.assertEqual(cl['cc'].execute, cl['aaaa'].execute)

		cl.unbind('cc')
		cl.rebuild_paths()

		self.assertEqual(fnc2, cl['aaaa'].execute)
		self.assertKeyError(cl, 'cc')

		# ----------------------- test clearing
		cl.clear()
		self.assertKeyError(cl, 'a')
		self.assertKeyError(cl, 'aa')
		self.assertKeyError(cl, 'aaa')
		self.assertKeyError(cl, 'aaaa')
		self.assertKeyError(cl, 'aab')
		self.assertKeyError(cl, 'aabb')


if __name__ == '__main__': main()