summary refs log tree commit diff stats
Commit message (Expand)AuthorAgeFilesLines
...
* fixed minor logical errorhut2009-12-241-1/+1
* random fixeshut2009-12-244-17/+29
* fixed G keyhut2009-12-241-1/+1
* in keys.py: from curses import *hut2009-12-241-3/+1
* fixed directory.load_content_if_outdated with linkshut2009-12-241-1/+1
* misc clean upshut2009-12-243-21/+27
* implemented sortinghut2009-12-246-6/+57
* minor fixhut2009-12-241-1/+4
* added hints for key-combinationshut2009-12-248-17/+95
* own history for quickopen-consolehut2009-12-231-1/+6
* fixed marking (again)hut2009-12-232-11/+7
* improved keys.pyhut2009-12-231-20/+23
* max_dirsize_for_autopreview = 300 is not rly needed anymorehut2009-12-231-1/+1
* optimized directory loadinghut2009-12-232-8/+12
* improved loader performance with win.nodelay()hut2009-12-232-7/+7
* fixed throbberhut2009-12-233-6/+21
* fixed marking :)hut2009-12-232-6/+7
* implemented marking, for operations on multiple fileshut2009-12-239-37/+172
* handled exception found in the unit testshut2009-12-231-1/+4
* keybuffer was made aware of prefixed numbershut2009-12-235-19/+92
* added action.move_pointer_by_percentage()hut2009-12-231-0/+10
* added primitive "throbber"hut2009-12-232-0/+5
* fixed / improved loaderhut2009-12-236-25/+42
* some clean upshut2009-12-225-7/+11
* slightly improved get_permission_string() algorithmhut2009-12-221-9/+10
* (half-assed) implementation of parallel directory loaderhut2009-12-227-73/+165
* improved auto-previewshut2009-12-229-41/+84
* "open with" dialog if no application was foundhut2009-12-221-2/+4
* fixed cut/paste for the case where nothing is copied yethut2009-12-202-0/+4
* improved titlebar, shrinks if its too largehut2009-12-201-20/+169
* Added option for autoloading previews.hut2009-12-203-7/+13
* postpone directory previews if not loaded yethut2009-12-202-3/+19
* fixed CTRL+Lhut2009-12-181-2/+2
* improved the file operationshut2009-12-181-10/+31
* notification widgethut2009-12-185-7/+110
* UI.redraw now redraws widgets. old redraw is now redraw_windowhut2009-12-183-5/+9
* added provisional filesystem operations (cp/cut/paste/delete/mkdir)hut2009-12-185-10/+103
* re-indented docstringshut2009-12-1713-57/+75
* added quick_open() in abstract Command classhut2009-12-171-0/+3
* quit command, aliaseshut2009-12-172-10/+23
* fixed colorschemes, added unittest for colorschemeshut2009-12-172-3/+34
* fixed history (fast_forward worked reversed)hut2009-12-171-3/+3
* added history to consolehut2009-12-172-16/+47
* extended history by a couple of methodshut2009-12-172-10/+33
* tons of stuffhut2009-12-178-38/+146
* fixed CD command / tab completionhut2009-12-153-49/+48
* Added console commands + tab completionhut2009-12-155-10/+180
* fine tuninghut2009-12-152-98/+107
* turned different console types into seperate subclasseshut2009-12-151-36/+46
* changed default key binding implementationhut2009-12-152-89/+79
itter hut <hut@lavabit.com> 2009-11-24 00:41:16 +0100 better implementation of directories/files' href='/akspecs/ranger/commit/test/tc_directory.py?h=v1.9.0b4&id=fae694a03ebb52888a747010fcb92fa43b33b4a8'>fae694a0 ^
fae694a0 ^
1159f9ec ^



fe179145 ^
5822dff7 ^
9506fb8e ^
fae694a0 ^
fe179145 ^
fae694a0 ^
fe179145 ^

fae694a0 ^

fe179145 ^
fae694a0 ^
9506fb8e ^

f6f26231 ^
4c05e43d ^
f6f26231 ^







