Example #1
0
 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},
     ]
Example #2
0
 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},
     ]
Example #3
0
 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_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},
     ]
Example #6
0
 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},
     ]
Example #7
0
 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},
     ]
Example #8
0
 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_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},
     ]
Example #11
0
 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},
     ]
Example #12
0
 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},
     ]
Example #13
0
 def test_filtered_count(self, dao: TinyDbDao):
     assert dao.filter(pred_not_a).count() == 2
Example #14
0
 def test_exists_filtered_fail(self, dao: TinyDbDao):
     assert not dao.filter(pred_z).exists()
Example #15
0
 def test_exists_filtered_success(self, dao: TinyDbDao):
     assert dao.filter(pred_c).exists()
Example #16
0
 def test_filtered_get_fail(self, dao: TinyDbDao):
     assert dao.filter(pred_not_a).get(1) is None
Example #17
0
 def test_filtered_get_success(self, dao: TinyDbDao):
     object_2 = dao.get(2)
     assert dao.filter(pred_not_a).get(2) == object_2
 def test_filtered_get_success(self, dao: TinyDbDao):
     object_2 = dao.get(2)
     assert dao.filter(pred_not_a).get(2) == object_2
 def test_multiple_filter_success(self, dao: TinyDbDao):
     assert list(dao.filter(pred_not_a).filter(pred_c)) == [{
         'char': 'c',
         'is_a': False
     }]
 def test_batch_insert(self, dao: TinyDbDao):
     batch = [{'foo': 'bar'}, {'foo': 'baz'}]
     result = dao.batch_insert(batch)
     assert result == (4, 5)
     assert list(dao.filter(where('foo').exists())) == batch
Example #21
0
 def test_multiple_filter_success(self, dao: TinyDbDao):
     assert list(dao.filter(pred_not_a).filter(pred_c)) == [{"char": "c", "is_a": False}]
Example #22
0
 def test_multiple_filter_success(self, dao: TinyDbDao):
     assert list(dao.filter(pred_not_a).filter(pred_c)) == [
         {'char': 'c', 'is_a': False}
     ]
 def test_filtered_get_fail(self, dao: TinyDbDao):
     assert dao.filter(pred_not_a).get(1) is None
Example #24
0
 def test_batch_insert(self, dao: TinyDbDao):
     batch = [{"foo": "bar"}, {"foo": "baz"}]
     result = dao.batch_insert(batch)
     assert result == (4, 5)
     assert list(dao.filter(where("foo").exists())) == batch
 def test_filter_by_success(self, dao: TinyDbDao):
     not_a = pred_not_a
     assert list(dao.filter(not_a).filter_by(id_=3)) == [{
         'char': 'c',
         'is_a': False
     }]
 def test_exists_filtered_success(self, dao: TinyDbDao):
     assert dao.filter(pred_c).exists()
Example #27
0
 def test_filter_by_success(self, dao: TinyDbDao):
     not_a = pred_not_a
     assert list(dao.filter(not_a).filter_by(id_=3)) == [{"char": "c", "is_a": False}]
Example #28
0
 def test_batch_insert(self, dao: TinyDbDao):
     batch = [{'foo': 'bar'}, {'foo': 'baz'}]
     result = dao.batch_insert(batch)
     assert result == (4, 5)
     assert list(dao.filter(where('foo').exists())) == batch
 def test_exists_filtered_fail(self, dao: TinyDbDao):
     assert not dao.filter(pred_z).exists()
Example #30
0
 def test_filter_by_success(self, dao: TinyDbDao):
     not_a = pred_not_a
     assert list(dao.filter(not_a).filter_by(id_=3)) == [{'char': 'c', 'is_a': False}]
 def test_filtered_count(self, dao: TinyDbDao):
     assert dao.filter(pred_not_a).count() == 2