Turn test logs into assert messages

This test file is full of them, and it is probably better to split all of them into their own test cases but it will require a bigger refactoring...
This commit is contained in:
davelopez
2023-05-15 18:58:10 +02:00
parent 09dfcdbb29
commit 1206926ce3
+7 -10
View File
@@ -961,22 +961,19 @@ class TestHistoryFilters(BaseTestCase):
all_histories = [history1, history2, history3, history4]
deleted = [history1, history2, history3]
self.log("no filters should work")
assert self.history_manager.count() == len(all_histories)
self.log("orm filtered should work")
assert self.history_manager.count() == len(all_histories), "having no filters should count all histories"
filters = [model.History.deleted == true()]
assert self.history_manager.count(filters=filters) == len(deleted)
assert self.history_manager.count(filters=filters) == len(deleted), "counting with orm filters should work"
raw_annotation_fn_filter = ("annotation", "has", test_annotation)
self.log("fn filtered is not supported")
with pytest.raises(exceptions.RequestParameterInvalidException) as exc:
# functional filtering is not supported
with pytest.raises(exceptions.RequestParameterInvalidException) as exc_info:
filters = self.filter_parser.parse_filters([raw_annotation_fn_filter])
self.history_manager.count(filters=filters)
assert "not supported" in str(exc)
assert "not supported" in str(exc_info)
raw_deleted_orm_filter = ("deleted", "eq", "True")
self.log("mixin orm and fn filtered is not supported")
with pytest.raises(exceptions.RequestParameterInvalidException) as exc:
with pytest.raises(exceptions.RequestParameterInvalidException) as exc_info:
filters = self.filter_parser.parse_filters([raw_deleted_orm_filter, raw_annotation_fn_filter])
self.history_manager.count(filters=filters)
assert "not supported" in str(exc)
assert "not supported" in str(exc_info)