Merge lp:~dobey/ubuntu/natty/ubuntuone-dev-tools/devtools-012 into lp:ubuntu/natty/ubuntuone-dev-tools
- Natty (11.04)
- devtools-012
- Merge into natty
Proposed by
dobey
Status: | Merged |
---|---|
Merged at revision: | 3 |
Proposed branch: | lp:~dobey/ubuntu/natty/ubuntuone-dev-tools/devtools-012 |
Merge into: | lp:ubuntu/natty/ubuntuone-dev-tools |
Diff against target: |
1346 lines (+649/-290) 17 files modified
MANIFEST.in (+1/-1) PKG-INFO (+1/-1) bin/u1lint (+56/-49) bin/u1trial (+107/-55) debian/changelog (+11/-0) debian/control (+12/-6) debian/rules (+1/-1) debian/watch (+1/-1) pylintrc (+223/-36) run-tests (+23/-0) setup.py (+9/-9) ubuntuone/devtools/__init__.py (+0/-1) ubuntuone/devtools/dbus_util.py (+0/-89) ubuntuone/devtools/handlers.py (+64/-0) ubuntuone/devtools/services/__init__.py (+1/-0) ubuntuone/devtools/services/dbus.py (+94/-0) ubuntuone/devtools/testcase.py (+45/-41) |
To merge this branch: | bzr merge lp:~dobey/ubuntu/natty/ubuntuone-dev-tools/devtools-012 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel Holbach (community) | Approve | ||
Ubuntu branches | Pending | ||
Review via email: mp+42295@code.launchpad.net |
Commit message
Description of the change
* New upstream release.
* Fix debian/watch to use the right file extension.
* Remove python-oauth as a dependency.
* Update build and runtime dependencies.
* Require pep8 to run tests during build.
* Use ./run-tests during the build instead of setup.py lint to run tests.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'MANIFEST.in' | |||
2 | --- MANIFEST.in 2010-08-02 13:45:54 +0000 | |||
3 | +++ MANIFEST.in 2010-11-30 19:41:01 +0000 | |||
4 | @@ -1,4 +1,4 @@ | |||
5 | 1 | include MANIFEST.in | 1 | include MANIFEST.in |
7 | 2 | include COPYING pylintrc | 2 | include COPYING pylintrc run-tests |
8 | 3 | recursive-include data *.conf | 3 | recursive-include data *.conf |
9 | 4 | recursive-include man *.1 | 4 | recursive-include man *.1 |
10 | 5 | 5 | ||
11 | === modified file 'PKG-INFO' | |||
12 | --- PKG-INFO 2010-08-02 13:45:54 +0000 | |||
13 | +++ PKG-INFO 2010-11-30 19:41:01 +0000 | |||
14 | @@ -1,6 +1,6 @@ | |||
15 | 1 | Metadata-Version: 1.0 | 1 | Metadata-Version: 1.0 |
16 | 2 | Name: ubuntuone-dev-tools | 2 | Name: ubuntuone-dev-tools |
18 | 3 | Version: 0.1.1 | 3 | Version: 0.1.2 |
19 | 4 | Summary: Ubuntu One development tools and utilities | 4 | Summary: Ubuntu One development tools and utilities |
20 | 5 | Home-page: http://launchpad.net/ubuntuone-dev-tools | 5 | Home-page: http://launchpad.net/ubuntuone-dev-tools |
21 | 6 | Author: UNKNOWN | 6 | Author: UNKNOWN |
22 | 7 | 7 | ||
23 | === modified file 'bin/u1lint' | |||
24 | --- bin/u1lint 2010-08-02 13:45:54 +0000 | |||
25 | +++ bin/u1lint 2010-11-30 19:41:01 +0000 | |||
26 | @@ -6,18 +6,19 @@ | |||
27 | 6 | # | 6 | # |
28 | 7 | # Copyright 2009-2010 Canonical Ltd. | 7 | # Copyright 2009-2010 Canonical Ltd. |
29 | 8 | # | 8 | # |
32 | 9 | # This program is free software: you can redistribute it and/or modify it | 9 | # This program is free software: you can redistribute it and/or modify it |
33 | 10 | # under the terms of the GNU General Public License version 3, as published | 10 | # under the terms of the GNU General Public License version 3, as published |
34 | 11 | # by the Free Software Foundation. | 11 | # by the Free Software Foundation. |
35 | 12 | # | 12 | # |
39 | 13 | # This program is distributed in the hope that it will be useful, but | 13 | # This program is distributed in the hope that it will be useful, but |
40 | 14 | # WITHOUT ANY WARRANTY; without even the implied warranties of | 14 | # WITHOUT ANY WARRANTY; without even the implied warranties of |
41 | 15 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | 15 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
42 | 16 | # PURPOSE. See the GNU General Public License for more details. | 16 | # PURPOSE. See the GNU General Public License for more details. |
43 | 17 | # | 17 | # |
45 | 18 | # You should have received a copy of the GNU General Public License along | 18 | # You should have received a copy of the GNU General Public License along |
46 | 19 | # with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
48 | 20 | """Wrapper script for pylint command""" | 20 | |
49 | 21 | """Wrapper script for pylint command.""" | ||
50 | 21 | 22 | ||
51 | 22 | import ConfigParser | 23 | import ConfigParser |
52 | 23 | import os | 24 | import os |
53 | @@ -104,45 +105,51 @@ | |||
54 | 104 | return pyfiles | 105 | return pyfiles |
55 | 105 | 106 | ||
56 | 106 | 107 | ||
99 | 107 | failed = False | 108 | def main(): |
100 | 108 | 109 | """Do the deed.""" | |
101 | 109 | ignored = _read_pylintrc_ignored() | 110 | failed = False |
102 | 110 | 111 | ignored = _read_pylintrc_ignored() | |
103 | 111 | # So that we can match the path correctly | 112 | |
104 | 112 | if ignored: | 113 | # So that we can match the path correctly |
105 | 113 | moreignores = [os.path.join(SRCDIR, item) for item in ignored] | 114 | if ignored: |
106 | 114 | ignored.extend(moreignores) | 115 | moreignores = [os.path.join(SRCDIR, item) for item in ignored] |
107 | 115 | else: | 116 | ignored.extend(moreignores) |
108 | 116 | ignored = [] | 117 | else: |
109 | 117 | 118 | ignored = [] | |
110 | 118 | if os.environ.get('USE_PYFLAKES'): | 119 | |
111 | 119 | pylint_args = ["pyflakes"] | 120 | if os.environ.get('USE_PYFLAKES'): |
112 | 120 | else: | 121 | pylint_args = ["pyflakes"] |
113 | 121 | pylint_args = ["pylint", | 122 | else: |
114 | 122 | "--output-format=parseable", | 123 | pylint_args = ["pylint", |
115 | 123 | "--include-ids=yes",] | 124 | "--output-format=parseable", |
116 | 124 | if PYLINTRC: | 125 | "--include-ids=yes",] |
117 | 125 | pylint_args.append("--rcfile=" + PYLINTRC) | 126 | if PYLINTRC: |
118 | 126 | 127 | pylint_args.append("--rcfile=" + PYLINTRC) | |
119 | 127 | for path in _find_files(): | 128 | |
120 | 128 | if path not in ignored and not path.startswith(os.path.join(SRCDIR, | 129 | for path in _find_files(): |
121 | 129 | "_build")): | 130 | is_build = path.startswith(os.path.join(SRCDIR, "_build")) |
122 | 130 | pylint_args.append(path) | 131 | if path not in ignored and not is_build: |
123 | 131 | 132 | pylint_args.append(path) | |
124 | 132 | p = subprocess.Popen(pylint_args, | 133 | |
125 | 133 | bufsize=4096, stdout=subprocess.PIPE) | 134 | sp = subprocess.Popen(pylint_args, |
126 | 134 | notices = p.stdout | 135 | bufsize=4096, stdout=subprocess.PIPE) |
127 | 135 | 136 | notices = sp.stdout | |
128 | 136 | output = "".join(notices.readlines()) | 137 | |
129 | 137 | if output != "": | 138 | output = "".join(notices.readlines()) |
130 | 138 | print "== Python Lint Notices ==" | 139 | if output != "": |
131 | 139 | (failed, grouped) = _group_lines_by_file(output) | 140 | print "== Python Lint Notices ==" |
132 | 140 | print grouped | 141 | (failed, grouped) = _group_lines_by_file(output) |
133 | 141 | print "" | 142 | print grouped |
134 | 142 | 143 | print "" | |
135 | 143 | returncode = p.wait() | 144 | |
136 | 144 | if returncode != 0: | 145 | returncode = sp.wait() |
137 | 145 | exit(returncode) | 146 | # XXX Testing that W0511 does not cause a failure |
138 | 146 | 147 | if failed: | |
139 | 147 | if failed: | 148 | if returncode != 0: |
140 | 148 | exit(1) | 149 | exit(returncode) |
141 | 150 | else: | ||
142 | 151 | exit(1) | ||
143 | 152 | |||
144 | 153 | |||
145 | 154 | if __name__ == '__main__': | ||
146 | 155 | main() | ||
147 | 149 | 156 | ||
148 | === modified file 'bin/u1trial' | |||
149 | --- bin/u1trial 2010-08-02 13:45:54 +0000 | |||
150 | +++ bin/u1trial 2010-11-30 19:41:01 +0000 | |||
151 | @@ -6,38 +6,78 @@ | |||
152 | 6 | # | 6 | # |
153 | 7 | # Copyright 2009-2010 Canonical Ltd. | 7 | # Copyright 2009-2010 Canonical Ltd. |
154 | 8 | # | 8 | # |
157 | 9 | # This program is free software: you can redistribute it and/or modify it | 9 | # This program is free software: you can redistribute it and/or modify it |
158 | 10 | # under the terms of the GNU General Public License version 3, as published | 10 | # under the terms of the GNU General Public License version 3, as published |
159 | 11 | # by the Free Software Foundation. | 11 | # by the Free Software Foundation. |
160 | 12 | # | 12 | # |
164 | 13 | # This program is distributed in the hope that it will be useful, but | 13 | # This program is distributed in the hope that it will be useful, but |
165 | 14 | # WITHOUT ANY WARRANTY; without even the implied warranties of | 14 | # WITHOUT ANY WARRANTY; without even the implied warranties of |
166 | 15 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | 15 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
167 | 16 | # PURPOSE. See the GNU General Public License for more details. | 16 | # PURPOSE. See the GNU General Public License for more details. |
168 | 17 | # | 17 | # |
170 | 18 | # You should have received a copy of the GNU General Public License along | 18 | # You should have received a copy of the GNU General Public License along |
171 | 19 | # with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
172 | 20 | |||
173 | 20 | """Test runner that uses a private dbus session and glib main loop.""" | 21 | """Test runner that uses a private dbus session and glib main loop.""" |
174 | 21 | 22 | ||
175 | 23 | import coverage | ||
176 | 24 | import gc | ||
177 | 25 | import inspect | ||
178 | 22 | import os | 26 | import os |
179 | 23 | import re | 27 | import re |
180 | 24 | import sys | 28 | import sys |
181 | 25 | import unittest | 29 | import unittest |
182 | 26 | 30 | ||
183 | 31 | from twisted.trial.runner import TrialRunner | ||
184 | 32 | |||
185 | 27 | sys.path.insert(0, os.path.abspath(".")) | 33 | sys.path.insert(0, os.path.abspath(".")) |
186 | 28 | 34 | ||
187 | 29 | # pylint: disable=W0212 | ||
188 | 30 | 35 | ||
190 | 31 | class TestRunner(object): | 36 | class TestRunner(TrialRunner): |
191 | 32 | """The test runner implementation.""" | 37 | """The test runner implementation.""" |
192 | 33 | 38 | ||
193 | 39 | def __init__(self): | ||
194 | 40 | # install the glib2reactor before any import of the reactor to avoid | ||
195 | 41 | # using the default SelectReactor and be able to run the dbus tests | ||
196 | 42 | from twisted.internet import glib2reactor | ||
197 | 43 | glib2reactor.install() | ||
198 | 44 | from twisted.trial.reporter import TreeReporter | ||
199 | 45 | |||
200 | 46 | # setup a custom XDG_CACHE_HOME and create the logs directory | ||
201 | 47 | xdg_cache = os.path.join(os.getcwd(), "_trial_temp", "xdg_cache") | ||
202 | 48 | os.environ["XDG_CACHE_HOME"] = xdg_cache | ||
203 | 49 | # setup the ROOTDIR env var | ||
204 | 50 | os.environ['ROOTDIR'] = os.getcwd() | ||
205 | 51 | if not os.path.exists(xdg_cache): | ||
206 | 52 | os.makedirs(xdg_cache) | ||
207 | 53 | |||
208 | 54 | self.tempdir = os.path.join(os.getcwd(), "_trial_temp") | ||
209 | 55 | working_dir = os.path.join(self.tempdir, 'tmp') | ||
210 | 56 | super(TestRunner, self).__init__(reporterFactory=TreeReporter, | ||
211 | 57 | realTimeErrors=True, | ||
212 | 58 | workingDirectory=working_dir, | ||
213 | 59 | forceGarbageCollection=True) | ||
214 | 60 | self.required_services = [] | ||
215 | 61 | self.source_files = [] | ||
216 | 62 | |||
217 | 34 | def _load_unittest(self, relpath): | 63 | def _load_unittest(self, relpath): |
219 | 35 | """Load unit tests from a Python module with the given relative path.""" | 64 | """Load unit tests from a Python module with the given 'relpath'.""" |
220 | 36 | assert relpath.endswith(".py"), ( | 65 | assert relpath.endswith(".py"), ( |
221 | 37 | "%s does not appear to be a Python module" % relpath) | 66 | "%s does not appear to be a Python module" % relpath) |
222 | 67 | if not os.path.basename(relpath).startswith('test_'): | ||
223 | 68 | return | ||
224 | 38 | modpath = relpath.replace(os.path.sep, ".")[:-3] | 69 | modpath = relpath.replace(os.path.sep, ".")[:-3] |
225 | 39 | module = __import__(modpath, None, None, [""]) | 70 | module = __import__(modpath, None, None, [""]) |
226 | 40 | 71 | ||
227 | 72 | # If the module specifies required_services, make sure we get them | ||
228 | 73 | members = [x[1] for x in inspect.getmembers(module, inspect.isclass)] | ||
229 | 74 | for member_type in members: | ||
230 | 75 | if hasattr(member_type, 'required_services'): | ||
231 | 76 | member = member_type() | ||
232 | 77 | self.required_services.extend(member.required_services()) | ||
233 | 78 | del member | ||
234 | 79 | gc.collect() | ||
235 | 80 | |||
236 | 41 | # If the module has a 'suite' or 'test_suite' function, use that | 81 | # If the module has a 'suite' or 'test_suite' function, use that |
237 | 42 | # to load the tests. | 82 | # to load the tests. |
238 | 43 | if hasattr(module, "suite"): | 83 | if hasattr(module, "suite"): |
239 | @@ -53,8 +93,11 @@ | |||
240 | 53 | if test_pattern: | 93 | if test_pattern: |
241 | 54 | pattern = re.compile('.*%s.*' % test_pattern) | 94 | pattern = re.compile('.*%s.*' % test_pattern) |
242 | 55 | else: | 95 | else: |
244 | 56 | pattern = None | 96 | pattern = None |
245 | 57 | 97 | ||
246 | 98 | # Disable this lint warning as we need to access _tests in the | ||
247 | 99 | # test suites, to collect the tests | ||
248 | 100 | # pylint: disable=W0212 | ||
249 | 58 | if path: | 101 | if path: |
250 | 59 | try: | 102 | try: |
251 | 60 | module_suite = self._load_unittest(path) | 103 | module_suite = self._load_unittest(path) |
252 | @@ -69,83 +112,92 @@ | |||
253 | 69 | except AssertionError: | 112 | except AssertionError: |
254 | 70 | pass | 113 | pass |
255 | 71 | else: | 114 | else: |
257 | 72 | parser.print_help() | 115 | print 'Path should be defined.' |
258 | 73 | exit(1) | 116 | exit(1) |
259 | 74 | 117 | ||
260 | 75 | # We don't use the dirs variable, so ignore the warning | 118 | # We don't use the dirs variable, so ignore the warning |
261 | 76 | # pylint: disable=W0612 | 119 | # pylint: disable=W0612 |
262 | 77 | for root, dirs, files in os.walk(path): | 120 | for root, dirs, files in os.walk(path): |
263 | 78 | for test in files: | 121 | for test in files: |
274 | 79 | path = os.path.join(root, test) | 122 | filepath = os.path.join(root, test) |
275 | 80 | if test.endswith(".py") and test.startswith("test_"): | 123 | if test.endswith(".py"): |
276 | 81 | module_suite = self._load_unittest(path) | 124 | self.source_files.append(filepath) |
277 | 82 | if pattern: | 125 | if test.startswith("test_"): |
278 | 83 | for inner_suite in module_suite._tests: | 126 | module_suite = self._load_unittest(filepath) |
279 | 84 | for test in inner_suite._tests: | 127 | if pattern: |
280 | 85 | if pattern.match(test.id()): | 128 | for inner_suite in module_suite._tests: |
281 | 86 | suite.addTest(test) | 129 | for test in inner_suite._tests: |
282 | 87 | else: | 130 | if pattern.match(test.id()): |
283 | 88 | suite.addTests(module_suite) | 131 | suite.addTest(test) |
284 | 132 | else: | ||
285 | 133 | suite.addTests(module_suite) | ||
286 | 89 | return suite | 134 | return suite |
287 | 90 | 135 | ||
312 | 91 | def run(self, path, test_pattern=None, loops=None): | 136 | # pylint: disable=E0202 |
313 | 92 | """run the tests. """ | 137 | def run(self, path, options=None): |
314 | 93 | # install the glib2reactor before any import of the reactor to avoid | 138 | """run the tests.""" |
291 | 94 | # using the default SelectReactor and be able to run the dbus tests | ||
292 | 95 | from twisted.internet import glib2reactor | ||
293 | 96 | glib2reactor.install() | ||
294 | 97 | from twisted.trial.reporter import TreeReporter | ||
295 | 98 | from twisted.trial.runner import TrialRunner | ||
296 | 99 | |||
297 | 100 | from ubuntuone.devtools.dbus_util import DBusRunner | ||
298 | 101 | dbus_runner = DBusRunner() | ||
299 | 102 | dbus_runner.startDBus() | ||
300 | 103 | |||
301 | 104 | working_dir = os.path.join(os.getcwd(), "_trial_temp", "tmp") | ||
302 | 105 | runner = TrialRunner(reporterFactory=TreeReporter, realTimeErrors=True, | ||
303 | 106 | workingDirectory=working_dir) | ||
304 | 107 | |||
305 | 108 | # setup a custom XDG_CACHE_HOME and create the logs directory | ||
306 | 109 | xdg_cache = os.path.join(os.getcwd(), "_trial_temp", "xdg_cache") | ||
307 | 110 | os.environ["XDG_CACHE_HOME"] = xdg_cache | ||
308 | 111 | # setup the ROOTDIR env var | ||
309 | 112 | os.environ['ROOTDIR'] = os.getcwd() | ||
310 | 113 | if not os.path.exists(xdg_cache): | ||
311 | 114 | os.makedirs(xdg_cache) | ||
315 | 115 | success = 0 | 139 | success = 0 |
316 | 140 | running_services = [] | ||
317 | 141 | if options.coverage: | ||
318 | 142 | coverage.erase() | ||
319 | 143 | coverage.start() | ||
320 | 144 | |||
321 | 116 | try: | 145 | try: |
324 | 117 | suite = self._collect_tests(path, test_pattern) | 146 | suite = self._collect_tests(path, options.test) |
325 | 118 | if loops: | 147 | if options.loops: |
326 | 119 | old_suite = suite | 148 | old_suite = suite |
327 | 120 | suite = unittest.TestSuite() | 149 | suite = unittest.TestSuite() |
329 | 121 | for _ in xrange(loops): | 150 | for _ in xrange(options.loops): |
330 | 122 | suite.addTest(old_suite) | 151 | suite.addTest(old_suite) |
332 | 123 | result = runner.run(suite) | 152 | |
333 | 153 | # Start any required services | ||
334 | 154 | for service in self.required_services: | ||
335 | 155 | runner = service() | ||
336 | 156 | runner.start_service(tempdir=self.tempdir) | ||
337 | 157 | running_services.append(runner) | ||
338 | 158 | |||
339 | 159 | result = super(TestRunner, self).run(suite) | ||
340 | 124 | success = result.wasSuccessful() | 160 | success = result.wasSuccessful() |
341 | 125 | finally: | 161 | finally: |
343 | 126 | dbus_runner.stopDBus() | 162 | # Stop all the running services |
344 | 163 | for runner in running_services: | ||
345 | 164 | runner.stop_service() | ||
346 | 165 | |||
347 | 166 | if options.coverage: | ||
348 | 167 | coverage.stop() | ||
349 | 168 | coverage.report(self.source_files, ignore_errors=True, | ||
350 | 169 | show_missing=False) | ||
351 | 170 | |||
352 | 127 | if not success: | 171 | if not success: |
353 | 128 | sys.exit(1) | 172 | sys.exit(1) |
354 | 129 | else: | 173 | else: |
355 | 130 | sys.exit(0) | 174 | sys.exit(0) |
356 | 131 | 175 | ||
357 | 132 | 176 | ||
359 | 133 | if __name__ == '__main__': | 177 | def main(): |
360 | 178 | """Do the deed.""" | ||
361 | 134 | from optparse import OptionParser | 179 | from optparse import OptionParser |
362 | 135 | usage = '%prog [options] path' | 180 | usage = '%prog [options] path' |
363 | 136 | parser = OptionParser(usage=usage) | 181 | parser = OptionParser(usage=usage) |
364 | 137 | parser.add_option("-t", "--test", dest="test", | 182 | parser.add_option("-t", "--test", dest="test", |
365 | 138 | help = "run specific tests, e.g: className.methodName") | 183 | help = "run specific tests, e.g: className.methodName") |
366 | 139 | parser.add_option("-l", "--loop", dest="loops", type="int", default=1, | 184 | parser.add_option("-l", "--loop", dest="loops", type="int", default=1, |
368 | 140 | help = "loop selected tests LOOPS number of times", | 185 | help = "loop selected tests LOOPS number of times", |
369 | 141 | metavar="LOOPS") | 186 | metavar="LOOPS") |
370 | 187 | parser.add_option("-c", "--coverage", action="store_true", dest="coverage", | ||
371 | 188 | help="print a coverage report when finished") | ||
372 | 142 | 189 | ||
373 | 143 | (options, args) = parser.parse_args() | 190 | (options, args) = parser.parse_args() |
374 | 144 | if args: | 191 | if args: |
375 | 145 | testpath = args[0] | 192 | testpath = args[0] |
376 | 146 | if not os.path.exists(testpath): | 193 | if not os.path.exists(testpath): |
377 | 147 | print "the path to test does not exists!" | 194 | print "the path to test does not exists!" |
379 | 148 | sys.exit() | 195 | sys.exit(1) |
380 | 149 | else: | 196 | else: |
383 | 150 | testpath = None | 197 | parser.print_help() |
384 | 151 | TestRunner().run(testpath, options.test, options.loops) | 198 | sys.exit(2) |
385 | 199 | |||
386 | 200 | TestRunner().run(testpath, options) | ||
387 | 201 | |||
388 | 202 | if __name__ == '__main__': | ||
389 | 203 | main() | ||
390 | 152 | 204 | ||
391 | === modified file 'debian/changelog' | |||
392 | --- debian/changelog 2010-08-02 13:45:54 +0000 | |||
393 | +++ debian/changelog 2010-11-30 19:41:01 +0000 | |||
394 | @@ -1,3 +1,14 @@ | |||
395 | 1 | ubuntuone-dev-tools (0.1.2-0ubuntu1) natty; urgency=low | ||
396 | 2 | |||
397 | 3 | * New upstream release. | ||
398 | 4 | * Fix debian/watch to use the right file extension. | ||
399 | 5 | * Remove python-oauth as a dependency. | ||
400 | 6 | * Update build and runtime dependencies. | ||
401 | 7 | * Require pep8 to run tests during build. | ||
402 | 8 | * Use ./run-tests during the build instead of setup.py lint to run tests. | ||
403 | 9 | |||
404 | 10 | -- Rodney Dawes <rodney.dawes@ubuntu.com> Mon, 29 Nov 2010 13:43:06 -0500 | ||
405 | 11 | |||
406 | 1 | ubuntuone-dev-tools (0.1.1-0ubuntu1) maverick; urgency=low | 12 | ubuntuone-dev-tools (0.1.1-0ubuntu1) maverick; urgency=low |
407 | 2 | 13 | ||
408 | 3 | * Initial packaging for ubuntuone-dev-tools. (LP:#610576) | 14 | * Initial packaging for ubuntuone-dev-tools. (LP:#610576) |
409 | 4 | 15 | ||
410 | === modified file 'debian/control' | |||
411 | --- debian/control 2010-08-02 13:45:54 +0000 | |||
412 | +++ debian/control 2010-11-30 19:41:01 +0000 | |||
413 | @@ -5,20 +5,23 @@ | |||
414 | 5 | Priority: optional | 5 | Priority: optional |
415 | 6 | Standards-Version: 3.9.1 | 6 | Standards-Version: 3.9.1 |
416 | 7 | Build-Depends-Indep: | 7 | Build-Depends-Indep: |
417 | 8 | dbus, | ||
418 | 9 | pep8, | ||
419 | 10 | pylint (>= 0.21.0), | ||
420 | 11 | python-coverage, | ||
421 | 12 | python-dbus, | ||
422 | 13 | python-gobject, | ||
423 | 8 | python-setuptools, | 14 | python-setuptools, |
424 | 9 | python-support, | 15 | python-support, |
425 | 10 | python-xdg, | ||
426 | 11 | python-twisted-core, | 16 | python-twisted-core, |
430 | 12 | python-dbus, | 17 | python-xdg |
428 | 13 | python-oauth, | ||
429 | 14 | pylint (>= 0.21.0) | ||
431 | 15 | Build-Depends: cdbs (>= 0.4.43), debhelper (>= 7.0.17), python-all | 18 | Build-Depends: cdbs (>= 0.4.43), debhelper (>= 7.0.17), python-all |
432 | 16 | Homepage: http://launchpad.net/ubuntuone-dev-tools | 19 | Homepage: http://launchpad.net/ubuntuone-dev-tools |
433 | 17 | 20 | ||
434 | 18 | Package: python-ubuntuone-devtools | 21 | Package: python-ubuntuone-devtools |
435 | 19 | Architecture: all | 22 | Architecture: all |
436 | 20 | Depends: ${python:Depends}, ${misc:Depends}, | 23 | Depends: ${python:Depends}, ${misc:Depends}, |
438 | 21 | python-oauth, | 24 | dbus, |
439 | 22 | python-dbus | 25 | python-dbus |
440 | 23 | Description: Ubuntu One development tools - Python modules | 26 | Description: Ubuntu One development tools - Python modules |
441 | 24 | Ubuntu One development tools provides scripts, test cases, and other | 27 | Ubuntu One development tools provides scripts, test cases, and other |
442 | @@ -29,8 +32,11 @@ | |||
443 | 29 | Package: ubuntuone-dev-tools | 32 | Package: ubuntuone-dev-tools |
444 | 30 | Architecture: all | 33 | Architecture: all |
445 | 31 | Depends: ${python:Depends}, ${misc:Depends}, python, | 34 | Depends: ${python:Depends}, ${misc:Depends}, python, |
446 | 35 | pylint (>= 0.21.0) | pyflakes, | ||
447 | 36 | python-coverage, | ||
448 | 37 | python-gobject, | ||
449 | 38 | python-twisted-core, | ||
450 | 32 | python-ubuntuone-devtools (= ${binary:Version}), | 39 | python-ubuntuone-devtools (= ${binary:Version}), |
451 | 33 | python-twisted-core, | ||
452 | 34 | python-xdg | 40 | python-xdg |
453 | 35 | Description: Ubuntu One development tools | 41 | Description: Ubuntu One development tools |
454 | 36 | Ubuntu One development tools provides scripts, test cases, and other | 42 | Ubuntu One development tools provides scripts, test cases, and other |
455 | 37 | 43 | ||
456 | === modified file 'debian/rules' | |||
457 | --- debian/rules 2010-08-02 13:45:54 +0000 | |||
458 | +++ debian/rules 2010-11-30 19:41:01 +0000 | |||
459 | @@ -6,7 +6,7 @@ | |||
460 | 6 | 6 | ||
461 | 7 | common-build-arch common-build-indep:: debian/stamp-check | 7 | common-build-arch common-build-indep:: debian/stamp-check |
462 | 8 | debian/stamp-check: | 8 | debian/stamp-check: |
464 | 9 | cd $(DEB_SRCDIR) && $(call cdbs_python_binary,python$(cdbs_python_compile_version)) $(DEB_PYTHON_SETUP_CMD) lint | 9 | cd $(DEB_SRCDIR) && ./run-tests |
465 | 10 | touch $@ | 10 | touch $@ |
466 | 11 | 11 | ||
467 | 12 | makefile-clean:: | 12 | makefile-clean:: |
468 | 13 | 13 | ||
469 | === modified file 'debian/watch' | |||
470 | --- debian/watch 2010-08-02 13:45:54 +0000 | |||
471 | +++ debian/watch 2010-11-30 19:41:01 +0000 | |||
472 | @@ -1,3 +1,3 @@ | |||
473 | 1 | version=3 | 1 | version=3 |
475 | 2 | http://launchpad.net/ubuntuone-dev-tools/+download .*/ubuntuone-dev-tools-([0-9.]+)\.tar\.bz2 | 2 | http://launchpad.net/ubuntuone-dev-tools/+download .*/ubuntuone-dev-tools-([0-9.]+)\.tar\.gz |
476 | 3 | 3 | ||
477 | 4 | 4 | ||
478 | === modified file 'pylintrc' | |||
479 | --- pylintrc 2010-08-02 13:45:54 +0000 | |||
480 | +++ pylintrc 2010-11-30 19:41:01 +0000 | |||
481 | @@ -1,39 +1,137 @@ | |||
482 | 1 | # lint Python modules using external checkers. | 1 | # lint Python modules using external checkers. |
483 | 2 | # | 2 | # |
485 | 3 | # This is the main checker controling the other ones and the reports | 3 | # This is the main checker controlling the other ones and the reports |
486 | 4 | # generation. It is itself both a raw checker and an astng checker in order | 4 | # generation. It is itself both a raw checker and an astng checker in order |
487 | 5 | # to: | 5 | # to: |
488 | 6 | # * handle message activation / deactivation at the module level | 6 | # * handle message activation / deactivation at the module level |
490 | 7 | # * handle some basic but necessary stats data (number of classes, methods...) | 7 | # * handle some basic but necessary stats'data (number of classes, methods...) |
491 | 8 | # | 8 | # |
492 | 9 | [MASTER] | 9 | [MASTER] |
495 | 10 | # Set the cache size for astng objects. | 10 | |
496 | 11 | cache-size=500 | 11 | # Specify a configuration file. |
497 | 12 | #rcfile= | ||
498 | 13 | |||
499 | 14 | # Python code to execute, usually for sys.path manipulation such as | ||
500 | 15 | # pygtk.require(). | ||
501 | 16 | #init-hook= | ||
502 | 17 | |||
503 | 18 | # Profiled execution. | ||
504 | 19 | profile=no | ||
505 | 20 | |||
506 | 21 | # Add <file or directory> to the black list. It should be a base name, not a | ||
507 | 22 | # path. You may set this option multiple times. | ||
508 | 23 | #ignore=<somedir> | ||
509 | 24 | |||
510 | 25 | # Pickle collected data for later comparisons. | ||
511 | 26 | persistent=no | ||
512 | 27 | |||
513 | 28 | # List of plugins (as comma separated values of python modules names) to load, | ||
514 | 29 | # usually to register additional checkers. | ||
515 | 30 | load-plugins= | ||
516 | 31 | |||
517 | 12 | 32 | ||
518 | 13 | [MESSAGES CONTROL] | 33 | [MESSAGES CONTROL] |
520 | 14 | # Disable some checkers | 34 | |
521 | 35 | # Enable only checker(s) with the given id(s). This option conflicts with the | ||
522 | 36 | # disable-checker option | ||
523 | 37 | #enable-checker= | ||
524 | 38 | |||
525 | 39 | # Enable all checker(s) except those with the given id(s). This option | ||
526 | 40 | # conflicts with the enable-checker option | ||
527 | 41 | #disable-checker= | ||
528 | 42 | |||
529 | 43 | # Enable all messages in the listed categories. | ||
530 | 44 | #enable-cat= | ||
531 | 45 | |||
532 | 15 | # Disable all messages in the listed categories. | 46 | # Disable all messages in the listed categories. |
543 | 16 | # Disable the message(s) with the given id(s). | 47 | #disable-cat= |
544 | 17 | # :E0101: *Explicit return in __init__* | 48 | |
545 | 18 | # :E0202: An attribute inherited from %s hide this method | 49 | # Disable the message(s) with the given id(s) or categories |
546 | 19 | # :W0142: *Used * or ** magic* | 50 | # W0142: Used * or ** magic |
547 | 20 | # :W0201: Attribute '%s' defined outside __init__ | 51 | # W0221: Arguments number differs from %s method (pylint is confused by * and **) |
548 | 21 | # :W0221: *Arguments number differs from %s method* (pylint is confused by * and **) | 52 | # W0613: Unused argument %r (We get lots of these from interfaces) |
549 | 22 | # :W0613: *Unused argument %r* (We get lots of these from interfaces) | 53 | disable=R,I,W0142,W0221,W0613 |
540 | 23 | # :W0621: *Redefining name %r from outer scope (line %s)* (pylint does a poor evaluation) | ||
541 | 24 | # :W0622: *Redefining built-in '%r' | ||
542 | 25 | disable=typecheck,design,similarities,R,I,E0101,E0202,W0142,W0201,W0221,W0613,W0621,W0622,C0322 | ||
550 | 26 | 54 | ||
551 | 27 | 55 | ||
552 | 28 | [REPORTS] | 56 | [REPORTS] |
554 | 29 | # Tells wether to display a full report or only the messages | 57 | |
555 | 58 | # Set the output format. Available formats are text, parseable, colorized, msvs | ||
556 | 59 | # (visual studio) and html | ||
557 | 60 | output-format=colorized | ||
558 | 61 | |||
559 | 62 | # Include message's id in output | ||
560 | 63 | include-ids=yes | ||
561 | 64 | |||
562 | 65 | # Put messages in a separate file for each module / package specified on the | ||
563 | 66 | # command line instead of printing them on stdout. Reports (if any) will be | ||
564 | 67 | # written in a file name "pylint_global.[txt|html]". | ||
565 | 68 | files-output=no | ||
566 | 69 | |||
567 | 70 | # Tells whether to display a full report or only the messages | ||
568 | 30 | reports=no | 71 | reports=no |
569 | 31 | 72 | ||
570 | 73 | # Python expression which should return a note less than 10 (10 is the highest | ||
571 | 74 | # note). You have access to the variables errors warning, statement which | ||
572 | 75 | # respectively contain the number of errors / warnings messages and the total | ||
573 | 76 | # number of statements analyzed. This is used by the global evaluation report | ||
574 | 77 | # (R0004). | ||
575 | 78 | evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) | ||
576 | 79 | |||
577 | 80 | # Add a comment according to your evaluation note. This is used by the global | ||
578 | 81 | # evaluation report (R0004). | ||
579 | 82 | comment=no | ||
580 | 83 | |||
581 | 84 | # Enable the report(s) with the given id(s). | ||
582 | 85 | #enable-report= | ||
583 | 86 | |||
584 | 87 | # Disable the report(s) with the given id(s). | ||
585 | 88 | #disable-report= | ||
586 | 89 | |||
587 | 90 | |||
588 | 91 | # try to find bugs in the code using type inference | ||
589 | 92 | # | ||
590 | 93 | [TYPECHECK] | ||
591 | 94 | |||
592 | 95 | # Tells whether missing members accessed in mixin class should be ignored. A | ||
593 | 96 | # mixin class is detected if its name ends with "mixin" (case insensitive). | ||
594 | 97 | ignore-mixin-members=yes | ||
595 | 98 | |||
596 | 99 | # List of classes names for which member attributes should not be checked | ||
597 | 100 | # (useful for classes with attributes dynamically set). | ||
598 | 101 | ignored-classes= | ||
599 | 102 | |||
600 | 103 | # When zope mode is activated, add a predefined set of Zope acquired attributes | ||
601 | 104 | # to generated-members. | ||
602 | 105 | zope=no | ||
603 | 106 | |||
604 | 107 | # List of members which are set dynamically and missed by pylint inference | ||
605 | 108 | # system, and so shouldn't trigger E0201 when accessed. | ||
606 | 109 | generated-members=REQUEST,acl_users,aq_parent | ||
607 | 110 | |||
608 | 111 | |||
609 | 112 | # checks for | ||
610 | 113 | # * unused variables / imports | ||
611 | 114 | # * undefined variables | ||
612 | 115 | # * redefinition of variable from builtins or from an outer scope | ||
613 | 116 | # * use of variable before assignment | ||
614 | 117 | # | ||
615 | 118 | [VARIABLES] | ||
616 | 119 | |||
617 | 120 | # Tells whether we should check for unused import in __init__ files. | ||
618 | 121 | init-import=yes | ||
619 | 122 | |||
620 | 123 | # A regular expression matching names used for dummy variables (i.e. not used). | ||
621 | 124 | dummy-variables-rgx=_|dummy | ||
622 | 125 | |||
623 | 126 | # List of additional names supposed to be defined in builtins. Remember that | ||
624 | 127 | # you should avoid to define new builtins when possible. | ||
625 | 128 | additional-builtins= | ||
626 | 129 | |||
627 | 32 | 130 | ||
628 | 33 | # checks for : | 131 | # checks for : |
629 | 34 | # * doc strings | 132 | # * doc strings |
630 | 35 | # * modules / classes / functions / methods / arguments / variables name | 133 | # * modules / classes / functions / methods / arguments / variables name |
632 | 36 | # * number of arguments, local variables, branchs, returns and statements in | 134 | # * number of arguments, local variables, branches, returns and statements in |
633 | 37 | # functions, methods | 135 | # functions, methods |
634 | 38 | # * required module attributes | 136 | # * required module attributes |
635 | 39 | # * dangerous default values as arguments | 137 | # * dangerous default values as arguments |
636 | @@ -41,7 +139,6 @@ | |||
637 | 41 | # * uses of the global statement | 139 | # * uses of the global statement |
638 | 42 | # | 140 | # |
639 | 43 | [BASIC] | 141 | [BASIC] |
640 | 44 | enable-basic=yes | ||
641 | 45 | 142 | ||
642 | 46 | # Required attributes for module, separated by a comma | 143 | # Required attributes for module, separated by a comma |
643 | 47 | required-attributes= | 144 | required-attributes= |
644 | @@ -54,34 +151,32 @@ | |||
645 | 54 | module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ | 151 | module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ |
646 | 55 | 152 | ||
647 | 56 | # Regular expression which should only match correct module level names | 153 | # Regular expression which should only match correct module level names |
649 | 57 | const-rgx=([a-z_][a-z0-9_]*|[A-Z_][A-Z0-9_]*)$ | 154 | const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ |
650 | 58 | 155 | ||
651 | 59 | # Regular expression which should only match correct class names | 156 | # Regular expression which should only match correct class names |
652 | 60 | class-rgx=[A-Z_][a-zA-Z0-9]+$ | 157 | class-rgx=[A-Z_][a-zA-Z0-9]+$ |
653 | 61 | 158 | ||
654 | 62 | # Regular expression which should only match correct function names | 159 | # Regular expression which should only match correct function names |
656 | 63 | function-rgx=[a-z_][a-zA-Z0-9_]*$ | 160 | function-rgx=[a-z_][a-z0-9_]{2,79}$ |
657 | 64 | 161 | ||
658 | 65 | # Regular expression which should only match correct method names | 162 | # Regular expression which should only match correct method names |
660 | 66 | method-rgx=[a-z_][a-zA-Z0-9_]*$ | 163 | method-rgx=([a-z_][a-z0-9_]{2,79}$|setUp|tearDown) |
661 | 67 | 164 | ||
662 | 68 | # Regular expression which should only match correct instance attribute names | 165 | # Regular expression which should only match correct instance attribute names |
664 | 69 | attr-rgx=[a-z_][a-zA-Z0-9_]*$ | 166 | attr-rgx=[a-z_][a-z0-9_]{1,30}$ |
665 | 70 | 167 | ||
666 | 71 | # Regular expression which should only match correct argument names | 168 | # Regular expression which should only match correct argument names |
668 | 72 | argument-rgx=[a-z_][a-zA-Z0-9_]{1,30}$ | 169 | argument-rgx=[a-z_][a-z0-9_]{1,30}$ |
669 | 73 | 170 | ||
670 | 74 | # Regular expression which should only match correct variable names | 171 | # Regular expression which should only match correct variable names |
673 | 75 | # They are normally all lowercase, but when a constant, they are all uppercase. | 172 | variable-rgx=[a-z_][a-z0-9_]{1,30}$ |
672 | 76 | variable-rgx=([a-z_][a-z0-9_]*|[A-Z_][A-Z0-9_]*)$ | ||
674 | 77 | 173 | ||
675 | 78 | # Regular expression which should only match correct list comprehension / | 174 | # Regular expression which should only match correct list comprehension / |
676 | 79 | # generator expression variable names | 175 | # generator expression variable names |
677 | 80 | inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ | 176 | inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ |
678 | 81 | 177 | ||
679 | 82 | # Good variable names which should always be accepted, separated by a comma | 178 | # Good variable names which should always be accepted, separated by a comma |
682 | 83 | # Update this to supress warnings about inherrited names (C0103) | 179 | good-names=d,e,f,g,i,j,k,ex,logger,Run,_ |
681 | 84 | good-names=_,a,b,c,i,j,k,v,d,f,s,t,l,ex,_,orderBy,getByName,clauseTables | ||
683 | 85 | 180 | ||
684 | 86 | # Bad variable names which should always be refused, separated by a comma | 181 | # Bad variable names which should always be refused, separated by a comma |
685 | 87 | bad-names=foo,bar,baz,toto,tutu,tata | 182 | bad-names=foo,bar,baz,toto,tutu,tata |
686 | @@ -90,13 +185,80 @@ | |||
687 | 90 | bad-functions=apply,input,reduce | 185 | bad-functions=apply,input,reduce |
688 | 91 | 186 | ||
689 | 92 | 187 | ||
697 | 93 | # checks for: | 188 | # checks for sign of poor/misdesign: |
698 | 94 | # * warning notes in the code like FIXME, XXX | 189 | # * number of methods, attributes, local variables... |
699 | 95 | # * PEP 263: source code with non ascii character but no encoding declaration | 190 | # * size, complexity of functions, methods |
700 | 96 | # | 191 | # |
701 | 97 | [MISCELLANEOUS] | 192 | [DESIGN] |
702 | 98 | # List of note tags to take in consideration, separated by a comma. | 193 | |
703 | 99 | notes=FIXME,XXX,TODO,fixme,todo | 194 | # Maximum number of arguments for function / method |
704 | 195 | max-args=5 | ||
705 | 196 | |||
706 | 197 | # Maximum number of locals for function / method body | ||
707 | 198 | max-locals=15 | ||
708 | 199 | |||
709 | 200 | # Maximum number of return / yield for function / method body | ||
710 | 201 | max-returns=6 | ||
711 | 202 | |||
712 | 203 | # Maximum number of branch for function / method body | ||
713 | 204 | max-branchs=12 | ||
714 | 205 | |||
715 | 206 | # Maximum number of statements in function / method body | ||
716 | 207 | max-statements=50 | ||
717 | 208 | |||
718 | 209 | # Maximum number of parents for a class (see R0901). | ||
719 | 210 | max-parents=7 | ||
720 | 211 | |||
721 | 212 | # Maximum number of attributes for a class (see R0902). | ||
722 | 213 | max-attributes=7 | ||
723 | 214 | |||
724 | 215 | # Minimum number of public methods for a class (see R0903). | ||
725 | 216 | min-public-methods=2 | ||
726 | 217 | |||
727 | 218 | # Maximum number of public methods for a class (see R0904). | ||
728 | 219 | max-public-methods=20 | ||
729 | 220 | |||
730 | 221 | |||
731 | 222 | # checks for : | ||
732 | 223 | # * methods without self as first argument | ||
733 | 224 | # * overridden methods signature | ||
734 | 225 | # * access only to existent members via self | ||
735 | 226 | # * attributes not defined in the __init__ method | ||
736 | 227 | # * supported interfaces implementation | ||
737 | 228 | # * unreachable code | ||
738 | 229 | # | ||
739 | 230 | [CLASSES] | ||
740 | 231 | |||
741 | 232 | # List of interface methods to ignore, separated by a comma. This is used for | ||
742 | 233 | # instance to not check methods defines in Zopes Interface base class. | ||
743 | 234 | #ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by,providedBy | ||
744 | 235 | |||
745 | 236 | # List of method names used to declare (i.e. assign) instance attributes. | ||
746 | 237 | defining-attr-methods=__init__,__new__,setUp | ||
747 | 238 | |||
748 | 239 | |||
749 | 240 | # checks for | ||
750 | 241 | # * external modules dependencies | ||
751 | 242 | # * relative / wildcard imports | ||
752 | 243 | # * cyclic imports | ||
753 | 244 | # * uses of deprecated modules | ||
754 | 245 | # | ||
755 | 246 | [IMPORTS] | ||
756 | 247 | |||
757 | 248 | # Deprecated modules which should not be used, separated by a comma | ||
758 | 249 | deprecated-modules=regsub,string,TERMIOS,Bastion,rexec | ||
759 | 250 | |||
760 | 251 | # Create a graph of every (i.e. internal and external) dependencies in the | ||
761 | 252 | # given file (report RP0402 must not be disabled) | ||
762 | 253 | import-graph= | ||
763 | 254 | |||
764 | 255 | # Create a graph of external dependencies in the given file (report RP0402 must | ||
765 | 256 | # not be disabled) | ||
766 | 257 | ext-import-graph= | ||
767 | 258 | |||
768 | 259 | # Create a graph of internal dependencies in the given file (report RP0402 must | ||
769 | 260 | # not be disabled) | ||
770 | 261 | int-import-graph= | ||
771 | 100 | 262 | ||
772 | 101 | 263 | ||
773 | 102 | # checks for : | 264 | # checks for : |
774 | @@ -106,10 +268,9 @@ | |||
775 | 106 | # * use of <> instead of != | 268 | # * use of <> instead of != |
776 | 107 | # | 269 | # |
777 | 108 | [FORMAT] | 270 | [FORMAT] |
778 | 109 | enable-format=yes | ||
779 | 110 | 271 | ||
780 | 111 | # Maximum number of characters on a single line. | 272 | # Maximum number of characters on a single line. |
782 | 112 | max-line-length=80 | 273 | max-line-length=79 |
783 | 113 | 274 | ||
784 | 114 | # Maximum number of lines in a module | 275 | # Maximum number of lines in a module |
785 | 115 | max-module-lines=2000 | 276 | max-module-lines=2000 |
786 | @@ -117,3 +278,29 @@ | |||
787 | 117 | # String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 | 278 | # String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 |
788 | 118 | # tab). | 279 | # tab). |
789 | 119 | indent-string=' ' | 280 | indent-string=' ' |
790 | 281 | |||
791 | 282 | |||
792 | 283 | # checks for similarities and duplicated code. This computation may be | ||
793 | 284 | # memory / CPU intensive, so you should disable it if you experiments some | ||
794 | 285 | # problems. | ||
795 | 286 | # | ||
796 | 287 | [SIMILARITIES] | ||
797 | 288 | |||
798 | 289 | # Minimum lines number of a similarity. | ||
799 | 290 | min-similarity-lines=4 | ||
800 | 291 | |||
801 | 292 | # Ignore comments when computing similarities. | ||
802 | 293 | ignore-comments=yes | ||
803 | 294 | |||
804 | 295 | # Ignore docstrings when computing similarities. | ||
805 | 296 | ignore-docstrings=yes | ||
806 | 297 | |||
807 | 298 | |||
808 | 299 | # checks for: | ||
809 | 300 | # * warning notes in the code like FIXME, XXX | ||
810 | 301 | # * PEP 263: source code with non ascii character but no encoding declaration | ||
811 | 302 | # | ||
812 | 303 | [MISCELLANEOUS] | ||
813 | 304 | |||
814 | 305 | # List of note tags to take in consideration, separated by a comma. | ||
815 | 306 | notes=FIXME,XXX,TODO,fixme,xxx,todo | ||
816 | 120 | 307 | ||
817 | === added file 'run-tests' | |||
818 | --- run-tests 1970-01-01 00:00:00 +0000 | |||
819 | +++ run-tests 2010-11-30 19:41:01 +0000 | |||
820 | @@ -0,0 +1,23 @@ | |||
821 | 1 | #!/bin/bash | ||
822 | 2 | # Author: Natalia Bidart <natalia.bidart@canonical.com> | ||
823 | 3 | # | ||
824 | 4 | # Copyright 2010 Canonical Ltd. | ||
825 | 5 | # | ||
826 | 6 | # This program is free software: you can redistribute it and/or modify it | ||
827 | 7 | # under the terms of the GNU General Public License version 3, as published | ||
828 | 8 | # by the Free Software Foundation. | ||
829 | 9 | # | ||
830 | 10 | # This program is distributed in the hope that it will be useful, but | ||
831 | 11 | # WITHOUT ANY WARRANTY; without even the implied warranties of | ||
832 | 12 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
833 | 13 | # PURPOSE. See the GNU General Public License for more details. | ||
834 | 14 | # | ||
835 | 15 | # You should have received a copy of the GNU General Public License along | ||
836 | 16 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
837 | 17 | set -e | ||
838 | 18 | |||
839 | 19 | bin/u1trial -c ubuntuone | ||
840 | 20 | bin/u1lint | ||
841 | 21 | pep8 --repeat . | ||
842 | 22 | rm -rf _trial_temp | ||
843 | 23 | rm -rf .coverage | ||
844 | 0 | 24 | ||
845 | === modified file 'setup.py' | |||
846 | --- setup.py 2010-08-02 13:45:54 +0000 | |||
847 | +++ setup.py 2010-11-30 19:41:01 +0000 | |||
848 | @@ -21,10 +21,11 @@ | |||
849 | 21 | from distutils.core import setup, Command | 21 | from distutils.core import setup, Command |
850 | 22 | 22 | ||
851 | 23 | PACKAGE = 'ubuntuone-dev-tools' | 23 | PACKAGE = 'ubuntuone-dev-tools' |
853 | 24 | VERSION = '0.1.1' | 24 | VERSION = '0.1.2' |
854 | 25 | 25 | ||
855 | 26 | U1LINT = 'bin/u1lint' | 26 | U1LINT = 'bin/u1lint' |
856 | 27 | 27 | ||
857 | 28 | |||
858 | 28 | class Lint(Command): | 29 | class Lint(Command): |
859 | 29 | """Command to run the lint checks.""" | 30 | """Command to run the lint checks.""" |
860 | 30 | description = 'run python lint checks' | 31 | description = 'run python lint checks' |
861 | @@ -37,7 +38,7 @@ | |||
862 | 37 | def finalize_options(self): | 38 | def finalize_options(self): |
863 | 38 | pass | 39 | pass |
864 | 39 | 40 | ||
866 | 40 | def run (self): | 41 | def run(self): |
867 | 41 | """Run u1lint to check the code.""" | 42 | """Run u1lint to check the code.""" |
868 | 42 | retcode = subprocess.call([U1LINT]) | 43 | retcode = subprocess.call([U1LINT]) |
869 | 43 | if retcode != 0: | 44 | if retcode != 0: |
870 | @@ -48,21 +49,20 @@ | |||
871 | 48 | description='Ubuntu One development tools and utilities', | 49 | description='Ubuntu One development tools and utilities', |
872 | 49 | url='http://launchpad.net/ubuntuone-dev-tools', | 50 | url='http://launchpad.net/ubuntuone-dev-tools', |
873 | 50 | packages=['ubuntuone', | 51 | packages=['ubuntuone', |
875 | 51 | 'ubuntuone.devtools'], | 52 | 'ubuntuone.devtools', |
876 | 53 | 'ubuntuone.devtools.services'], | ||
877 | 52 | scripts=['bin/u1lint', | 54 | scripts=['bin/u1lint', |
878 | 53 | 'bin/u1trial', | 55 | 'bin/u1trial', |
879 | 54 | ], | 56 | ], |
880 | 55 | data_files=[('share/%s' % PACKAGE, | 57 | data_files=[('share/%s' % PACKAGE, |
881 | 56 | ['pylintrc', | 58 | ['pylintrc', |
884 | 57 | 'data/dbus-session.conf'] | 59 | 'data/dbus-session.conf']), |
883 | 58 | ), | ||
885 | 59 | ('share/man/man1', | 60 | ('share/man/man1', |
886 | 60 | ['man/u1lint.1', | 61 | ['man/u1lint.1', |
889 | 61 | 'man/u1trial.1',] | 62 | 'man/u1trial.1']), |
888 | 62 | ), | ||
890 | 63 | ], | 63 | ], |
891 | 64 | 64 | ||
894 | 65 | cmdclass = { | 65 | cmdclass={ |
895 | 66 | 'lint' : Lint, | 66 | 'lint': Lint, |
896 | 67 | }, | 67 | }, |
897 | 68 | ) | 68 | ) |
898 | 69 | 69 | ||
899 | === modified file 'ubuntuone/devtools/__init__.py' | |||
900 | --- ubuntuone/devtools/__init__.py 2010-08-02 13:45:54 +0000 | |||
901 | +++ ubuntuone/devtools/__init__.py 2010-11-30 19:41:01 +0000 | |||
902 | @@ -1,2 +1,1 @@ | |||
903 | 1 | """Testing utilities for Ubuntu One client code.""" | 1 | """Testing utilities for Ubuntu One client code.""" |
904 | 2 | |||
905 | 3 | 2 | ||
906 | === removed file 'ubuntuone/devtools/dbus_util.py' | |||
907 | --- ubuntuone/devtools/dbus_util.py 2010-08-02 13:45:54 +0000 | |||
908 | +++ ubuntuone/devtools/dbus_util.py 1970-01-01 00:00:00 +0000 | |||
909 | @@ -1,89 +0,0 @@ | |||
910 | 1 | # | ||
911 | 2 | # Author: Guillermo Gonzalez <guillermo.gonzalez@canonical.com> | ||
912 | 3 | # | ||
913 | 4 | # Copyright 2009-2010 Canonical Ltd. | ||
914 | 5 | # | ||
915 | 6 | # This program is free software: you can redistribute it and/or modify it | ||
916 | 7 | # under the terms of the GNU General Public License version 3, as published | ||
917 | 8 | # by the Free Software Foundation. | ||
918 | 9 | # | ||
919 | 10 | # This program is distributed in the hope that it will be useful, but | ||
920 | 11 | # WITHOUT ANY WARRANTY; without even the implied warranties of | ||
921 | 12 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
922 | 13 | # PURPOSE. See the GNU General Public License for more details. | ||
923 | 14 | # | ||
924 | 15 | # You should have received a copy of the GNU General Public License along | ||
925 | 16 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
926 | 17 | """Utilities for finding and running a dbus session bus for testing.""" | ||
927 | 18 | |||
928 | 19 | import os | ||
929 | 20 | import signal | ||
930 | 21 | import subprocess | ||
931 | 22 | |||
932 | 23 | from distutils.spawn import find_executable | ||
933 | 24 | from xdg.BaseDirectory import load_data_paths | ||
934 | 25 | |||
935 | 26 | |||
936 | 27 | class DBusLaunchError(Exception): | ||
937 | 28 | """Error while launching dbus-daemon""" | ||
938 | 29 | pass | ||
939 | 30 | |||
940 | 31 | class NotFoundError(Exception): | ||
941 | 32 | """Not found error""" | ||
942 | 33 | pass | ||
943 | 34 | |||
944 | 35 | |||
945 | 36 | class DBusRunner(object): | ||
946 | 37 | """Class for running dbus-daemon with a private session.""" | ||
947 | 38 | |||
948 | 39 | def __init__(self): | ||
949 | 40 | self.dbus_address = None | ||
950 | 41 | self.dbus_pid = None | ||
951 | 42 | self.running = False | ||
952 | 43 | |||
953 | 44 | def _find_config_file(self): | ||
954 | 45 | """Find the first appropriate dbus-session.conf to use.""" | ||
955 | 46 | # In case we're running from within the source tree | ||
956 | 47 | path = os.path.join(os.path.dirname(__file__), "..", "..", | ||
957 | 48 | "data", "dbus-session.conf") | ||
958 | 49 | if os.path.exists(path): | ||
959 | 50 | return path | ||
960 | 51 | |||
961 | 52 | # Use the installed file in $pkgdatadir | ||
962 | 53 | for i in load_data_paths("ubuntuone-dev-tools", "dbus-session.conf"): | ||
963 | 54 | if os.path.exists(i): | ||
964 | 55 | return i | ||
965 | 56 | |||
966 | 57 | |||
967 | 58 | def startDBus(self): | ||
968 | 59 | """Start our own session bus daemon for testing.""" | ||
969 | 60 | dbus = find_executable("dbus-daemon") | ||
970 | 61 | if not dbus: | ||
971 | 62 | raise NotFoundError("dbus-daemon was not found.") | ||
972 | 63 | |||
973 | 64 | config_file = self._find_config_file() | ||
974 | 65 | |||
975 | 66 | dbus_args = ["--fork", | ||
976 | 67 | "--config-file=" + config_file, | ||
977 | 68 | "--print-address=1", | ||
978 | 69 | "--print-pid=2"] | ||
979 | 70 | p = subprocess.Popen([dbus] + dbus_args, | ||
980 | 71 | bufsize=4096, stdout=subprocess.PIPE, | ||
981 | 72 | stderr=subprocess.PIPE) | ||
982 | 73 | |||
983 | 74 | self.dbus_address = "".join(p.stdout.readlines()).strip() | ||
984 | 75 | self.dbus_pid = int("".join(p.stderr.readlines()).strip()) | ||
985 | 76 | |||
986 | 77 | if self.dbus_address != "": | ||
987 | 78 | os.environ["DBUS_SESSION_BUS_ADDRESS"] = self.dbus_address | ||
988 | 79 | else: | ||
989 | 80 | os.kill(self.dbus_pid, signal.SIGKILL) | ||
990 | 81 | raise DBusLaunchError("There was a problem launching dbus-daemon.") | ||
991 | 82 | self.running = True | ||
992 | 83 | |||
993 | 84 | def stopDBus(self): | ||
994 | 85 | """Stop our DBus session bus daemon.""" | ||
995 | 86 | del os.environ["DBUS_SESSION_BUS_ADDRESS"] | ||
996 | 87 | os.kill(self.dbus_pid, signal.SIGKILL) | ||
997 | 88 | self.running = False | ||
998 | 89 | |||
999 | 90 | 0 | ||
1000 | === added file 'ubuntuone/devtools/handlers.py' | |||
1001 | --- ubuntuone/devtools/handlers.py 1970-01-01 00:00:00 +0000 | |||
1002 | +++ ubuntuone/devtools/handlers.py 2010-11-30 19:41:01 +0000 | |||
1003 | @@ -0,0 +1,64 @@ | |||
1004 | 1 | # -*- coding: utf-8 -*- | ||
1005 | 2 | |||
1006 | 3 | # Author: Guillermo Gonzalez <guillermo.gonzalez@canonical.com> | ||
1007 | 4 | # Author: Facundo Batista <facundo@canonical.com> | ||
1008 | 5 | # | ||
1009 | 6 | # Copyright 2009-2010 Canonical Ltd. | ||
1010 | 7 | # | ||
1011 | 8 | # This program is free software: you can redistribute it and/or modify it | ||
1012 | 9 | # under the terms of the GNU General Public License version 3, as published | ||
1013 | 10 | # by the Free Software Foundation. | ||
1014 | 11 | # | ||
1015 | 12 | # This program is distributed in the hope that it will be useful, but | ||
1016 | 13 | # WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1017 | 14 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
1018 | 15 | # PURPOSE. See the GNU General Public License for more details. | ||
1019 | 16 | # | ||
1020 | 17 | # You should have received a copy of the GNU General Public License along | ||
1021 | 18 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1022 | 19 | |||
1023 | 20 | """Set of helpers handlers.""" | ||
1024 | 21 | |||
1025 | 22 | import logging | ||
1026 | 23 | |||
1027 | 24 | |||
1028 | 25 | class MementoHandler(logging.Handler): | ||
1029 | 26 | """ A handler class which store logging records in a list """ | ||
1030 | 27 | |||
1031 | 28 | def __init__(self, *args, **kwargs): | ||
1032 | 29 | """ Create the instance, and add a records attribute. """ | ||
1033 | 30 | logging.Handler.__init__(self, *args, **kwargs) | ||
1034 | 31 | self.records = [] | ||
1035 | 32 | self.debug = False | ||
1036 | 33 | |||
1037 | 34 | def emit(self, record): | ||
1038 | 35 | """ Just add the record to self.records. """ | ||
1039 | 36 | self.format(record) | ||
1040 | 37 | self.records.append(record) | ||
1041 | 38 | |||
1042 | 39 | def check(self, level, *msgs): | ||
1043 | 40 | """Verifies that the msgs are logged in the specified level.""" | ||
1044 | 41 | for rec in self.records: | ||
1045 | 42 | if rec.levelno == level and all(m in rec.message for m in msgs): | ||
1046 | 43 | return True | ||
1047 | 44 | if self.debug: | ||
1048 | 45 | recorded = [(logging.getLevelName(r.levelno), r.message) | ||
1049 | 46 | for r in self.records] | ||
1050 | 47 | print "Memento messages:", recorded | ||
1051 | 48 | return False | ||
1052 | 49 | |||
1053 | 50 | def check_debug(self, *msgs): | ||
1054 | 51 | """Shortcut for checking in DEBUG.""" | ||
1055 | 52 | return self.check(logging.DEBUG, *msgs) | ||
1056 | 53 | |||
1057 | 54 | def check_info(self, *msgs): | ||
1058 | 55 | """Shortcut for checking in INFO.""" | ||
1059 | 56 | return self.check(logging.INFO, *msgs) | ||
1060 | 57 | |||
1061 | 58 | def check_warning(self, *msgs): | ||
1062 | 59 | """Shortcut for checking in WARNING.""" | ||
1063 | 60 | return self.check(logging.WARNING, *msgs) | ||
1064 | 61 | |||
1065 | 62 | def check_error(self, *msgs): | ||
1066 | 63 | """Shortcut for checking in ERROR.""" | ||
1067 | 64 | return self.check(logging.ERROR, *msgs) | ||
1068 | 0 | 65 | ||
1069 | === added directory 'ubuntuone/devtools/services' | |||
1070 | === added file 'ubuntuone/devtools/services/__init__.py' | |||
1071 | --- ubuntuone/devtools/services/__init__.py 1970-01-01 00:00:00 +0000 | |||
1072 | +++ ubuntuone/devtools/services/__init__.py 2010-11-30 19:41:01 +0000 | |||
1073 | @@ -0,0 +1,1 @@ | |||
1074 | 1 | """Service runners for testing.""" | ||
1075 | 0 | 2 | ||
1076 | === added file 'ubuntuone/devtools/services/dbus.py' | |||
1077 | --- ubuntuone/devtools/services/dbus.py 1970-01-01 00:00:00 +0000 | |||
1078 | +++ ubuntuone/devtools/services/dbus.py 2010-11-30 19:41:01 +0000 | |||
1079 | @@ -0,0 +1,94 @@ | |||
1080 | 1 | # | ||
1081 | 2 | # Author: Guillermo Gonzalez <guillermo.gonzalez@canonical.com> | ||
1082 | 3 | # | ||
1083 | 4 | # Copyright 2009-2010 Canonical Ltd. | ||
1084 | 5 | # | ||
1085 | 6 | # This program is free software: you can redistribute it and/or modify it | ||
1086 | 7 | # under the terms of the GNU General Public License version 3, as published | ||
1087 | 8 | # by the Free Software Foundation. | ||
1088 | 9 | # | ||
1089 | 10 | # This program is distributed in the hope that it will be useful, but | ||
1090 | 11 | # WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1091 | 12 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
1092 | 13 | # PURPOSE. See the GNU General Public License for more details. | ||
1093 | 14 | # | ||
1094 | 15 | # You should have received a copy of the GNU General Public License along | ||
1095 | 16 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1096 | 17 | """Utilities for finding and running a dbus session bus for testing.""" | ||
1097 | 18 | |||
1098 | 19 | import os | ||
1099 | 20 | import signal | ||
1100 | 21 | import subprocess | ||
1101 | 22 | |||
1102 | 23 | from distutils.spawn import find_executable | ||
1103 | 24 | from xdg.BaseDirectory import load_data_paths | ||
1104 | 25 | |||
1105 | 26 | |||
1106 | 27 | class DBusLaunchError(Exception): | ||
1107 | 28 | """Error while launching dbus-daemon""" | ||
1108 | 29 | pass | ||
1109 | 30 | |||
1110 | 31 | |||
1111 | 32 | class NotFoundError(Exception): | ||
1112 | 33 | """Not found error""" | ||
1113 | 34 | pass | ||
1114 | 35 | |||
1115 | 36 | |||
1116 | 37 | class DBusRunner(object): | ||
1117 | 38 | """Class for running dbus-daemon with a private session.""" | ||
1118 | 39 | |||
1119 | 40 | def __init__(self): | ||
1120 | 41 | self.dbus_address = None | ||
1121 | 42 | self.dbus_pid = None | ||
1122 | 43 | self.running = False | ||
1123 | 44 | |||
1124 | 45 | def _find_config_file(self): | ||
1125 | 46 | """Find the first appropriate dbus-session.conf to use.""" | ||
1126 | 47 | # In case we're running from within the source tree | ||
1127 | 48 | path = os.path.join(os.path.dirname(__file__), "..", "..", ".." | ||
1128 | 49 | "data", "dbus-session.conf") | ||
1129 | 50 | if os.path.exists(path): | ||
1130 | 51 | return path | ||
1131 | 52 | |||
1132 | 53 | # Use the installed file in $pkgdatadir | ||
1133 | 54 | for i in load_data_paths("ubuntuone-dev-tools", "dbus-session.conf"): | ||
1134 | 55 | if os.path.exists(i): | ||
1135 | 56 | return i | ||
1136 | 57 | |||
1137 | 58 | def start_service(self, tempdir=None): | ||
1138 | 59 | """Start our own session bus daemon for testing.""" | ||
1139 | 60 | if not tempdir: | ||
1140 | 61 | tempdir = os.path.join(os.getcwd(), '_trial_temp') | ||
1141 | 62 | dbus = find_executable("dbus-daemon") | ||
1142 | 63 | if not dbus: | ||
1143 | 64 | raise NotFoundError("dbus-daemon was not found.") | ||
1144 | 65 | |||
1145 | 66 | config_file = self._find_config_file() | ||
1146 | 67 | |||
1147 | 68 | dbus_args = ["--fork", | ||
1148 | 69 | "--config-file=" + config_file, | ||
1149 | 70 | "--print-address=1", | ||
1150 | 71 | "--print-pid=2", | ||
1151 | 72 | "--address=unix:tmpdir=%s" % tempdir] | ||
1152 | 73 | sp = subprocess.Popen([dbus] + dbus_args, | ||
1153 | 74 | bufsize=4096, stdout=subprocess.PIPE, | ||
1154 | 75 | stderr=subprocess.PIPE) | ||
1155 | 76 | |||
1156 | 77 | self.dbus_address = "".join(sp.stdout.readlines()).strip() | ||
1157 | 78 | self.dbus_pid = int("".join(sp.stderr.readlines()).strip()) | ||
1158 | 79 | |||
1159 | 80 | if self.dbus_address != "": | ||
1160 | 81 | os.environ["DBUS_SESSION_BUS_ADDRESS"] = self.dbus_address | ||
1161 | 82 | else: | ||
1162 | 83 | os.kill(self.dbus_pid, signal.SIGKILL) | ||
1163 | 84 | raise DBusLaunchError("There was a problem launching dbus-daemon.") | ||
1164 | 85 | self.running = True | ||
1165 | 86 | |||
1166 | 87 | def stop_service(self): | ||
1167 | 88 | """Stop our DBus session bus daemon.""" | ||
1168 | 89 | try: | ||
1169 | 90 | del os.environ["DBUS_SESSION_BUS_ADDRESS"] | ||
1170 | 91 | except KeyError: | ||
1171 | 92 | pass | ||
1172 | 93 | os.kill(self.dbus_pid, signal.SIGKILL) | ||
1173 | 94 | self.running = False | ||
1174 | 0 | 95 | ||
1175 | === modified file 'ubuntuone/devtools/testcase.py' | |||
1176 | --- ubuntuone/devtools/testcase.py 2010-08-02 13:45:54 +0000 | |||
1177 | +++ ubuntuone/devtools/testcase.py 2010-11-30 19:41:01 +0000 | |||
1178 | @@ -1,4 +1,5 @@ | |||
1180 | 1 | # | 1 | # -*- coding: utf-8 -*- |
1181 | 2 | |||
1182 | 2 | # Author: Guillermo Gonzalez <guillermo.gonzalez@canonical.com> | 3 | # Author: Guillermo Gonzalez <guillermo.gonzalez@canonical.com> |
1183 | 3 | # | 4 | # |
1184 | 4 | # Copyright 2009-2010 Canonical Ltd. | 5 | # Copyright 2009-2010 Canonical Ltd. |
1185 | @@ -14,19 +15,26 @@ | |||
1186 | 14 | # | 15 | # |
1187 | 15 | # You should have received a copy of the GNU General Public License along | 16 | # You should have received a copy of the GNU General Public License along |
1188 | 16 | # with this program. If not, see <http://www.gnu.org/licenses/>. | 17 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
1190 | 17 | """ Base tests cases and test utilities """ | 18 | |
1191 | 19 | """Base tests cases and test utilities.""" | ||
1192 | 20 | |||
1193 | 18 | from __future__ import with_statement | 21 | from __future__ import with_statement |
1194 | 19 | 22 | ||
1195 | 20 | import dbus | ||
1196 | 21 | from dbus.mainloop.glib import DBusGMainLoop | ||
1197 | 22 | import contextlib | 23 | import contextlib |
1198 | 23 | import os | 24 | import os |
1199 | 24 | import shutil | 25 | import shutil |
1200 | 25 | 26 | ||
1201 | 27 | import dbus | ||
1202 | 28 | import dbus.service | ||
1203 | 29 | |||
1204 | 30 | from dbus.mainloop.glib import DBusGMainLoop | ||
1205 | 31 | |||
1206 | 26 | from twisted.internet import defer | 32 | from twisted.internet import defer |
1207 | 27 | from twisted.python import failure | 33 | from twisted.python import failure |
1210 | 28 | from unittest import TestCase | 34 | from twisted.trial.unittest import TestCase |
1211 | 29 | from oauth import oauth | 35 | |
1212 | 36 | # DBusRunner for DBusTestCase using tests | ||
1213 | 37 | from ubuntuone.devtools.services.dbus import DBusRunner | ||
1214 | 30 | 38 | ||
1215 | 31 | 39 | ||
1216 | 32 | @contextlib.contextmanager | 40 | @contextlib.contextmanager |
1217 | @@ -41,21 +49,9 @@ | |||
1218 | 41 | os.environ[env_var] = old_value | 49 | os.environ[env_var] = old_value |
1219 | 42 | 50 | ||
1220 | 43 | 51 | ||
1221 | 44 | class FakeOAuthClient(object): | ||
1222 | 45 | """ Fake OAuthClient""" | ||
1223 | 46 | |||
1224 | 47 | def __init__(self, realm): | ||
1225 | 48 | """ create the instance. """ | ||
1226 | 49 | self.realm = realm | ||
1227 | 50 | self.consumer = oauth.OAuthConsumer('ubuntuone', 'hammertime') | ||
1228 | 51 | |||
1229 | 52 | def get_access_token(self): | ||
1230 | 53 | """ returns a Token""" | ||
1231 | 54 | return 'a token' | ||
1232 | 55 | |||
1233 | 56 | |||
1234 | 57 | class FakeDBusInterface(object): | 52 | class FakeDBusInterface(object): |
1235 | 58 | """A fake DBusInterface...""" | 53 | """A fake DBusInterface...""" |
1236 | 54 | |||
1237 | 59 | def shutdown(self, with_restart=False): | 55 | def shutdown(self, with_restart=False): |
1238 | 60 | """...that only knows how to go away""" | 56 | """...that only knows how to go away""" |
1239 | 61 | 57 | ||
1240 | @@ -67,10 +63,15 @@ | |||
1241 | 67 | mktemp(name): helper to create temporary dirs | 63 | mktemp(name): helper to create temporary dirs |
1242 | 68 | rmtree(path): support read-only shares | 64 | rmtree(path): support read-only shares |
1243 | 69 | makedirs(path): support read-only shares | 65 | makedirs(path): support read-only shares |
1244 | 66 | |||
1245 | 70 | """ | 67 | """ |
1246 | 71 | 68 | ||
1247 | 69 | def required_services(self): | ||
1248 | 70 | """Return the list of required services for DBusTestCase.""" | ||
1249 | 71 | return [] | ||
1250 | 72 | |||
1251 | 72 | def mktemp(self, name='temp'): | 73 | def mktemp(self, name='temp'): |
1253 | 73 | """ Customized mktemp that accepts an optional name argument. """ | 74 | """Customized mktemp that accepts an optional name argument.""" |
1254 | 74 | tempdir = os.path.join(self.tmpdir, name) | 75 | tempdir = os.path.join(self.tmpdir, name) |
1255 | 75 | if os.path.exists(tempdir): | 76 | if os.path.exists(tempdir): |
1256 | 76 | self.rmtree(tempdir) | 77 | self.rmtree(tempdir) |
1257 | @@ -84,10 +85,10 @@ | |||
1258 | 84 | root_dir = getattr(self, '__root', None) | 85 | root_dir = getattr(self, '__root', None) |
1259 | 85 | if root_dir: | 86 | if root_dir: |
1260 | 86 | return root_dir | 87 | return root_dir |
1265 | 87 | MAX_FILENAME = 32 # some platforms limit lengths of filenames | 88 | max_filename = 32 # some platforms limit lengths of filenames |
1266 | 88 | base = os.path.join(self.__class__.__module__[:MAX_FILENAME], | 89 | base = os.path.join(self.__class__.__module__[:max_filename], |
1267 | 89 | self.__class__.__name__[:MAX_FILENAME], | 90 | self.__class__.__name__[:max_filename], |
1268 | 90 | self._testMethodName[:MAX_FILENAME]) | 91 | self._testMethodName[:max_filename]) |
1269 | 91 | # use _trial_temp dir, it should be os.gwtcwd() | 92 | # use _trial_temp dir, it should be os.gwtcwd() |
1270 | 92 | # define the root temp dir of the testcase, pylint: disable=W0201 | 93 | # define the root temp dir of the testcase, pylint: disable=W0201 |
1271 | 93 | self.__root = os.path.join(os.getcwd(), base) | 94 | self.__root = os.path.join(os.getcwd(), base) |
1272 | @@ -116,19 +117,20 @@ | |||
1273 | 116 | os.chmod(parent, 0755) | 117 | os.chmod(parent, 0755) |
1274 | 117 | os.makedirs(path) | 118 | os.makedirs(path) |
1275 | 118 | 119 | ||
1276 | 119 | def setUp(self): | ||
1277 | 120 | TestCase.setUp(self) | ||
1278 | 121 | |||
1279 | 122 | def tearDown(self): | ||
1280 | 123 | """ cleanup the temp dir. """ | ||
1281 | 124 | return TestCase.tearDown(self) | ||
1282 | 125 | |||
1283 | 126 | 120 | ||
1284 | 127 | class DBusTestCase(BaseTestCase): | 121 | class DBusTestCase(BaseTestCase): |
1286 | 128 | """ Test the DBus event handling """ | 122 | """Test the DBus event handling.""" |
1287 | 123 | |||
1288 | 124 | def required_services(self): | ||
1289 | 125 | """Return the list of required services for DBusTestCase.""" | ||
1290 | 126 | services = super(DBusTestCase, self).required_services() | ||
1291 | 127 | services.extend([DBusRunner]) | ||
1292 | 128 | return services | ||
1293 | 129 | 129 | ||
1294 | 130 | def setUp(self): | 130 | def setUp(self): |
1296 | 131 | """ Setup the infrastructure fo the test (dbus service). """ | 131 | """Setup the infrastructure fo the test (dbus service).""" |
1297 | 132 | # Class 'BaseTestCase' has no 'setUp' member | ||
1298 | 133 | # pylint: disable=E1101 | ||
1299 | 132 | BaseTestCase.setUp(self) | 134 | BaseTestCase.setUp(self) |
1300 | 133 | self.loop = DBusGMainLoop(set_as_default=True) | 135 | self.loop = DBusGMainLoop(set_as_default=True) |
1301 | 134 | self.bus = dbus.bus.BusConnection(mainloop=self.loop) | 136 | self.bus = dbus.bus.BusConnection(mainloop=self.loop) |
1302 | @@ -139,29 +141,32 @@ | |||
1303 | 139 | self.signal_receivers = set() | 141 | self.signal_receivers = set() |
1304 | 140 | 142 | ||
1305 | 141 | def tearDown(self): | 143 | def tearDown(self): |
1307 | 142 | """ Cleanup the test. """ | 144 | """Cleanup the test.""" |
1308 | 145 | # Class 'BaseTestCase' has no 'tearDown' member | ||
1309 | 146 | # pylint: disable=E1101 | ||
1310 | 143 | d = self.cleanup_signal_receivers(self.signal_receivers) | 147 | d = self.cleanup_signal_receivers(self.signal_receivers) |
1312 | 144 | d.addBoth(self._tearDown) | 148 | d.addBoth(self._tear_down) |
1313 | 145 | d.addBoth(lambda _: BaseTestCase.tearDown(self)) | 149 | d.addBoth(lambda _: BaseTestCase.tearDown(self)) |
1314 | 146 | return d | 150 | return d |
1315 | 147 | 151 | ||
1318 | 148 | def _tearDown(self): | 152 | def _tear_down(self): |
1319 | 149 | """ shutdown """ | 153 | """Shutdown.""" |
1320 | 150 | self.bus.flush() | 154 | self.bus.flush() |
1321 | 151 | self.bus.close() | 155 | self.bus.close() |
1322 | 152 | 156 | ||
1323 | 153 | def error_handler(self, error): | 157 | def error_handler(self, error): |
1325 | 154 | """ default error handler for DBus calls. """ | 158 | """Default error handler for DBus calls.""" |
1326 | 155 | if isinstance(error, failure.Failure): | 159 | if isinstance(error, failure.Failure): |
1327 | 156 | self.fail(error.getErrorMessage()) | 160 | self.fail(error.getErrorMessage()) |
1328 | 157 | 161 | ||
1329 | 158 | def cleanup_signal_receivers(self, signal_receivers): | 162 | def cleanup_signal_receivers(self, signal_receivers): |
1331 | 159 | """ cleanup self.signal_receivers and returns a deferred """ | 163 | """Cleanup self.signal_receivers and returns a deferred.""" |
1332 | 160 | deferreds = [] | 164 | deferreds = [] |
1333 | 161 | for match in signal_receivers: | 165 | for match in signal_receivers: |
1334 | 162 | d = defer.Deferred() | 166 | d = defer.Deferred() |
1335 | 167 | |||
1336 | 163 | def callback(*args): | 168 | def callback(*args): |
1338 | 164 | """ callback that accepts *args. """ | 169 | """Callback that accepts *args.""" |
1339 | 165 | if not d.called: | 170 | if not d.called: |
1340 | 166 | d.callback(args) | 171 | d.callback(args) |
1341 | 167 | self.bus.call_async(dbus.bus.BUS_DAEMON_NAME, | 172 | self.bus.call_async(dbus.bus.BUS_DAEMON_NAME, |
1342 | @@ -173,4 +178,3 @@ | |||
1343 | 173 | return defer.DeferredList(deferreds) | 178 | return defer.DeferredList(deferreds) |
1344 | 174 | else: | 179 | else: |
1345 | 175 | return defer.succeed(True) | 180 | return defer.succeed(True) |
1346 | 176 |
Good work.