|
9 | 9 | from pyarrow import csv as pyarrow_csv
|
10 | 10 | from pyarrow import fs
|
11 | 11 |
|
| 12 | +# note: the mocker fixture used throughout is provided by pytest-mock |
| 13 | + |
12 | 14 |
|
13 | 15 | @pytest.fixture()
|
14 | 16 | def model_output_table() -> pa.Table:
|
@@ -118,6 +120,55 @@ def test_parse_file(file_uri, expected_round_id, expected_model_id):
|
118 | 120 | assert mo.model_id == expected_model_id
|
119 | 121 |
|
120 | 122 |
|
| 123 | +@pytest.mark.parametrize( |
| 124 | + "input_uri, output_uri, expected_input_file, expected_output_path, expected_file_name, expected_model_id", |
| 125 | + [ |
| 126 | + ( |
| 127 | + "mock:bucket123/raw/prefix1/prefix 2/2420-01-01-team-model name with spaces.csv", |
| 128 | + "mock:bucket123/prefix1/prefix 2", |
| 129 | + "bucket123/raw/prefix1/prefix 2/2420-01-01-team-model name with spaces.csv", |
| 130 | + "bucket123/prefix1/prefix 2", |
| 131 | + "2420-01-01-team-model name with spaces", |
| 132 | + "team-model name with spaces", |
| 133 | + ), |
| 134 | + ( |
| 135 | + "mock:bucket1.2.3/raw/prefix1/prefix 2/2420-01-01-team-model.name.csv", |
| 136 | + "mock:bucket123/prefix1/~prefix 2", |
| 137 | + "bucket1.2.3/raw/prefix1/prefix 2/2420-01-01-team-model.name.csv", |
| 138 | + "bucket123/prefix1/~prefix 2", |
| 139 | + "2420-01-01-team-model.name", |
| 140 | + "team-model.name", |
| 141 | + ), |
| 142 | + ( |
| 143 | + "mock:raw/prefix 1/prefix2/2420-01-01-spáces at end .csv", |
| 144 | + "mock:prefix 1/prefix2", |
| 145 | + "raw/prefix 1/prefix2/2420-01-01-spáces at end.csv", |
| 146 | + "prefix 1/prefix2", |
| 147 | + "2420-01-01-spáces at end", |
| 148 | + "spáces at end", |
| 149 | + ), |
| 150 | + ( |
| 151 | + "mock:a space/prefix 1/prefix2/2420-01-01 look ma no hyphens.csv", |
| 152 | + "mock:prefix 1/prefix 🐍", |
| 153 | + "a space/prefix 1/prefix2/2420-01-01 look ma no hyphens.csv", |
| 154 | + "prefix 1/prefix 🐍", |
| 155 | + "2420-01-01 look ma no hyphens", |
| 156 | + "look ma no hyphens", |
| 157 | + ), |
| 158 | + ], |
| 159 | +) |
| 160 | +def test_new_instance_special_characters( |
| 161 | + input_uri, output_uri, expected_input_file, expected_output_path, expected_file_name, expected_model_id |
| 162 | +): |
| 163 | + # ensure spaces and other characters in directory, filename, s3 key, etc. are handled correctly |
| 164 | + |
| 165 | + mo = ModelOutputHandler(input_uri, output_uri) |
| 166 | + assert mo.input_file == expected_input_file |
| 167 | + assert mo.output_path == expected_output_path |
| 168 | + assert mo.file_name == expected_file_name |
| 169 | + assert mo.model_id == expected_model_id |
| 170 | + |
| 171 | + |
121 | 172 | @pytest.mark.parametrize(
|
122 | 173 | "s3_key, expected_input_uri, expected_output_uri",
|
123 | 174 | [
|
|
0 commit comments