コード例 #1
0
ファイル: test_dao.py プロジェクト: lhaze/dharma
 def test_update_all(self, dao: InMemoryDao):
     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},
     ]
コード例 #2
0
ファイル: test_dao.py プロジェクト: lhaze/dharma
 def test_update_none(self, dao: InMemoryDao):
     ids = dao.filter(pred_z).update(char='z')
     assert ids == []
     assert list(dao.all()) == [
         {'char': 'a', 'is_a': True},
         {'char': 'b', 'is_a': False},
         {'char': 'c', 'is_a': False},
     ]
コード例 #3
0
ファイル: test_dao.py プロジェクト: lhaze/dharma
 def test_update_filtered_by_id(self, dao: InMemoryDao):
     ids = dao.filter(pred_not_a).filter_by(id_=2).update(char='z')
     assert ids == [2]
     assert list(dao.all()) == [
         {'char': 'a', 'is_a': True},
         {'char': 'z', 'is_a': False},
         {'char': 'c', 'is_a': False},
     ]
コード例 #4
0
 def test_update_all(self, dao: InMemoryDao):
     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
         },
     ]
コード例 #5
0
 def test_update_all(self, dao: InMemoryDao):
     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
         },
     ]
コード例 #6
0
 def test_update_none(self, dao: InMemoryDao):
     ids = dao.filter(pred_z).update(char="z")
     assert ids == []
     assert list(dao.all()) == [
         {
             "char": "a",
             "is_a": True
         },
         {
             "char": "b",
             "is_a": False
         },
         {
             "char": "c",
             "is_a": False
         },
     ]
コード例 #7
0
 def test_update_none(self, dao: InMemoryDao):
     ids = dao.filter(pred_z).update(char='z')
     assert ids == []
     assert list(dao.all()) == [
         {
             'char': 'a',
             'is_a': True
         },
         {
             'char': 'b',
             'is_a': False
         },
         {
             'char': 'c',
             'is_a': False
         },
     ]
コード例 #8
0
 def test_update_filtered_by_id(self, dao: InMemoryDao):
     ids = dao.filter(pred_not_a).filter_by(id_=2).update(char='z')
     assert ids == [2]
     assert list(dao.all()) == [
         {
             'char': 'a',
             'is_a': True
         },
         {
             'char': 'z',
             'is_a': False
         },
         {
             'char': 'c',
             'is_a': False
         },
     ]
コード例 #9
0
 def test_update_filtered_by_id(self, dao: InMemoryDao):
     ids = dao.filter(pred_not_a).filter_by(id_=2).update(char="z")
     assert ids == [2]
     assert list(dao.all()) == [
         {
             "char": "a",
             "is_a": True
         },
         {
             "char": "z",
             "is_a": False
         },
         {
             "char": "c",
             "is_a": False
         },
     ]
コード例 #10
0
ファイル: test_dao.py プロジェクト: lhaze/dharma
 def test_initial_content(self, mock_container, content):
     dao = InMemoryDao(mock_container, initial_content=content)
     assert list(dao.all()) == content
コード例 #11
0
ファイル: test_dao.py プロジェクト: lhaze/dharma
 def test_remove_all_error(self, dao: InMemoryDao):
     with pytest.raises(QueryError) as error_info:
         dao.all().remove()
     assert error_info.value == QueryErrors.UNRESTRICTED_REMOVE
コード例 #12
0
 def test_remove_all_error(self, dao: InMemoryDao):
     with pytest.raises(InvalidQueryError):
         dao.all().remove()
コード例 #13
0
 def test_exists_empty_fail(self, dao: InMemoryDao):
     dao.clear()
     assert not dao.all().exists()
コード例 #14
0
 def test_all(self, dao: InMemoryDao):
     assert get_ids(dao.all()) == [1, 2, 3]
コード例 #15
0
 def test_filter_by_two_times_error(self, dao: InMemoryDao):
     with pytest.raises(QueryError):
         assert dao.all().filter_by(id_=3).filter_by(id_=5)
