From 6314742343a98b9a2b832cd9593871545944c830 Mon Sep 17 00:00:00 2001 From: Ilan Steemers Date: Thu, 25 Jun 2015 13:29:06 +0200 Subject: [PATCH] simple test for monitor --- django_q/management/commands/qmonitor.py | 10 +--------- django_q/tests/test_monitor.py | 7 ++++++- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/django_q/management/commands/qmonitor.py b/django_q/management/commands/qmonitor.py index 505898b..2673746 100644 --- a/django_q/management/commands/qmonitor.py +++ b/django_q/management/commands/qmonitor.py @@ -12,16 +12,8 @@ from django_q.core import Stat, RUNNING, STOPPED class Command(BaseCommand): help = "Monitors cluster activity" - def add_arguments(self, parser): - parser.add_argument('--run-once', - action='store_true', - dest='run_once', - default=False, - help='Run once till first stat') - def handle(self, *args, **options): - monitor(run_once=options['run_once']) - + monitor() def monitor(run_once=False): term = Terminal() diff --git a/django_q/tests/test_monitor.py b/django_q/tests/test_monitor.py index ef07520..d07e418 100644 --- a/django_q/tests/test_monitor.py +++ b/django_q/tests/test_monitor.py @@ -8,4 +8,9 @@ def test_monitor(): stats = monitor(run_once=True) c.stop() assert len(stats) > 0 - assert stats[0].cluster_id == c.pid + found_c = False + for stat in stats: + if stat.cluster_id == c.pid: + found_c = True + break + assert found_c is True