def test_remove_error_wrong_id(self, data, repo: Repository, dao: IDao): id_ = dao.insert(**data) entity = repo.find(id_) repo.remove(entity) with pytest.raises(QueryError) as error_info: repo.remove(entity) assert error_info.value == QueryErrors.NOT_FOUND assert error_info.value.params == {'id': id_, 'entity': entity}
def test_remove_error_wrong_id(self, data, repo: Repository, dao: IDao): id_ = dao.insert(**data) entity = repo.find(id_) repo.remove(entity) with pytest.raises(QueryError) as error_info: repo.remove(entity) assert error_info.value == QueryErrors.NOT_FOUND assert error_info.value.params == {'id': id_, 'entity': entity}
def test_remove_error_not_added(self, data, repo: Repository, dao: IDao): entity = repo.create(**data) with pytest.raises(QueryError) as error_info: repo.remove(entity) assert error_info.value == QueryErrors.NOT_FOUND assert error_info.value.params == { "id": entity.__get_id__(), "entity": entity }
def test_remove_error_not_added(self, data, repo: Repository, dao: IDao): entity = repo.create(**data) with pytest.raises(QueryError) as error_info: repo.remove(entity) assert error_info.value == QueryErrors.ENTITY_NOT_YET_ADDED assert error_info.value.params == {'entity': entity}
def test_remove_success(self, data, repo: Repository, dao: IDao): id_ = dao.insert(**data) entity = repo.find(id_) assert dao.filter_by(id_=id_).exists() repo.remove(entity) assert not dao.filter_by(id_=id_).exists()
def test_remove_error_not_added(self, data, repo: Repository, dao: IDao): entity = repo.create(**data) with pytest.raises(QueryError) as error_info: repo.remove(entity) assert error_info.value == QueryErrors.ENTITY_NOT_YET_ADDED assert error_info.value.params == {'entity': entity}
def test_remove_success(self, data, repo: Repository, dao: IDao): id_ = dao.insert(**data) entity = repo.find(id_) assert dao.filter_by(id_=id_).exists() repo.remove(entity) assert not dao.filter_by(id_=id_).exists()
def test_remove_error_wrong_id(self, data, repo: Repository, dao: IDao): id_ = dao.insert(**data) entity = repo.find(id_) repo.remove(entity) with pytest.raises(InvalidQueryError): repo.remove(entity)
def test_remove_error_not_added(self, data, repo: Repository, dao: IDao): entity = repo.create(**data) with pytest.raises(InvalidQueryError): repo.remove(entity)