]>
gitweb.michael.orlitzky.com - dead/census-tools.git/blob - src/Tests/Unit/FileUtilsTest.py
7 class FindFilePathsTest(unittest
.TestCase
):
9 def testPostgisFixturesFound(self
):
11 There are two dummy files in the fixtures directory,
12 lwpostgis.sql and postgis.sql. They have been placed in two
13 subfolders named after two distros who include the SQL file with
16 If we search a distro subdirectory for *both* names, we should
17 get back only one result: the correct one to use on that
20 gentoo_fixtures_path
= Tests
.Fixtures
.Path() + '/FileUtils/gentoo'
21 ubuntu_fixtures_path
= Tests
.Fixtures
.Path() + '/FileUtils/ubuntu'
23 target_files
= ['lwpostgis.sql', 'postgis.sql']
25 res
= FileUtils
.find_file_paths(gentoo_fixtures_path
, target_files
)
26 self
.assertTrue(len(res
) == 1)
27 self
.assertTrue('postgis.sql' in res
[0])
29 res
= FileUtils
.find_file_paths(ubuntu_fixtures_path
, target_files
)
31 self
.assertTrue(len(res
) == 1)
32 self
.assertTrue('lwpostgis.sql' in res
[0])
35 def testBothFixturesFoundFromRoot(self
):
37 If we search for the (lw)postgis.sql files from the fixtures
38 root, we should find both of them.
40 fixtures_path
= Tests
.Fixtures
.Path() + '/FileUtils'
42 target_files
= ['lwpostgis.sql', 'postgis.sql']
44 res
= FileUtils
.find_file_paths(fixtures_path
, target_files
)
45 self
.assertTrue(len(res
) == 2)
46 # "gentoo" comes first alphabetically, and so we'll traverse
47 # it first. Thus, postgis.sql should be found before
49 self
.assertTrue('postgis.sql' in res
[0])
50 self
.assertTrue('lwpostgis.sql' in res
[1])
53 def testOnlyOneResultReturnedWhenReturnFirstTrue(self
):
55 Make sure that, in a case where we would normally get two
56 results back, the usage of return_first causes us to receive
59 fixtures_path
= Tests
.Fixtures
.Path() + '/FileUtils'
61 target_files
= ['lwpostgis.sql', 'postgis.sql']
63 res
= FileUtils
.find_file_paths(fixtures_path
, target_files
, True)
64 self
.assertTrue(len(res
) == 1)
65 # Again, "gentoo" comes before "ubuntu" alphabetically, so
66 # this is the expected result.
67 self
.assertTrue('postgis.sql' in res
[0])
71 suite
= unittest
.TestSuite()
72 suite
.addTest(unittest
.makeSuite(FindFilePathsTest
))