예제 #1
0
    def test_deleting_a_task_deletes_the_executions(self):
        notebook = Notebook(name='tagada', users=[])
        task = Task(notebook=notebook, name='stuff', periodicity=42)
        DBSession.add_all([notebook, task])
        DBSession.flush()
        task.execute(None, 12)
        self.assertEqual(Execution.query().count(), 1)

        DBSession.delete(task)

        self.assertEqual(Execution.query().count(), 0)
예제 #2
0
    def test_last_executions(self):
        from augias.views import notebook
        n = Notebook(name='some notebook')
        task = Task(name='some task', notebook=n, periodicity=12)
        user = User(email='*****@*****.**')
        task.execute(user, 5)
        task.execute(user, 10)
        request = DummyRequest(user=user)

        result = notebook(n, request)

        last_executions = result['last_executions']
        self.assertEqual(len(last_executions), 2)
        self.assertEqual(last_executions[0].length, 10)
예제 #3
0
    def test_deleting_a_notebook_deletes_the_tasks(self):
        notebook = Notebook(name='tagada', users=[])
        task = Task(notebook=notebook, name='stuff', periodicity=42)
        DBSession.add_all([notebook, task])
        DBSession.flush()

        DBSession.delete(notebook)

        self.assertEqual(Task.query().count(), 0)
예제 #4
0
 def _create_task_and_execute(self, notebook, user, length, time=None):
     t = Task(name='some task', notebook=notebook, periodicity=42)
     t.execute(user, length, time)
     return t