mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-22 16:06:19 -05:00
Creating background_task function to keep set of tasks from being cleaned up during garbage collection.
This commit is contained in:
parent
6fa6be50fe
commit
1230a3056d
11 changed files with 65 additions and 43 deletions
|
|
@ -7,7 +7,7 @@ from sanic_ext import validate
|
|||
from sanic_ext.extensions.openapi import openapi
|
||||
|
||||
from modules.map import lib, schema
|
||||
from wrolpi.common import wrol_mode_check, get_media_directory
|
||||
from wrolpi.common import wrol_mode_check, get_media_directory, background_task
|
||||
from wrolpi.errors import ValidationError
|
||||
from wrolpi.root_api import get_blueprint, json_response
|
||||
from wrolpi.vars import PYTEST, DOCKERIZED
|
||||
|
|
@ -34,7 +34,7 @@ async def import_pbfs(_: Request, body: schema.ImportPost):
|
|||
if PYTEST:
|
||||
await coro
|
||||
else:
|
||||
asyncio.create_task(coro)
|
||||
background_task(coro)
|
||||
return response.empty()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -86,17 +86,8 @@ def test_status_and_import(test_client, test_session, test_directory):
|
|||
def test_empty_import(test_client, test_session, test_directory):
|
||||
"""Some files must be requested."""
|
||||
with mock.patch('modules.map.lib.import_file') as mock_import_file:
|
||||
body = {'pbfs': []}
|
||||
request, response = test_client.post('/api/map/import', content=json.dumps(body))
|
||||
assert response.status_code == HTTPStatus.BAD_REQUEST
|
||||
mock_import_file.assert_not_called()
|
||||
|
||||
body = {'dumps': []}
|
||||
request, response = test_client.post('/api/map/import', content=json.dumps(body))
|
||||
assert response.status_code == HTTPStatus.BAD_REQUEST
|
||||
mock_import_file.assert_not_called()
|
||||
|
||||
body = {'pbfs': [], 'dumps': []}
|
||||
body = {'files': []}
|
||||
request, response = test_client.post('/api/map/import', content=json.dumps(body))
|
||||
assert response.status_code == HTTPStatus.BAD_REQUEST
|
||||
mock_import_file.assert_not_called()
|
||||
assert 'validate' in response.json['error']
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue