def test_create_task(ctx, controller, mock_repository: TaskRepository):
    result = ("bla", True)
    mut = TaskMutationRequest(content='content')
    mock_repository.create_task = MagicMock(return_value=result)
    assert result == controller.create_task(ctx,
                                            CreateTaskRequest(mutation=mut))
    mock_repository.create_task.assert_called_once_with(ctx, mut)
def test_delete_task(ctx, controller, mock_repository: TaskRepository):
    mock_repository.delete_task = MagicMock(return_value=True)
    assert True == controller.delete_task(ctx, DeleteTaskRequest(id='test'))
    mock_repository.delete_task.assert_called_once_with(ctx, 'test')
def test_update_task(ctx, controller, mock_repository: TaskRepository):
    mut = TaskMutationRequest(content='content')
    mock_repository.update_task = MagicMock(return_value=True)
    assert True == controller.update_task(
        ctx, UpdateTaskRequest(id='test', mutation=mut))
    mock_repository.update_task.assert_called_once_with(ctx, 'test', mut)
def test_get_task(ctx, controller, mock_repository: TaskRepository):
    result = ("aa", True)
    mock_repository.get_task_by_uuid = MagicMock(return_value=result)
    assert result == controller.get_task(ctx, GetTaskRequest(id='test'))
    mock_repository.get_task_by_uuid.assert_called_once_with(ctx, "test")
Beispiel #5
0
 def setUp(self):
     unittest.TestCase.setUp(self)
     self.repo = TaskRepository()
     self.cont = TaskController(self.repo)
Beispiel #6
0
class Test(unittest.TestCase):

    def setUp(self):
        unittest.TestCase.setUp(self)
        self.repo = TaskRepository()
        self.cont = TaskController(self.repo)

    def testFileReading(self):
        assert(len(self.repo.getAll()) > 0)
        
    def testAddTask(self):
        oL = len(self.repo.getAll());
        t = Task("sample", "done");
        self.repo.addTask(t);
        nL = len(self.repo.getAll());
        assert(oL + 1 == nL);
        
    def testRemoveTask(self):
        oL = len(self.repo.getAll());
        self.repo.removeTask(1)
        nL = len(self.repo.getAll());
        assert(oL - 1 == nL);
        
    def testUndo(self):
        oL = len(self.repo.getAll());
        t = Task("sample", "done");
        self.repo.addTask(t);
        self.repo.undo()
        nL = len(self.repo.getAll());
        assert(oL  == nL);

    def testRedo(self):
        oL = len(self.repo.getAll());
        t = Task("sample", "done");
        self.repo.addTask(t);
        self.repo.undo()
        self.repo.redo();
        self.repo.redo();
        nL = len(self.repo.getAll());
        assert(oL + 1  == nL);

    def testNonFilter(self):
        oL = len(self.repo.getAll());
        t = Task("sample", "done");
        self.repo.addTask(t);
        self.repo.undo()
        self.repo.redo();
        self.repo.redo();
        nL = len(self.repo.getAll());
        assert(oL + 1  == nL);
        
    def testGetNonFilter(self):
        totalLength = len(self.repo.getAll());
        openLength = len(self.cont.getNonFilterTasks("active"));
        archivedLength = len(self.cont.getNonFilterTasks("archived"));
        doneLength = len(self.cont.getNonFilterTasks("done"));
        assert(totalLength == (openLength + archivedLength + doneLength));