def test_init_raises(self) -> None: with pytest.raises(TypeError): Task.reconstruct(0, True, Text("Hello")) with pytest.raises(TypeError): Task.reconstruct(uuid.uuid1(), 0, Text("Hello")) with pytest.raises(TypeError): Task.reconstruct(uuid.uuid1(), True, "Hello")
def test_property(self) -> None: string = "Hello" text = Text(string) task = Task.create(text) task.is_done = True task.text = Text(string * 2) assert isinstance(task.id, TaskId) assert task.is_done is True assert task.text.value == string * 2
def test_create(self) -> None: string = "Hello, Hello" text = Text(string) task = Task.create(text) assert isinstance(task.id, TaskId) assert task.is_done is False assert task.text.value == string
def test_init(self) -> None: string = "Test string " t = Text(string) assert t.value == string t.value = string * 2 assert t.value == string * 2
def test_reconstruct(self) -> None: id = TaskId(uuid.uuid1()) is_done = True text = Text("Reconstruct") task = Task.reconstruct(id, is_done, text) assert task.id == id assert task.text.value == "Reconstruct" assert task.is_done is is_done
def update(self, command: TaskUpdateCommand) -> None: target_id = TaskId(command.id) task = self.__task_repository.find(target_id) if task is None: raise ValueError text = Text(command.text) task.text = text task.is_done = command.is_done self.__task_repository.save(task)
def test_init(self) -> None: string = "Hello" text = Text(string) task = Task.create(text) data = TaskData(task) assert data.id == task.id.value assert data.is_done == task.is_done assert data.text == task.text.value
def add(self, text: str) -> None: task = Task.create(Text(text)) self.__task_repository.save(task)
def factory(texts: List[str]) -> List[Task]: return [Task.create(Text(text)) for text in texts]