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
|
# Copyright (c) 2007-2008 Forest Bond.
# This file is part of the pytagsfs software package.
#
# pytagsfs is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License version 2 as published by the Free
# Software Foundation.
#
# A copy of the license has been included in the COPYING file.
from unittest import TestCase, main
from pytagsfs.exceptions import PathNotFound, NotADirectory
class _PathStoreTestCase(TestCase):
path_store_class = None
def _testNoFiles(self):
store = self.path_store_class()
# With no files, get_entries on root should always return an empty
# list:
self.assertEqual(store.get_entries('/'), [])
def _testPathMapping(self):
store = self.path_store_class()
store.put_file('/a/b/1', '/x/y/m')
self.assertEqual(store.get_real_path('/a/b/1'), '/x/y/m')
def _testCollision(self):
store = self.path_store_class()
store.put_file('/foo/bar', '/bim/bam')
self.assertEqual(store.get_real_path('/foo/bar'), '/bim/bam')
store.put_file('/foo/bar', '/biz/baz')
self.assertEqual(store.get_real_path('/foo/bar'), '/biz/baz')
store.delete_file('/foo/bar')
self.assertEqual(store.get_real_path('/foo/bar'), '/bim/bam')
def _testOrderOfEntries(self):
store = self.path_store_class()
store.put_file('/foo/bar', '/bim/bam')
store.put_file('/foo/angst', '/bim/boom')
self.assertEqual(store.get_entries('/foo'), ['bar', 'angst'])
def _testOrderOfEntriesWithCollision(self):
store = self.path_store_class()
store.put_file('/foo/bar', '/bim/bam')
store.put_file('/foo/angst', '/bim/boom')
self.assertEqual(store.get_entries('/foo'), ['bar', 'angst'])
store.put_file('/foo/bar', '/bim/bang')
self.assertEqual(store.get_entries('/foo'), ['angst', 'bar'])
store.delete_file('/foo/bar')
self.assertEqual(store.get_entries('/foo'), ['bar', 'angst'])
def _testOrderOfEntriesWithRename(self):
store = self.path_store_class()
store.put_file('/foo/bar', '/bim/bam')
store.put_file('/biz/baz', '/bim/boink')
store.put_file('/foo/angst', '/bim/boom')
store.put_file('/foo/clunk', '/bim/bang')
self.assertEqual(store.get_entries('/foo'), ['bar', 'angst', 'clunk'])
store.rename_file('/foo/bar', '/foo/point')
self.assertEqual(store.get_entries('/foo'), ['point', 'angst', 'clunk'])
if __name__ == '__main__':
main()
|