def test_notebook(self): from augias.views import notebook n = Notebook(name='some notebook') task = Task(name='some task', notebook=n) request = DummyRequest(user=None) result = notebook(n, request) self.assertEqual(list(result['tasks'])[0].name, 'some task')
def test_last_executions_from_other_notebooks_do_not_appear(self): from augias.views import notebook p1 = Notebook(name='some notebook') p2 = Notebook(name='another notebook') user = User(email='*****@*****.**') self._create_task_and_execute(p1, None, 10) request = DummyRequest(user=user) result = notebook(p2, request) self.assertEqual(len(result['last_executions']), 0)
def test_suggest_total_time_of_all_pending_tasks(self): from augias.views import notebook n = Notebook(name='some notebook') user = User(email='*****@*****.**') long_ago = datetime.datetime.utcfromtimestamp(0) self._create_task_and_execute(n, user, 10, long_ago) self._create_task_and_execute(n, user, 10, long_ago) self._create_task_and_execute(n, user, 10, long_ago) request = DummyRequest(user=user) result = notebook(n, request) self.assertEqual(result['urgent_tasks_time'], 30)
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)
def test_suggest_when_execution_in_other_notebook(self): from augias.views import notebook p1 = Notebook(name='some notebook') p2 = Notebook(name='other notebook') user = User(email='*****@*****.**') long_ago = datetime.datetime.utcfromtimestamp(0) self._create_task_and_execute(p1, user, 10, long_ago) self._create_task_and_execute(p2, user, 60) request = DummyRequest(user=user) result = notebook(p1, request) urgent = result['urgent_tasks'] self.assertEqual(len(urgent), 1) self.assertEqual(urgent[0].suggested, True)
def test_suggest_even_when_someone_else_did_something(self): from augias.views import notebook n = Notebook(name='some notebook') user1 = User(email='*****@*****.**') user2 = User(email='*****@*****.**') long_ago = datetime.datetime.utcfromtimestamp(0) self._create_task_and_execute(n, user1, 10, long_ago) self._create_task_and_execute(n, user2, 60) request = DummyRequest(user=user1) result = notebook(n, request) urgent = result['urgent_tasks'] self.assertEqual(len(urgent), 1) self.assertEqual(urgent[0].suggested, True)
def test_suggestions(self): from augias.views import notebook n = Notebook(name='some notebook') user = User(email='*****@*****.**') long_ago = datetime.datetime.utcfromtimestamp(0) self._create_task_and_execute(n, user, 10, long_ago) self._create_task_and_execute(n, user, 10, long_ago) self._create_task_and_execute(n, user, 10, long_ago) request = DummyRequest(user=user) result = notebook(n, request) tasks = result['tasks'] self.assertEqual(tasks[0].suggested, True) self.assertEqual(tasks[1].suggested, True) self.assertEqual(tasks[2].suggested, False)