Skip to content

Commit

Permalink
Normalize all paths to be absolute; first try at persistent filemap
Browse files Browse the repository at this point in the history
  • Loading branch information
bitprophet committed Oct 15, 2010
1 parent f438fb2 commit 185eec9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
6 changes: 6 additions & 0 deletions tests/fake_filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ def write(self, value):


class FakeFilesystem(dict):
def __init__(self, d=None):
# Replicate input dictionary using our custom __setitem__
d = d or {}
for key, value in d.iteritems():
self[key] = value

def __setitem__(self, key, value):
if isinstance(value, StringTypes) or value is None:
value = FakeFile(value, key)
Expand Down
16 changes: 8 additions & 8 deletions tests/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@
tests"""
}
FILES = {
'file.txt': 'contents',
'file2.txt': 'contents2',
'folder/file3.txt': 'contents3',
'empty_folder': None,
'tree/file1.txt': 'x',
'tree/file2.txt': 'y',
'tree/subfolder/file3.txt': 'z',
'/file.txt': 'contents',
'/file2.txt': 'contents2',
'/folder/file3.txt': 'contents3',
'/empty_folder': None,
'/tree/file1.txt': 'x',
'/tree/file2.txt': 'y',
'/tree/subfolder/file3.txt': 'z',
'/etc/apache2/apache2.conf': 'Include other.conf'
}
PASSWORDS = {
Expand Down Expand Up @@ -209,7 +209,7 @@ def missing_folders(paths):
class FakeSFTPServer(ssh.SFTPServerInterface):
def __init__(self, server, *args, **kwargs):
self.server = server
files = copy.deepcopy(self.server.files)
files = self.server.files
# Expand such that omitted, implied folders get added explicitly
for folder in missing_folders(files.keys()):
files[folder] = None
Expand Down
4 changes: 2 additions & 2 deletions tests/test_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ def test_put_file_to_existing_directory(self):
local2 = self.path('foo2.txt')
with open(local, 'w') as fd:
fd.write("foo!")
put(local, '')
get('foo.txt', local2)
put(local, '/')
get('/foo.txt', local2)
eq_contents(local2, "foo!")


Expand Down

0 comments on commit 185eec9

Please sign in to comment.