Revision b5b8309d test/ganeti.utils_unittest.py
b/test/ganeti.utils_unittest.py | ||
---|---|---|
1341 | 1341 |
def _test(self, files, expected): |
1342 | 1342 |
self._CreateFiles(files) |
1343 | 1343 |
found = ListVisibleFiles(self.path) |
1344 |
# by default ListVisibleFiles sorts its output |
|
1345 |
self.assertEqual(found, sorted(expected)) |
|
1344 |
self.assertEqual(set(found), set(expected)) |
|
1346 | 1345 |
|
1347 | 1346 |
def testAllVisible(self): |
1348 | 1347 |
files = ["a", "b", "c"] |
... | ... | |
1359 | 1358 |
expected = ["a", "b"] |
1360 | 1359 |
self._test(files, expected) |
1361 | 1360 |
|
1362 |
def testForceSort(self): |
|
1363 |
files = ["c", "b", "a"] |
|
1364 |
self._CreateFiles(files) |
|
1365 |
found = ListVisibleFiles(self.path, sort=True) |
|
1366 |
self.assertEqual(found, sorted(files)) |
|
1367 |
|
|
1368 |
def testForceNonSort(self): |
|
1369 |
files = ["c", "b", "a"] |
|
1370 |
self._CreateFiles(files) |
|
1371 |
found = ListVisibleFiles(self.path, sort=False) |
|
1372 |
# We can't actually check that they weren't sorted, because they might come |
|
1373 |
# out sorted by chance |
|
1374 |
self.assertEqual(set(found), set(files)) |
|
1375 |
|
|
1376 | 1361 |
def testNonAbsolutePath(self): |
1377 | 1362 |
self.failUnlessRaises(errors.ProgrammerError, ListVisibleFiles, "abc") |
1378 | 1363 |
|
Also available in: Unified diff