about summary refs log tree commit diff stats
path: root/html/subx/apps/crenshaw2-1.subx.html
Commit message (Expand)AuthorAgeFilesLines
* 4847Kartik Agaram2018-12-061-4/+4
* 4844Kartik Agaram2018-12-061-2/+2
* 4840Kartik Agaram2018-12-041-1/+1
* 4837Kartik Agaram2018-12-041-1/+1
* 4832Kartik Agaram2018-12-041-409/+413
* 4826Kartik Agaram2018-12-031-1/+1
* 4821Kartik Agaram2018-12-021-107/+66
* 4819Kartik Agaram2018-12-021-1/+1
* 4818Kartik Agaram2018-12-021-547/+548
* 4816Kartik Agaram2018-12-021-14/+17
* 4815Kartik Agaram2018-12-021-599/+604
* 4814Kartik Agaram2018-12-011-0/+1
* 4813Kartik Agaram2018-12-011-2/+2
* 4811Kartik Agaram2018-11-301-14/+14
* 4809 - subx: html with 5 colors for commentsKartik Agaram2018-11-301-642/+645
* 4797Kartik Agaram2018-11-301-1/+1
* 4796Kartik Agaram2018-11-301-441/+440
* 4782Kartik Agaram2018-11-261-81/+617
* 4734Kartik Agaram2018-10-281-88/+100
* 4722Kartik Agaram2018-10-241-8/+8
* 4709Kartik Agaram2018-10-171-115/+88
* 4649Kartik Agaram2018-10-021-126/+45
* 4512Kartik Agaram2018-09-231-105/+167
* 4588Kartik Agaram2018-09-221-0/+194
875f913ad'>^
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











                                                                 
                                    








































                                                          
                                                       
                                      
                                  
 

                                                                      



                                     
                                                                      
 
                               
                                  

                                                          
                                             
 
                                                       








                                               
                                 
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)

		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()