Skip to content
Snippets Groups Projects
Commit 1f64088b authored by Thomas Kluyver's avatar Thomas Kluyver
Browse files

Add unit test for wait_on_transfer

parent 72e8daf1
No related branches found
No related tags found
1 merge request!435Use asyncio subprocess interface in webservice code
......@@ -8,5 +8,5 @@ pytest:
stage: test
script:
- python3 -m pip install --user -r requirements.txt
- python3 -m pip install --user pytest
- python3 -m pip install --user pytest pytest-asyncio testpath
- pytest -vv tests/test_*
import sys
from pathlib import Path
from testpath import MockCommand
from unittest import mock
import pytest
sys.path.insert(0, Path(__file__).parent / 'webservice')
from webservice.webservice import check_files, merge, parse_config # noqa
from webservice.webservice import (
check_files, merge, parse_config, wait_on_transfer,
)
def test_check_files():
......@@ -63,3 +67,14 @@ def test_parse_config():
with pytest.raises(ValueError):
config = {'somekey': 'a value'}
config = parse_config(cmd, config)
@pytest.mark.asyncio
async def test_wait_on_transfer(tmp_path):
mock_getfattr = MockCommand(
'getfattr',
content="""#!{}\nprint('user.status="dCache"')""".format(sys.executable)
)
with mock.patch('asyncio.sleep'), mock_getfattr:
res = await wait_on_transfer(tmp_path, max_tries=1)
assert res is True
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment