From 4ee47fc38f0f02c9e4feb1ccbb1f6cbde4112ea6 Mon Sep 17 00:00:00 2001 From: Ilan Steemers Date: Tue, 7 Jul 2015 20:20:28 +0200 Subject: [PATCH] upping the coverage --- django_q/conf.py | 6 ++---- django_q/monitor.py | 4 +--- django_q/tests/test_cluster.py | 3 +++ django_q/tests/test_scheduler.py | 1 + 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/django_q/conf.py b/django_q/conf.py index 396f937..b195637 100644 --- a/django_q/conf.py +++ b/django_q/conf.py @@ -46,10 +46,8 @@ class Conf(object): LABEL = conf.get('label', 'Django Q') # Use the secret key for package signing - try: - SECRET_KEY = settings.SECRET_KEY - except AttributeError: - SECRET_KEY = 'omgicantbelieveudonthaveasecretkey' + # Django itself should raise an error if it's not configured + SECRET_KEY = settings.SECRET_KEY # The redis list key Q_LIST = 'django_q:{}:q'.format(PREFIX) diff --git a/django_q/monitor.py b/django_q/monitor.py index a602341..e946f61 100644 --- a/django_q/monitor.py +++ b/django_q/monitor.py @@ -52,8 +52,6 @@ def monitor(run_once=False): status = term.red(str(Conf.STOPPED)) elif stat.status == Conf.IDLE: status = str(Conf.IDLE) - else: - status = term.yellow(str(stat.status)) # color q's tasks = stat.task_q_size if tasks > 0: @@ -98,7 +96,7 @@ class Status(object): self.reincarnations = 0 self.cluster_id = pid self.sentinel = 0 - self.status = 'Idle' + self.status = Conf.STOPPED self.done_q_size = 0 self.host = socket.gethostname() self.monitor = 0 diff --git a/django_q/tests/test_cluster.py b/django_q/tests/test_cluster.py index 1e0f65f..5d0055a 100644 --- a/django_q/tests/test_cluster.py +++ b/django_q/tests/test_cluster.py @@ -39,9 +39,12 @@ def test_cluster_initial(r): r.delete(list_key) c = Cluster(list_key=list_key) assert c.sentinel is None + assert c.stat.status == Conf.STOPPED assert c.start() > 0 assert c.sentinel.is_alive() is True assert c.is_running + assert c.is_stopping is False + assert c.is_starting is False stat = c.stat assert stat.status == Conf.IDLE assert c.stop() is True diff --git a/django_q/tests/test_scheduler.py b/django_q/tests/test_scheduler.py index e10db1c..93f1239 100644 --- a/django_q/tests/test_scheduler.py +++ b/django_q/tests/test_scheduler.py @@ -59,3 +59,4 @@ def test_scheduler(r): ) assert schedule is not None assert schedule.last_run() is None + scheduler()