def test_validate_finished_None(self): l = TodoList() l.add_item(Todo('some text')) l.get_item(1).finished = False l.validate() with pytest.raises(base.ValidationError): l.get_item(1).finished = None l.validate()
def test_validate_nonset_tags(self): l = TodoList() l.add_item(Todo('some text')) l.get_item(1).tags = set(['a', 'b']) l.validate() with pytest.raises(base.ValidationError): l.get_item(1).tags = ['a', 'b'] l.validate()
def test_validate_finished_not_bool(self): l = TodoList() l.add_item(Todo('some text')) l.get_item(1).finished = True l.get_item(1).finished_date = 1234.1234 l.validate() with pytest.raises(base.ValidationError): l.get_item(1).finished = 'ham' l.get_item(1).finished_date = 1234.1234 l.validate()
def test_complete_item_reverse(self): l = TodoList() i1 = Todo('old toto item', oid=3, tags=set(['a', 'b'])) l.add_item(i1, initial_load=True) l.complete_item(3, set_complete=True) assert l.get_item(3).finished assert l.get_item(3).finished_date == 4163.5411422 l.complete_item(3, set_complete=False) assert not l.get_item(3).finished assert not l.get_item(3).finished_date
def test_remove_item_after_initial(self): l = TodoList() i1 = Todo('old toto item', tags=set(['a', 'b'])) l.add_item(i1, initial_load=False) assert l.size() == 1 assert l.get_item(1) == i1 assert l.tag_set == set(['a', 'b']) l.remove_item(1) assert l.size() == 0 with pytest.raises(base.InvalidIDError): l.get_item(1) assert l.tag_set == set()
def test_remove_item(self): l = TodoList() i1 = Todo('old toto item', oid=3, tags=set(['a', 'b'])) l.add_item(i1, initial_load=True) assert l.size() == 1 assert l.get_item(3) == i1 assert l.tag_set == set(['a', 'b']) l.remove_item(3) assert l.size() == 0 with pytest.raises(base.InvalidIDError): l.get_item(3) assert l.tag_set == set() assert l.modified
def test_validate_invalid_priority(self): l = TodoList() l.add_item(Todo('some text')) l.get_item(1).priority = PriorityEnum.URGENT.value l.validate() with pytest.raises(base.ValidationError): l.get_item(1).priority = None l.validate() with pytest.raises(base.ValidationError): l.get_item(1).priority = 16 l.validate() with pytest.raises(base.ValidationError): l.get_item(1).priority = 'cactus' l.validate() l.get_item(1).priority = PriorityEnum.DEFAULT.value l.validate()
def test_get_item_id_inc(self): l = TodoList() i1 = Todo('old toto item', oid=10) i2 = Todo('new toto item') l.add_item(i1, initial_load=True) l.add_item(i2, initial_load=False) assert i2 == l.get_item(11)
def test_get_item_new_item(self): l = TodoList() i1 = Todo('old toto item') i2 = Todo('new toto item') l.add_item(i1, initial_load=False) l.add_item(i2, initial_load=False) assert i2 == l.get_item(2)
def test_get_item_bad_id(self): l = TodoList() i1 = Todo('old toto item', oid=10) l.add_item(i1, initial_load=True) with pytest.raises(base.InvalidIDError): l.get_item(1)