← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/lazr.jobrunner/tox into lp:lazr.jobrunner

 

Colin Watson has proposed merging lp:~cjwatson/lazr.jobrunner/tox into lp:lazr.jobrunner.

Commit message:
Add tox testing support.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/lazr.jobrunner/tox/+merge/363988
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/lazr.jobrunner/tox into lp:lazr.jobrunner.
=== modified file '.bzrignore'
--- .bzrignore	2012-10-26 08:15:50 +0000
+++ .bzrignore	2019-03-05 17:09:19 +0000
@@ -1,4 +1,5 @@
 .installed.cfg
+.tox
 bin
 develop-eggs
 eggs

=== modified file 'NEWS.txt'
--- NEWS.txt	2015-08-03 07:04:36 +0000
+++ NEWS.txt	2019-03-05 17:09:19 +0000
@@ -1,6 +1,10 @@
 News
 ====
 
+UNRELEASED
+----------
+* Add tox testing support.
+
 0.13
 ----
 * Support and require celery >= 3.0.

=== modified file 'setup.py'
--- setup.py	2017-11-23 17:19:42 +0000
+++ setup.py	2019-03-05 17:09:19 +0000
@@ -31,6 +31,11 @@
     'celery>=3.0',
 ]
 
+tests_require = [
+    'oops>=0.0.11',
+    'unittest2',
+    'zope.testing',
+    ]
 
 setup(
     name='lazr.jobrunner',
@@ -51,6 +56,10 @@
     include_package_data=True,
     zip_safe=False,
     install_requires=install_requires,
+    tests_require=tests_require,
+    extras_require={
+        'test': tests_require,
+        },
     entry_points={
         'console_scripts': [
             'jobrunnerctl=lazr.jobrunner.bin.jobrunnerctl:main',

=== modified file 'src/lazr/jobrunner/bin/clear_queues.py'
--- src/lazr/jobrunner/bin/clear_queues.py	2015-08-03 05:34:59 +0000
+++ src/lazr/jobrunner/bin/clear_queues.py	2019-03-05 17:09:19 +0000
@@ -20,6 +20,7 @@
 __metaclass__ = type
 
 from argparse import ArgumentParser
+import json
 import os
 import sys
 
@@ -27,7 +28,9 @@
 
 
 def show_queue_data(body, message):
-    print '%s: %r' % (message.delivery_info['routing_key'], body)
+    print '%s: %s' % (
+        message.delivery_info['routing_key'],
+        json.dumps(body, sort_keys=True))
 
 
 def clear_queues(args):

=== modified file 'src/lazr/jobrunner/tests/test_celerytask.py'
--- src/lazr/jobrunner/tests/test_celerytask.py	2015-08-03 06:49:07 +0000
+++ src/lazr/jobrunner/tests/test_celerytask.py	2019-03-05 17:09:19 +0000
@@ -73,7 +73,7 @@
     cmd_args = ('worker', '--config', config_module, '--queue', queue)
     environ = dict(os.environ)
     environ['FILE_JOB_DIR'] = file_job_dir
-    return running('bin/celery', cmd_args, environ, cwd=get_root())
+    return running('celery', cmd_args, environ, cwd=get_root())
 
 
 @contextlib.contextmanager
@@ -494,7 +494,7 @@
         # any different configuration setting in a later test.
         # Running the script in a subprocess avoids this problem.
         queues = [self.queueName(task_id) for task_id in task_ids]
-        args = ['bin/clear-queues', '-c', celery_config] + queues
+        args = ['clear-queues', '-c', celery_config] + queues
         proc = subprocess.Popen(
             args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
             cwd=get_root())
@@ -519,8 +519,8 @@
 
     def successMessage(self, task_id):
         return (
-            "%s: {'status': 'SUCCESS', 'traceback': None, 'result': None, "
-            "'task_id': '%s', 'children': []}\n"
+            '%s: {"children": [], "result": null, "status": "SUCCESS", '
+            '"task_id": "%s", "traceback": null}\n'
             % (self.queueName(task_id), task_id))
 
     def noQueueMessage(self, task_id):

=== added file 'tox.ini'
--- tox.ini	1970-01-01 00:00:00 +0000
+++ tox.ini	2019-03-05 17:09:19 +0000
@@ -0,0 +1,11 @@
+[tox]
+envlist =
+    py27-celery31
+
+[testenv]
+commands =
+    zope-testrunner --test-path src --tests-pattern ^tests {posargs}
+deps =
+    .[test]
+    zope.testrunner
+    celery31: celery>=3.1,<4.0