-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_tasks.py
27 lines (24 loc) · 885 Bytes
/
test_tasks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""
Test case for back-off mechanist requirement
"""
from django.test import TransactionTestCase
from dramatiq import Worker
from django.contrib.auth.models import User
from ..models import Feed, Follow
from ..tasks import fetch_user_feed, broker
class TestCase(TransactionTestCase):
def setUp(self):
self.broker = broker
self.broker.emit_after("process_boot")
self.broker.flush_all()
self.worker = Worker(self.broker, worker_timeout=100)
self.worker.start()
self.u = User.objects.create(username="u1")
def test_back_off_case(self):
url = "http://localhost"
feed = Feed(url=url)
feed.save()
fetch_user_feed.send(id=feed.id, user_id=self.u.id)
with self.assertRaises(Exception):
self.broker.join(fetch_user_feed.queue_name, fail_fast=True)
self.worker.join()