mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-04 05:39:57 -05:00
Fixing archive deleting.
This commit is contained in:
parent
fb1f1c6926
commit
3cb2aaf6cf
10 changed files with 202 additions and 111 deletions
|
|
@ -18,11 +18,11 @@ def test_archives_search(test_session, archive_directory, archive_factory, test_
|
|||
|
||||
# 1 and 2 contain "foo".
|
||||
data = {'search_str': 'foo'}
|
||||
check_results(data, [1, 2])
|
||||
check_results(data, [2, 1])
|
||||
|
||||
# 2 and 3 contain "baz".
|
||||
data = {'search_str': 'baz'}
|
||||
check_results(data, [2, 3])
|
||||
check_results(data, [3, 2])
|
||||
|
||||
# 1 contains "bar".
|
||||
data = {'search_str': 'bar'}
|
||||
|
|
@ -47,3 +47,32 @@ def test_archives_search(test_session, archive_directory, archive_factory, test_
|
|||
# All titles contain "qux", but they contain different amounts. They are ordered by the amount.
|
||||
data = {'search_str': 'qux'}
|
||||
check_results(data, [3, 2, 1])
|
||||
|
||||
|
||||
def test_archives_search_no_query(archive_factory, test_client):
|
||||
"""
|
||||
Archive Search API endpoint does not require data in the body.
|
||||
"""
|
||||
# Add 100 random archives.
|
||||
for _ in range(100):
|
||||
archive_factory('example.com')
|
||||
|
||||
# All archives are returned when no `search_str` is passed.
|
||||
request, response = test_client.post('/api/archive/search')
|
||||
assert response.status_code == HTTPStatus.OK, response.json
|
||||
assert [i['id'] for i in response.json['archives']] == list(range(100, 80, -1))
|
||||
assert response.json['totals']['archives'] == 100
|
||||
|
||||
# All archives are from "example.com".
|
||||
data = dict(domain='example.com')
|
||||
request, response = test_client.post('/api/archive/search', content=json.dumps(data))
|
||||
assert response.status_code == HTTPStatus.OK, response.json
|
||||
assert [i['id'] for i in response.json['archives']] == list(range(100, 80, -1))
|
||||
assert response.json['totals']['archives'] == 100
|
||||
|
||||
# No archives are from "example.org".
|
||||
data = dict(domain='example.org')
|
||||
request, response = test_client.post('/api/archive/search', content=json.dumps(data))
|
||||
assert response.status_code == HTTPStatus.OK, response.json
|
||||
assert [i['id'] for i in response.json['archives']] == []
|
||||
assert response.json['totals']['archives'] == 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue