mirror of
https://github.com/django-q2/django-q2.git
synced 2026-09-28 09:18:12 +08:00
simple test for monitor
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user