|
| 1 | +# noinspection PyPackageRequirements |
1 | 2 | import pytest as pt |
2 | | - |
| 3 | +import os |
| 4 | +import shutil as sh |
3 | 5 | import kegg_pull.kegg_url as ku |
4 | 6 |
|
5 | 7 |
|
6 | 8 | @pt.fixture(autouse=True) |
7 | 9 | def mock_organism_set(mocker, request): |
8 | | - if not 'disable_mock_organism_set' in request.keywords: |
| 10 | + if 'disable_mock_organism_set' not in request.keywords: |
9 | 11 | organism_set_mock = {'organism-code', 'organism-T-number'} |
| 12 | + mocker.patch.object(ku.AbstractKEGGurl, 'organism_set', organism_set_mock) |
| 13 | + |
| 14 | + |
| 15 | +@pt.fixture(name='output_file', params=['dir/subdir/file.txt', 'dir/file.txt', './file.txt', 'file.txt']) |
| 16 | +def get_output_file(request): |
| 17 | + output_file: str = request.param |
| 18 | + yield output_file |
| 19 | + os.remove(output_file) |
| 20 | + sh.rmtree('dir', ignore_errors=True) |
| 21 | + |
| 22 | + |
| 23 | +@pt.fixture(name='zip_archive_data', params=['file.txt', 'dir/file.txt', '/file.txt', '/dir/file.txt']) |
| 24 | +def get_zip_archive_data(request): |
| 25 | + zip_file_name: str = request.param |
| 26 | + zip_archive_path = 'archive.zip' |
| 27 | + yield zip_archive_path, zip_file_name |
| 28 | + os.remove(zip_archive_path) |
| 29 | + |
10 | 30 |
|
11 | | - mocker.patch.object( |
12 | | - ku.AbstractKEGGurl, 'organism_set', organism_set_mock |
13 | | - ) |
| 31 | +@pt.fixture(name='json_file_path', params=[ |
| 32 | + 'dir/subdir/file.json', 'dir/file.json', './file.json', 'file.json', 'archive.zip:file.json', 'archive.zip:dir/file.json']) |
| 33 | +def get_json_file_path(request): |
| 34 | + json_file_path: str = request.param |
| 35 | + yield json_file_path |
| 36 | + if '.zip:' in json_file_path: |
| 37 | + os.remove('archive.zip') |
| 38 | + else: |
| 39 | + os.remove(json_file_path) |
| 40 | + sh.rmtree('dir', ignore_errors=True) |
0 commit comments