コード例 #16
0
 def test_remove_filtered_by_id(self, dao: InMemoryDao):
     ids = dao.filter(pred_not_a).filter_by(id_=2).remove()
     assert ids == [2]
     assert get_ids(dao.all()) == [1, 3]
コード例 #17
0
 def test_clear(self, dao: InMemoryDao):
     dao.clear()
     assert list(dao.all()) == []
コード例 #18
0
 def test_remove_all_error(self, dao: InMemoryDao):
     with pytest.raises(QueryError) as error_info:
         dao.all().remove()
     assert error_info.value == QueryErrors.UNRESTRICTED_REMOVE
コード例 #19
0
ファイル: test_dao.py プロジェクト: lhaze/dharma
 def test_clear(self, dao: InMemoryDao):
     dao.clear()
     assert list(dao.all()) == []
コード例 #20
0
ファイル: test_dao.py プロジェクト: lhaze/dharma
 def test_remove_none(self, dao: InMemoryDao):
     ids = dao.filter(pred_z).remove()
     assert ids == []
     assert get_ids(dao.all()) == [1, 2, 3]
コード例 #21
0
ファイル: test_dao.py プロジェクト: lhaze/dharma
 def test_remove_filtered_by_id(self, dao: InMemoryDao):
     ids = dao.filter(pred_not_a).filter_by(id_=2).remove()
     assert ids == [2]
     assert get_ids(dao.all()) == [1, 3]
コード例 #22
0
ファイル: test_dao.py プロジェクト: lhaze/dharma
 def test_remove_filtered(self, dao: InMemoryDao):
     ids = dao.filter(pred_a).remove()
     assert ids == [1]
     assert get_ids(dao.all()) == [2, 3]
コード例 #23
0
 def test_remove_filtered(self, dao: InMemoryDao):
     ids = dao.filter(pred_a).remove()
     assert ids == [1]
     assert get_ids(dao.all()) == [2, 3]
コード例 #24
0
ファイル: test_dao.py プロジェクト: lhaze/dharma
 def test_all(self, dao: InMemoryDao):
     assert get_ids(dao.all()) == [1, 2, 3]
コード例 #25
0
 def test_remove_none(self, dao: InMemoryDao):
     ids = dao.filter(pred_z).remove()
     assert ids == []
     assert get_ids(dao.all()) == [1, 2, 3]
コード例 #26
0
ファイル: test_dao.py プロジェクト: lhaze/dharma
 def test_filter_by_both_arguments_error(self, dao: InMemoryDao):
     with pytest.raises(QueryError):
         assert dao.all().filter_by(id_=3, ids=[3, 5])
コード例 #27
0
 def test_initial_content(self, mock_container, content):
     dao = InMemoryDao(mock_container, initial_content=content)
     assert list(dao.all()) == content
コード例 #28
0
ファイル: test_dao.py プロジェクト: lhaze/dharma
 def test_filter_by_two_times_error(self, dao: InMemoryDao):
     with pytest.raises(QueryError):
         assert dao.all().filter_by(id_=3).filter_by(id_=5)
コード例 #29
0
 def test_filter_by_both_arguments_error(self, dao: InMemoryDao):
     with pytest.raises(QueryError):
         assert dao.all().filter_by(id_=3, ids=[3, 5])
コード例 #30
0
ファイル: test_dao.py プロジェクト: lhaze/dharma
 def test_exists_all_success(self, dao: InMemoryDao):
     assert dao.all().exists()
コード例 #31
0
 def test_exists_all_success(self, dao: InMemoryDao):
     assert dao.all().exists()
コード例 #32
0
ファイル: test_dao.py プロジェクト: lhaze/dharma
 def test_exists_empty_fail(self, dao: InMemoryDao):
     dao.clear()
     assert not dao.all().exists()
コード例 #33
0
 def test_count_all(self, dao: InMemoryDao):
     assert dao.all().count() == 3
コード例 #34
0
ファイル: test_dao.py プロジェクト: lhaze/dharma
 def test_count_all(self, dao: InMemoryDao):
     assert dao.all().count() == 3