示例#1
0
 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")
示例#2
0
 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
示例#3
0
 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
示例#4
0
    def test_init(self) -> None:
        string = "Test string "
        t = Text(string)
        assert t.value == string

        t.value = string * 2
        assert t.value == string * 2
示例#5
0
 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
示例#6
0
 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)
示例#7
0
    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
示例#8
0
 def add(self, text: str) -> None:
     task = Task.create(Text(text))
     self.__task_repository.save(task)
示例#9
0
 def factory(texts: List[str]) -> List[Task]:
     return [Task.create(Text(text)) for text in texts]