mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
server/search: add content-checksum
This commit is contained in:
@ -182,6 +182,8 @@ class PostSearchConfig(BaseSearchConfig):
|
||||
'type':
|
||||
search_util.create_str_filter(
|
||||
db.Post.type, _type_transformer),
|
||||
'content-checksum': search_util.create_str_filter(
|
||||
db.Post.checksum),
|
||||
'file-size': search_util.create_num_filter(db.Post.file_size),
|
||||
('image-width', 'width'):
|
||||
search_util.create_num_filter(db.Post.canvas_width),
|
||||
|
@ -365,6 +365,24 @@ def test_filter_by_invalid_type(executor):
|
||||
executor.execute('type:invalid', page=1, page_size=100)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('input,expected_post_ids', [
|
||||
('content-checksum:checksum1', [1]),
|
||||
('content-checksum:checksum3', [3]),
|
||||
('content-checksum:checksum1,checksum3', [1, 3]),
|
||||
])
|
||||
def test_filter_by_content_checksum(
|
||||
verify_unpaged, post_factory, input, expected_post_ids):
|
||||
post1 = post_factory(id=1)
|
||||
post2 = post_factory(id=2)
|
||||
post3 = post_factory(id=3)
|
||||
post1.checksum = 'checksum1'
|
||||
post2.checksum = 'checksum2'
|
||||
post3.checksum = 'checksum3'
|
||||
db.session.add_all([post1, post2, post3])
|
||||
db.session.flush()
|
||||
verify_unpaged(input, expected_post_ids)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('input,expected_post_ids', [
|
||||
('file-size:100', [1]),
|
||||
('file-size:102', [3]),
|
||||
|
Reference in New Issue
Block a user