Beispiel #1
0
 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}
Beispiel #2
0
 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}
Beispiel #3
0
 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()
Beispiel #4
0
 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)
Beispiel #5
0
 def test_contains_success(self, data, repo: Repository, dao: IDao):
     id_ = dao.insert(**data)
     assert repo.contains(id_)
Beispiel #6
0
 def test_update_success(self, data, repo: Repository, dao: IDao):
     id_ = dao.insert(**data)
     entity = repo.find(id_)
     entity.frame_type = 'road'
     repo.update(entity)
     assert dao.get(id_) == {'frame_type': 'road', 'wheel_type': 'road'}
Beispiel #7
0
 def test_create_and_add(self, data, repo: Repository, dao: IDao):
     entity = repo.create_and_add(**data)
     assert dao.get(entity.id) == data
Beispiel #8
0
 def test_find_success(self, data, repo: Repository, dao: IDao):
     id_ = dao.insert(**data)
     entity = repo.find(id_)
     assert isinstance(entity, Bike)
     assert dataclasses.asdict(entity) == data
Beispiel #9
0
 def test_create(self, data, repo: Repository, dao: IDao):
     entity = repo.create(**data)
     assert repo.schema.deconstruct(entity) == data
     assert dao.all().count() == 0
Beispiel #10
0
 def test_add(self, data, repo: Repository, dao: IDao):
     entity = Bike(**data)
     id_ = repo.add(entity)
     assert dao.get(id_) == data
Beispiel #11
0
 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()
Beispiel #12
0
 def test_create(self, data, repo: Repository, dao: IDao):
     entity = repo.create(**data)
     assert repo.schema.deconstruct(entity) == data
     assert dao.all().count() == 0
Beispiel #13
0
 def test_update_success(self, data, repo: Repository, dao: IDao):
     id_ = dao.insert(**data)
     entity = repo.find(id_)
     entity.frame_type = 'road'
     repo.update(entity)
     assert dao.get(id_) == {'frame_type': 'road', 'wheel_type': 'road'}
Beispiel #14
0
 def test_contains_success(self, data, repo: Repository, dao: IDao):
     id_ = dao.insert(**data)
     assert repo.contains(id_)
Beispiel #15
0
 def test_find_success(self, data, repo: Repository, dao: IDao):
     id_ = dao.insert(**data)
     entity = repo.find(id_)
     assert isinstance(entity, Bike)
     assert dataclasses.asdict(entity) == data
Beispiel #16
0
 def test_create_and_add(self, data, repo: Repository, dao: IDao):
     entity = repo.create_and_add(**data)
     assert dao.get(entity.id) == data
Beispiel #17
0
 def test_add(self, data, repo: Repository, dao: IDao):
     entity = Bike(**data)
     id_ = repo.add(entity)
     assert dao.get(id_) == data