def test_update_all(self, dao: TinyDbDao): ids = dao.all().update(char='z') assert ids == [1, 2, 3] assert list(dao.all()) == [ {'char': 'z', 'is_a': True}, {'char': 'z', 'is_a': False}, {'char': 'z', 'is_a': False}, ]
def test_update_all(self, dao: TinyDbDao): ids = dao.all().update(char="z") assert ids == [1, 2, 3] assert list(dao.all()) == [ {"char": "z", "is_a": True}, {"char": "z", "is_a": False}, {"char": "z", "is_a": False}, ]
def test_update_all(self, dao: TinyDbDao): ids = dao.all().update(char='z') assert ids == [1, 2, 3] assert list(dao.all()) == [ {'char': 'z', 'is_a': True}, {'char': 'z', 'is_a': False}, {'char': 'z', 'is_a': False}, ]
def test_remove_filtered_by_id(self, dao: TinyDbDao): ids = dao.filter(pred_not_a).filter_by(id_=2).remove() assert ids == [2] assert list(dao.all()) == [ {"char": "a", "is_a": True}, {"char": "c", "is_a": False}, ]
def test_remove_filtered(self, dao: TinyDbDao): ids = dao.filter(pred_a).remove() assert ids == [1] assert list(dao.all()) == [ {"char": "b", "is_a": False}, {"char": "c", "is_a": False}, ]
def test_remove_filtered(self, dao: TinyDbDao): ids = dao.filter(pred_a).remove() assert ids == [1] assert list(dao.all()) == [ {'char': 'b', 'is_a': False}, {'char': 'c', 'is_a': False}, ]
def test_remove_filtered_by_id(self, dao: TinyDbDao): ids = dao.filter(pred_not_a).filter_by(id_=2).remove() assert ids == [2] assert list(dao.all()) == [ {'char': 'a', 'is_a': True}, {'char': 'c', 'is_a': False}, ]
def test_remove_filtered(self, dao: TinyDbDao): ids = dao.filter(pred_a).remove() assert ids == [1] assert list(dao.all()) == [ {'char': 'b', 'is_a': False}, {'char': 'c', 'is_a': False}, ]
def test_remove_filtered_by_id(self, dao: TinyDbDao): ids = dao.filter(pred_not_a).filter_by(id_=2).remove() assert ids == [2] assert list(dao.all()) == [ {'char': 'a', 'is_a': True}, {'char': 'c', 'is_a': False}, ]
def test_update_filtered(self, dao: TinyDbDao): ids = dao.filter(pred_not_a).update(char="z") assert ids == [2, 3] assert list(dao.all()) == [ {"char": "a", "is_a": True}, {"char": "z", "is_a": False}, {"char": "z", "is_a": False}, ]
def test_remove_none(self, dao: TinyDbDao): ids = dao.filter(pred_z).remove() assert ids == [] assert list(dao.all()) == [ {'char': 'a', 'is_a': True}, {'char': 'b', 'is_a': False}, {'char': 'c', 'is_a': False}, ]
def test_remove_none(self, dao: TinyDbDao): ids = dao.filter(pred_z).remove() assert ids == [] assert list(dao.all()) == [ {"char": "a", "is_a": True}, {"char": "b", "is_a": False}, {"char": "c", "is_a": False}, ]
def test_remove_none(self, dao: TinyDbDao): ids = dao.filter(pred_z).remove() assert ids == [] assert list(dao.all()) == [ {'char': 'a', 'is_a': True}, {'char': 'b', 'is_a': False}, {'char': 'c', 'is_a': False}, ]
def test_update_filtered(self, dao: TinyDbDao): ids = dao.filter(pred_not_a).update(char='z') assert ids == [2, 3] assert list(dao.all()) == [ {'char': 'a', 'is_a': True}, {'char': 'z', 'is_a': False}, {'char': 'z', 'is_a': False}, ]
def test_update_filtered(self, dao: TinyDbDao): ids = dao.filter(pred_not_a).update(char='z') assert ids == [2, 3] assert list(dao.all()) == [ {'char': 'a', 'is_a': True}, {'char': 'z', 'is_a': False}, {'char': 'z', 'is_a': False}, ]
def test_all(self, dao: TinyDbDao): assert list(dao.all()) == [ { 'char': 'a', 'is_a': True }, { 'char': 'b', 'is_a': False }, { 'char': 'c', 'is_a': False }, ]
def test_filter_by_both_arguments_error(self, dao: TinyDbDao): with pytest.raises(InvalidQueryError): assert dao.all().filter_by(id_=3, ids=[3, 5])
def test_remove_all_error(self, dao: TinyDbDao): with pytest.raises(QueryError) as error_info: dao.all().remove() assert error_info.value == QueryErrors.UNRESTRICTED_REMOVE
def test_filter_by_two_times_error(self, dao: TinyDbDao): with pytest.raises(InvalidQueryError): assert dao.all().filter_by(id_=3).filter_by(id_=5)
def test_count_all(self, dao: TinyDbDao): assert dao.all().count() == 3
def test_exists_empty_fail(self, dao: TinyDbDao): dao.clear() assert not dao.all().exists()
def test_filter_by_both_arguments_error(self, dao: TinyDbDao): with pytest.raises(QueryError) as error_info: assert dao.all().filter_by(id_=3, ids=[3, 5]) assert error_info.value == QueryErrors.CONFLICTING_QUERY_ARGUMENTS
def test_clear(self, dao: TinyDbDao): dao.clear() assert list(dao.all()) == []
def test_remove_all_error(self, dao: TinyDbDao): with pytest.raises(QueryError) as error_info: dao.all().remove() assert error_info.value == QueryErrors.UNRESTRICTED_REMOVE
def test_count_all(self, dao: TinyDbDao): assert dao.all().count() == 3
def test_filter_by_both_arguments_error(self, dao: TinyDbDao): with pytest.raises(QueryError) as error_info: assert dao.all().filter_by(id_=3, ids=[3, 5]) assert error_info.value == QueryErrors.CONFLICTING_QUERY_ARGUMENTS
def test_clear(self, dao: TinyDbDao): dao.clear() assert list(dao.all()) == []
def test_remove_all_error(self, dao: TinyDbDao): with pytest.raises(InvalidQueryError): dao.all().remove()
def test_exists_all_success(self, dao: TinyDbDao): assert dao.all().exists()
def test_filter_by_two_times_error(self, dao: TinyDbDao): with pytest.raises(QueryError) as error_info: assert dao.all().filter_by(id_=3).filter_by(id_=5) assert error_info.value == QueryErrors.CONFLICTING_QUERY_ARGUMENTS
def test_all(self, dao: TinyDbDao): assert list(dao.all()) == [ {"char": "a", "is_a": True}, {"char": "b", "is_a": False}, {"char": "c", "is_a": False}, ]
def test_all(self, dao: TinyDbDao): assert list(dao.all()) == [ {'char': 'a', 'is_a': True}, {'char': 'b', 'is_a': False}, {'char': 'c', 'is_a': False}, ]
def test_exists_all_success(self, dao: TinyDbDao): assert dao.all().exists()
def test_filter_by_two_times_error(self, dao: TinyDbDao): with pytest.raises(QueryError) as error_info: assert dao.all().filter_by(id_=3).filter_by(id_=5) assert error_info.value == QueryErrors.CONFLICTING_QUERY_ARGUMENTS
def test_exists_empty_fail(self, dao: TinyDbDao): dao.clear() assert not dao.all().exists()