Skip to content

Commit a14a4df

Browse files
committed
Add new test case
1 parent c0b0062 commit a14a4df

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

tests/test_skillsnetwork.py

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,18 +137,45 @@ async def test_prepare_non_compressed_dataset_with_path(httpserver):
137137

138138

139139
@pytest.mark.asyncio
140-
async def test_prepare_non_compressed_dataset_with_overwrite(httpserver):
140+
async def test_prepare_non_compressed_dataset_no_path_with_overwrite(httpserver):
141141
url = "/test.csv"
142142
expected_path = Path("./test.csv")
143143
with open("tests/test.csv", "rb") as expected_data:
144144
httpserver.expect_request(url).respond_with_data(expected_data)
145-
await skillsnetwork.prepare_dataset(httpserver.url_for(url), overwrite=True)
145+
await skillsnetwork.prepare_dataset(httpserver.url_for(url))
146146
assert expected_path.exists()
147147
httpserver.clear()
148-
print(expected_path.absolute(), expected_path.absolute().exists())
149148
with open("tests/test.csv", "rb") as expected_data:
150149
httpserver.expect_request(url).respond_with_data(expected_data)
151150
await skillsnetwork.prepare_dataset(httpserver.url_for(url), overwrite=True)
152151
assert expected_path.exists()
153152
assert Path(expected_path).stat().st_size == 540
154153
expected_path.unlink()
154+
155+
156+
@pytest.mark.asyncio
157+
async def test_prepare_dataset_tar_no_path_with_overwrite(httpserver):
158+
url = "/test.tar.gz"
159+
expected_directory = Path("test")
160+
try:
161+
shutil.rmtree(expected_directory) # clean up any previous test
162+
except FileNotFoundError as e:
163+
print(e)
164+
pass
165+
166+
with open("tests/test.tar.gz", "rb") as expected_data:
167+
httpserver.expect_request(url).respond_with_data(expected_data)
168+
await skillsnetwork.prepare_dataset(httpserver.url_for(url))
169+
170+
assert os.path.isdir(expected_directory)
171+
with open(expected_directory / "1.txt") as f:
172+
assert "I am the first test file" in f.read()
173+
httpserver.clear()
174+
175+
with open("tests/test.tar.gz", "rb") as expected_data:
176+
httpserver.expect_request(url).respond_with_data(expected_data)
177+
await skillsnetwork.prepare_dataset(httpserver.url_for(url), overwrite=True)
178+
assert os.path.isdir(expected_directory)
179+
with open(expected_directory / "1.txt") as f:
180+
assert "I am the first test file" in f.read()
181+
expected_directory.unlink()

0 commit comments

Comments
 (0)