示例#1
0
    def test_project_key_property(self):
        task = Task(
            key=TaskKey.build_by_id(task_id=1),
            name=TaskName("Task Name"),
            project_key=None,
            finished_at=None,
            created_at=datetime.datetime(2019,
                                         12,
                                         1,
                                         0,
                                         0,
                                         0,
                                         tzinfo=datetime.timezone.utc),
            updated_at=datetime.datetime(2019,
                                         12,
                                         1,
                                         0,
                                         0,
                                         0,
                                         tzinfo=datetime.timezone.utc),
        )
        assert not task.project_key

        project = Project(
            key=ProjectKey.build_by_id(project_id=1),
            name=ProjectName("Project Name"),
            created_at=datetime.datetime(2019,
                                         12,
                                         1,
                                         0,
                                         0,
                                         0,
                                         tzinfo=datetime.timezone.utc),
        )

        finished_task = Task(
            key=TaskKey.build_by_id(task_id=1),
            name=TaskName("Task Name"),
            project_key=project.key,
            finished_at=None,
            created_at=datetime.datetime(2019,
                                         12,
                                         1,
                                         0,
                                         0,
                                         0,
                                         tzinfo=datetime.timezone.utc),
            updated_at=datetime.datetime(2019,
                                         12,
                                         1,
                                         0,
                                         0,
                                         0,
                                         tzinfo=datetime.timezone.utc),
        )

        assert finished_task.key
示例#2
0
    def test_finished_property(self):
        task = Task(
            key=TaskKey.build_by_id(task_id=1),
            name=TaskName("Task Name"),
            project_key=None,
            finished_at=None,
            created_at=datetime.datetime(2019,
                                         12,
                                         1,
                                         0,
                                         0,
                                         0,
                                         tzinfo=datetime.timezone.utc),
            updated_at=datetime.datetime(2019,
                                         12,
                                         1,
                                         0,
                                         0,
                                         0,
                                         tzinfo=datetime.timezone.utc),
        )

        assert not task.is_finished

        finished_task = Task(
            key=TaskKey.build_by_id(task_id=1),
            name=TaskName("Task Name"),
            project_key=None,
            finished_at=datetime.datetime(2019,
                                          12,
                                          2,
                                          0,
                                          0,
                                          0,
                                          tzinfo=datetime.timezone.utc),
            created_at=datetime.datetime(2019,
                                         12,
                                         1,
                                         0,
                                         0,
                                         0,
                                         tzinfo=datetime.timezone.utc),
            updated_at=datetime.datetime(2019,
                                         12,
                                         1,
                                         0,
                                         0,
                                         0,
                                         tzinfo=datetime.timezone.utc),
        )

        assert finished_task.is_finished
    def post(self, task_id):
        task_key = TaskKey.build_by_id(task_id=task_id)
        task_name: str = flask.request.form.get("new_task_name", "")
        service: TaskNameUpdateService = injector.get(TaskNameUpdateService)
        service.execute(key=task_key, task_name=task_name)

        return flask.redirect("/tasks")
示例#4
0
    def post(self, task_id):
        task_key = TaskKey.build_by_id(task_id=task_id)
        project_id: str = flask.request.form.get("project_id", "")
        service: TaskProjectUpdateService = injector.get(TaskProjectUpdateService)
        service.execute(key=task_key, project_id=project_id)

        return flask.redirect("/tasks")
    def post(self, task_id):
        task_key = TaskKey.build_by_id(task_id=task_id)
        finished = flask.request.form.get("finished", "false") == "true"
        service: TaskStatusUpdateService = injector.get(
            TaskStatusUpdateService)
        service.execute(key=task_key, finished=finished)
        print(flask.request.path)

        return flask.redirect("/")
示例#6
0
    def post(self, task_id):
        task_key = TaskKey.build_by_id(task_id=task_id)
        finished = flask.request.form.get("finished", "false") == "true"
        redirect_to = flask.request.form.get("redirectTo", "/tasks")
        if not redirect_to.startswith("/"):
            redirect_to = "/tasks"

        service: TaskStatusUpdateService = injector.get(TaskStatusUpdateService)
        service.execute(key=task_key, finished=finished)

        return flask.redirect(redirect_to)
示例#7
0
    def test_save(self):
        self.cleanup_entities()
        assert self.count_entities() == 0

        task = Task(
            key=TaskKey.build_by_id(task_id=123),
            name=TaskName("Task Name"),
            finished_at=None,
            project_key=None,
            created_at=datetime.datetime(2019, 12, 1, tzinfo=datetime.timezone.utc),
            updated_at=datetime.datetime(2019, 12, 1, tzinfo=datetime.timezone.utc),
        )
        self.repository.save(task=task)
        assert self.count_entities() == 1
示例#8
0
 def test_build_failure(self):
     with pytest.raises(expected_exception=TypeValidationError):
         Task(
             key=TaskKey.build_by_id(task_id=1),
             name='task name',
             project_key=None,
             finished_at=None,
             created_at=datetime.datetime(2019,
                                          12,
                                          1,
                                          0,
                                          0,
                                          0,
                                          tzinfo=datetime.timezone.utc),
             updated_at=datetime.datetime(2019,
                                          12,
                                          1,
                                          0,
                                          0,
                                          0,
                                          tzinfo=datetime.timezone.utc),
         )
示例#9
0
 def test_build_successful(self):
     task = Task(
         key=TaskKey.build_by_id(task_id=1),
         name=TaskName("Task Name"),
         project_key=None,
         finished_at=None,
         created_at=datetime.datetime(2019,
                                      12,
                                      1,
                                      0,
                                      0,
                                      0,
                                      tzinfo=datetime.timezone.utc),
         updated_at=datetime.datetime(2019,
                                      12,
                                      1,
                                      0,
                                      0,
                                      0,
                                      tzinfo=datetime.timezone.utc),
     )
     assert isinstance(task, Task)
示例#10
0
 def test_equal(self):
     key1 = TaskKey.build_by_id(task_id=1)
     key2 = TaskKey.build_by_id(task_id=1)
     assert key1 == key2
     assert key1.task_id == 1
    def post(self, task_id):
        task_key = TaskKey.build_by_id(task_id=task_id)
        repository: TaskRepository = injector.get(TaskRepository)
        repository.delete(key=task_key)

        return flask.redirect("/tasks")