root/branches/mk/tests/unit/test_cheese_files.py

Revision 74, 2.0 kB (checked in by mk, 6 years ago)

Improved scores for documentation and installability indices.
Fixed handling of duplicates in IndexRequiredFiles?.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1
2 from _mockup_cheesecake import MockupCheesecakeTest
3
4
5 def readlines_from_file(filename):
6     fd = open(filename)
7     lines = fd.readlines()
8     fd.close()
9     return lines
10
11
12 def cheesefile_in_log(filename, loglines):
13     return "entry found: %s" % filename in loglines
14
15
16 class CheeseFilesTest(MockupCheesecakeTest):
17     def _do_it(self, files, create_files, inside_log):
18         create_files(self.prefix_with_package_name(files))
19         self.cheesecake.walk_pkg()
20         self.cheesecake.compute_cheesecake_index()
21
22         loglines = ''.join(readlines_from_file(self._mock_logfile))
23
24         for filename in files:
25             print "Checking if %s was counted..." % filename
26             assert cheesefile_in_log(filename, loglines) is inside_log
27
28 class TestBogusCheeseFiles(CheeseFilesTest):
29     def test_bogus_filenames(self):
30         bogus_filenames = ['ReAdMe',
31                            'install.txt.txt',
32                            'setupXpy',
33                            'newsXtxt',
34                            'todoGARBAGE',
35                            'setup.py.txt']
36         self._do_it(bogus_filenames, self.create_files, False)
37
38 class TestGoodCheeseFiles(CheeseFilesTest):
39     def test_good_filenames(self):
40         good_filenames = ['Readme', 'INSTALL.txt', 'setup.py', 'news.TXT']
41         self._do_it(good_filenames, self.create_files, True)
42
43 class TestEmptyCheeseFiles(CheeseFilesTest):
44     def test_empty_filenames(self):
45         empty_filenames = ['Readme', 'INSTALL', 'setup.py']
46         self._do_it(empty_filenames, self.create_empty_files, False)
47
48
49 class TestDoubleFiles(MockupCheesecakeTest):
50     def test_double_files(self):
51         filenames = ['Readme', 'README.txt']
52
53         self.create_files(self.prefix_with_package_name(filenames))
54         self.cheesecake.walk_pkg()
55         self.cheesecake.compute_cheesecake_index()
56
57         loglines = ''.join(readlines_from_file(self._mock_logfile))
58
59         # Make sure that README was counted only once.
60         assert cheesefile_in_log('Readme', loglines)
61         assert not cheesefile_in_log('README.txt', loglines)
Note: See TracBrowser for help on using the browser.