Skip to content

Commit 9a0f704

Browse files
committed
Fix CSV writing on windows and reactivate tests (#350)
1 parent 14836bb commit 9a0f704

4 files changed

Lines changed: 3 additions & 17 deletions

File tree

hca/dss/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ def _write_output_manifest(self):
756756
fieldnames, source_manifest = self._parse_manifest(self.manifest)
757757
if 'file_path' not in fieldnames:
758758
fieldnames.append('file_path')
759-
with atomic_write(output, overwrite=True) as f:
759+
with atomic_write(output, overwrite=True, newline='') as f:
760760
writer = csv.DictWriter(f, fieldnames, delimiter='\t', quoting=csv.QUOTE_NONE)
761761
writer.writeheader()
762762
for row in source_manifest:

test/integration/dss/test_dss_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def test_python_manifest_download(self):
162162
cwd = os.getcwd()
163163
os.chdir(work_dir)
164164
try:
165-
with open('manifest.tsv', 'w') as manifest:
165+
with open('manifest.tsv', 'w', newline='') as manifest:
166166
tsv = csv.DictWriter(manifest,
167167
fieldnames=('bundle_uuid',
168168
'bundle_version',

test/tutorial/scripts/api/download_manifest_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
dss = DSSClient()
77

8-
with open("manifest.tsv", "w") as manifest:
8+
with open("manifest.tsv", "w", newline='') as manifest:
99
tsv = csv.DictWriter(
1010
manifest,
1111
fieldnames=(

test/unit/test_dss_client.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ def test_file_path_filestore_root(self):
176176
parts = ManifestDownloadContext._file_path('abcdefghij', 'nested_filestore').split(os.sep)
177177
self.assertEqual(parts, ['nested_filestore', '.hca', 'v2', 'files_1_3_2', 'a', 'bcd', 'ef', 'abcdefghij'])
178178

179-
@unittest.skipIf(os.name is 'nt', 'Unable to test on Windows') # TODO windows testing refactor
180179
@patch('logging.Logger.warning')
181180
@patch('hca.dss.DownloadContext._download_file', side_effect=_fake_download_file)
182181
def test_manifest_download(self, download_func, warning_log):
@@ -190,7 +189,6 @@ def test_manifest_download(self, download_func, warning_log):
190189
self._assert_all_files_downloaded()
191190
self._assert_manifest_updated_with_paths('')
192191

193-
@unittest.skipIf(os.name is 'nt', 'Unable to test on Windows') # TODO windows testing refactor
194192
def _test_download_dir(self, download_dir):
195193
with patch('hca.dss.DownloadContext._download_file', side_effect=_fake_download_file) as download_func:
196194
self.dss.download_manifest(self.manifest_file, 'aws', layout='none', download_dir=download_dir)
@@ -201,23 +199,18 @@ def _test_download_dir(self, download_dir):
201199
self._assert_all_files_downloaded(prefix=download_dir)
202200
self._assert_manifest_updated_with_paths(download_dir)
203201

204-
@unittest.skipIf(os.name is 'nt', 'Unable to test on Windows') # TODO windows testing refactor
205202
def test_download_dir_empty(self):
206203
self._test_download_dir('')
207204

208-
@unittest.skipIf(os.name is 'nt', 'Unable to test on Windows') # TODO windows testing refactor
209205
def test_download_dir_dot(self):
210206
self._test_download_dir('.')
211207

212-
@unittest.skipIf(os.name is 'nt', 'Unable to test on Windows') # TODO windows testing refactor
213208
def test_download_dir(self):
214209
self._test_download_dir('a_nested_dir')
215210

216-
@unittest.skipIf(os.name is 'nt', 'Unable to test on Windows') # TODO windows testing refactor
217211
def test_download_dir_dot_dir(self):
218212
self._test_download_dir(os.path.join('.', 'a_nested_dir'))
219213

220-
@unittest.skipIf(os.name is 'nt', 'Unable to test on Windows') # TODO windows testing refactor
221214
@patch('logging.Logger.warning')
222215
@patch('hca.dss.DownloadContext._download_file', side_effect=_fake_download_file)
223216
def test_manifest_download_different_path(self, download_func, warning_log):
@@ -238,7 +231,6 @@ def test_manifest_download_different_path(self, download_func, warning_log):
238231
self._assert_all_files_downloaded()
239232
self._assert_manifest_updated_with_paths('')
240233

241-
@unittest.skipIf(os.name is 'nt', 'Unable to test on Windows') # TODO windows testing refactor
242234
@patch('logging.Logger.warning')
243235
@patch('hca.dss.DownloadContext._download_file', side_effect=_fake_download_file)
244236
def test_manifest_download_partial(self, _, warning_log):
@@ -312,7 +304,6 @@ def _assert_all_files_downloaded(self, more_files=None, prefix=''):
312304
more_files = bundle_files.union(more_files) if more_files else bundle_files
313305
super(TestManifestDownloadBundle, self)._assert_all_files_downloaded(more_files=more_files, prefix=prefix)
314306

315-
@unittest.skipIf(os.name is 'nt', 'Unable to test on Windows') # TODO windows testing refactor
316307
@patch('hca.dss.DSSClient.get_bundle')
317308
@patch('hca.dss.DownloadContext._download_file', side_effect=_fake_download_file)
318309
def test_manifest_download_bundle(self, _, mock_get_bundle):
@@ -344,19 +335,15 @@ def _assert_bundle_json(self, prefix=''):
344335
actual_hash = hashlib.sha256(f.read()).hexdigest()
345336
self.assertEqual(actual_hash, expected_hash)
346337

347-
@unittest.skipIf(os.name is 'nt', 'Unable to test on Windows') # TODO windows testing refactor
348338
def test_download_dir_empty(self):
349339
self._test_download_dir('')
350340

351-
@unittest.skipIf(os.name is 'nt', 'Unable to test on Windows') # TODO windows testing refactor
352341
def test_download_dir_dot(self):
353342
self._test_download_dir('.')
354343

355-
@unittest.skipIf(os.name is 'nt', 'Unable to test on Windows') # TODO windows testing refactor
356344
def test_download_dir(self):
357345
self._test_download_dir('a_nested_dir')
358346

359-
@unittest.skipIf(os.name is 'nt', 'Unable to test on Windows') # TODO windows testing refactor
360347
def test_download_dir_dot_dir(self):
361348
self._test_download_dir(os.path.join('.', 'a_nested_dir'))
362349

@@ -553,7 +540,6 @@ def test_collection_download_self_nested(self):
553540
self.dss.download_collection(uuid=test_col['uuid'],
554541
replica='aws', download_dir=t)
555542

556-
@unittest.skipIf(os.name is 'nt', 'Unable to test on Windows') # TODO windows testing refactor
557543
def test_collection_download_deep(self):
558544
"""Test that we can download nested collections"""
559545
test_cols = self._generate_col_hierarchy(4)

0 commit comments

Comments
 (0)