forked from zmap/celerybeat-mongo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request zmap#51 from rafaelreuber/issue_37
[Fix zmap#37]: Enabled tasks do not run when there is another schedule en…
- Loading branch information
Showing
2 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
import unittest | ||
from mongoengine import disconnect | ||
from celerybeatmongo.schedulers import MongoScheduler | ||
from celery import Celery | ||
|
||
|
||
class MongoSchedulerTest(unittest.TestCase): | ||
|
||
def setUp(self): | ||
conf = { | ||
"mongodb_scheduler_url": "mongomock://localhost" | ||
} | ||
self.app = Celery(**conf) | ||
self.app.conf.update(**conf) | ||
self.scheduler = MongoScheduler(app=self.app) | ||
|
||
def tearDown(self): | ||
disconnect() | ||
|
||
def test_get_from_database(self): | ||
from celerybeatmongo.models import PeriodicTask | ||
PeriodicTask.objects.create(name="a1", task="foo", enabled=True, interval=PeriodicTask.Interval(every=1, period="days")) | ||
PeriodicTask.objects.create(name="b1", task="foo", enabled=True, interval=PeriodicTask.Interval(every=2, period="days")) | ||
PeriodicTask.objects.create(name="c2", task="foo", enabled=False, interval=PeriodicTask.Interval(every=3, period="days")) | ||
|
||
scheduler = MongoScheduler(app=self.app) | ||
self.assertEqual(2, len(scheduler.get_from_database()) | ||
, "get_from_database should return just enabled tasks") |