|
| 1 | +import os |
1 | 2 | import io |
2 | 3 |
|
3 | 4 | import pytest |
4 | 5 |
|
5 | 6 | from ExtractTable.client import ExtractTable |
6 | | -from ExtractTable.common import UsageStats |
7 | 7 | from ExtractTable.exceptions import ServiceError |
8 | | -from tests.constants import API_KEY, FILE_PATH, RESULTS_FOLDER |
| 8 | +from tests.constants import API_KEY, FILE_PATH |
9 | 9 |
|
10 | 10 |
|
11 | 11 | @pytest.fixture |
12 | 12 | def client(): |
13 | 13 | return ExtractTable(API_KEY) |
14 | 14 |
|
15 | 15 |
|
16 | | -def test_process_file(client: ExtractTable): |
17 | | - assert not (client.process_file(FILE_PATH, RESULTS_FOLDER)) |
18 | | - |
19 | | - |
20 | | -def test_process_file_index(client: ExtractTable): |
21 | | - assert not (client.process_file(FILE_PATH, RESULTS_FOLDER, True)) |
22 | | - |
23 | | - |
24 | | -def test_check_usage(client: ExtractTable): |
25 | | - assert isinstance(client.check_usage(), UsageStats) |
| 16 | +def test_get_result_fail(client: ExtractTable): |
| 17 | + with pytest.raises(ServiceError): |
| 18 | + assert not client.get_result('') |
26 | 19 |
|
27 | 20 |
|
28 | 21 | def test_trigger_process_fail(client: ExtractTable): |
29 | 22 | with pytest.raises(ServiceError): |
30 | 23 | client.trigger_process(io.BytesIO()) |
31 | 24 |
|
32 | 25 |
|
33 | | -def test_get_result_fail(client: ExtractTable): |
34 | | - with pytest.raises(ServiceError): |
35 | | - assert client.get_result('') |
| 26 | +def test_check_usage(client: ExtractTable): |
| 27 | + assert isinstance(client.check_usage(), dict) |
| 28 | + |
| 29 | + |
| 30 | +def test_process_file(client: ExtractTable): |
| 31 | + assert isinstance(client.process_file(filepath=FILE_PATH, output_format="df"), list) |
36 | 32 |
|
37 | 33 |
|
| 34 | +def test_process_file_csv(client: ExtractTable, fmt="csv"): |
| 35 | + return all([os.path.exists(x) and x.endswith(fmt) for x in client.process_file(filepath=FILE_PATH, output_format=fmt)]) |
0 commit comments