Exemple #1
0
 def test_long_error(self):
     task_id = add_task()
     self.d.add_error("A" * 1024, task_id)
     err = self.d.view_errors(task_id)
     assert err and len(err[0].message) == 1024
Exemple #2
0
 def test_fetch_specific_task(self):
     t1 = add_task(__file__, category="file", priority=999)
     t2 = add_task(__file__, category="file", priority=999)
     t = self.d.fetch(task_id=t1)
     assert t.id == t1
     assert t.status == "pending"
Exemple #3
0
 def test_list_tasks_noresults(self):
     for x in range(5):
         add_task(__file__, category="file")
     tasks = self.d.list_tasks(status="reported")
     assert tasks == []
Exemple #4
0
 def test_view_tasks(self):
     t1 = add_task(__file__)
     t2 = add_task("http://example.com", category="url")
     tasks = self.d.view_tasks([t1, t2])
     assert tasks[0].to_dict() == self.d.view_task(t1).to_dict()
     assert tasks[1].to_dict() == self.d.view_task(t2).to_dict()
Exemple #5
0
    def test_task_set_options(self):
        t0 = add_task(__file__, options={"foo": "bar"})
        t1 = add_task(__file__, options="foo=bar")

        assert self.d.view_task(t0).options == {"foo": "bar"}
        assert self.d.view_task(t1).options == {"foo": "bar"}
Exemple #6
0
 def test_long_error(self):
     add_task("http://google.com/", category="url")
     self.d.add_error("A" * 1024, 1)
     err = self.d.view_errors(1)
     assert err and len(err[0].message) == 1024
Exemple #7
0
 def test_error_exists(self):
     task_id = add_task("http://google.com/7", category="url")
     self.d.add_error("A" * 1024, task_id)
     assert len(self.d.view_errors(task_id)) == 1
     self.d.add_error("A" * 1024, task_id)
     assert len(self.d.view_errors(task_id)) == 2
 def test_tasks_by_id(self):
     """Test task endpoint"""
     add_task("Test1")
     task_id = 1
     response = self.client.get('/v1/tasks/{}'.format(task_id))
     self.assertEqual(response.status_code, 200)