9506fb8e ^
fae694a0 ^

f6f26231 ^










4c05e43d ^

fae694a0 ^

fe179145 ^
5822dff7 ^

fe179145 ^
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
101
102
103
                                                            
 

                                           
                           

                                               


                                                
 

                                                      
                                              
 
               
                               
                                         
                                                          
                                        

                                                   

                                                     
                                                 
                                                                  
 
                                            
                         
                                                                                
                                        
                                  

                                           
                                                           
 


                                                                                       

                                                                                    

                                        

                                             




                                                                                 
                                      
                                
                                                 



                                                                                       
 
                                       
                                                
                                  
                
                                                   

                                                

                                                                  
 
                                        

                           
                                                                                 
                                                                                         







                                                        
                                        

                          










                                                                             

                                                                                                      

                                                       
 

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

from os.path import realpath, join, dirname

from ranger import fsobject
from ranger.fsobject.file import File
from ranger.fsobject.directory import Directory
from ranger.shared.settings import SettingsAware

SettingsAware._setup()

TESTDIR = realpath(join(dirname(__file__), 'testdir'))
TESTFILE = join(TESTDIR, 'testfile5234148')
NONEXISTANT_DIR = join(TESTDIR, 'nonexistant')

import unittest
class Test1(unittest.TestCase):
	def test_initial_condition(self):
		# Check for the expected initial condition
		dir = Directory(TESTDIR)

		self.assertEqual(dir.path, TESTDIR)
		self.assertFalse(dir.content_loaded)
		self.assertEqual(dir.filenames, None)
		self.assertEqual(dir.files, None)
		self.assertRaises(fsobject.NotLoadedYet, len, dir)

	def test_after_content_loaded(self):
		import os
		# Check whether the directory has the correct list of filenames.
		dir = Directory(TESTDIR)
		dir.load_content()

		self.assertTrue(dir.exists)
		self.assertEqual(type(dir.filenames), list)

		# Get the filenames you expect it to have and sort both before
		# comparing. I don't expect any order after only loading the filenames.
		assumed_filenames = os.listdir(TESTDIR)
		assumed_filenames = list(map(lambda str: os.path.join(TESTDIR, str),
			assumed_filenames))
		assumed_filenames.sort()
		dir.filenames.sort()

		self.assertTrue(len(dir) > 0)
		self.assertEqual(dir.filenames, assumed_filenames)

		# build a file object for each file in the list assumed_filenames
		# and find exactly one equivalent in dir.files
		for name in assumed_filenames:
			f = File(name)
			f.load()
			for dirfile in dir.files:
				if (f.path == dirfile.path and f.stat == dirfile.stat):
					break
			else:
				self.fail("couldn't find file {0}".format(name))

	def test_nonexistant_dir(self):
		dir = Directory(NONEXISTANT_DIR)
		dir.load_content()
		
		self.assertTrue(dir.content_loaded)
		self.assertFalse(dir.exists)
		self.assertFalse(dir.accessible)
		self.assertEqual(dir.filenames, None)
		self.assertRaises(fsobject.NotLoadedYet, len, dir)

	def test_load_if_outdated(self):
		import os
		import time
		# modify the directory. If the time between the last modification
		# was within the filesystems resolution of mtime, we should have a reload

		def modify_dir():
			open(TESTFILE, 'w').close()
			os.unlink(TESTFILE)

		def mtime():
			return os.stat(TESTDIR).st_mtime

		dir = Directory(TESTDIR)
		dir.load()

		# If the modification happens to be in the same second as the
		# last modification, it will result in mtime having the same
		# integer value. So we wait until the resolution is exceeded
		# and mtime differs.
		old_mtime = mtime()
		for i in range(50):
			modify_dir()
			if old_mtime != mtime(): break
			time.sleep(0.1)
		else:
			# fail after 5 seconds of trying
			self.fail(
					"Cannot perform test: mtime of TESTDIR is not being updated.")

		self.assertTrue(dir.load_if_outdated())

if __name__ == '__main__':
	unittest.main()