root/branches/mk/tests/functional/test_options.py

Revision 129, 3.5 kB (checked in by mk, 6 years ago)

Implemented --keep-log command line option.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1
2 import os
3 import tempfile
4
5 from _helper_cheesecake import FunctionalTest, read_file_contents, NOSE_PATH, PACKAGE_PATH
6
7 from cheesecake.util import pad_msg
8 from cheesecake.cheesecake_index import IndexUnpack
9 from cheesecake.cheesecake_index import IndexUnpackDir
10 from cheesecake.cheesecake_index import IndexInstall
11 from cheesecake.cheesecake_index import IndexUrlDownload
12 from cheesecake.cheesecake_index import IndexPyPIDownload
13
14
15 class TestOptions(FunctionalTest):
16     def test_no_args(self):
17         self._run_cheesecake('')
18
19         assert self.return_code != 0
20
21         # Make sure that there's a reference to --help.
22         stdout = read_file_contents(self.stdout_name)
23         assert '--help' in stdout
24
25     def test_help(self):
26         self._run_cheesecake('--help')
27
28         self._assert_success()
29
30         # Make sure usage information has been shown.
31         stdout = read_file_contents(self.stdout_name)
32         assert 'usage:' in stdout
33
34     def test_name(self):
35         self._run_cheesecake('--name nose')
36
37         self._assert_success()
38
39         # Make sure that appropriate indices have been counted.
40         stdout = read_file_contents(self.stdout_name)
41         assert pad_msg('unpack', IndexUnpack.max_value) in stdout
42         assert pad_msg('install', IndexInstall.max_value) in stdout
43         # PyPI score can be lowered by penalties, so we don't include score check here.
44         assert 'py_pi_download' in stdout
45
46     def test_url(self):
47         self._run_cheesecake('--url http://www.agilistas.org/cheesecake/nose-0.8.3.tar.gz')
48
49         self._assert_success()
50
51         # Make sure that appropriate indices have been counted.
52         stdout = read_file_contents(self.stdout_name)
53         assert pad_msg('unpack', IndexUnpack.max_value) in stdout
54         assert pad_msg('unpack_dir', IndexUnpackDir.max_value) in stdout
55         assert pad_msg('install', IndexInstall.max_value) in stdout
56         assert pad_msg('url_download', IndexUrlDownload.max_value) in stdout
57
58     def test_path(self):
59         self._run_cheesecake('--path %s' % NOSE_PATH)
60
61         self._assert_success()
62
63         # Make sure that appropriate indices have been counted.
64         stdout = read_file_contents(self.stdout_name)
65         assert pad_msg('unpack', IndexUnpack.max_value) in stdout
66         assert pad_msg('unpack_dir', IndexUnpackDir.max_value) in stdout
67         assert pad_msg('install', IndexInstall.max_value) in stdout
68
69     def test_verbose(self):
70         self._run_cheesecake('--path %s' % PACKAGE_PATH)
71         normal = read_file_contents(self.stdout_name)
72         self._cleanup()
73
74         self._run_cheesecake('--path %s --verbose' % PACKAGE_PATH)
75         verbose = read_file_contents(self.stdout_name)
76
77         # Make sure that --verbose generates more information than default operation.
78         assert len(verbose) > len(normal)
79
80     def test_quiet(self):
81         self._run_cheesecake('--path %s' % PACKAGE_PATH)
82         normal = read_file_contents(self.stdout_name)
83         self._cleanup()
84
85         self._run_cheesecake('--path %s --quiet' % PACKAGE_PATH)
86         quiet = read_file_contents(self.stdout_name)
87
88         # Make sure that --quiet generates less information than default operation.
89         assert len(quiet) < len(normal)
90
91     def test_keep_log(self):
92         logfile = tempfile.mktemp(prefix='log')
93         self._run_cheesecake('--path %s --logfile %s --keep-log' % (NOSE_PATH, logfile))
94
95         self._assert_success()
96
97         # Make sure that log file was left.
98         assert os.path.exists(logfile)
99
100         # Delete the logfile now.
101         os.unlink(logfile)
Note: See TracBrowser for help on using the browser.