mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
add unit test for Tabular.set_meta for empty files
This commit is contained in:
@@ -556,13 +556,14 @@ class Tabular(TabularData):
|
||||
comment_lines = None # type: ignore [assignment]
|
||||
break
|
||||
i += 1
|
||||
|
||||
print(column_types)
|
||||
# we error on the larger number of columns
|
||||
# first we pad our column_types by using data from first line
|
||||
if len(first_line_column_types) > len(column_types):
|
||||
for column_type in first_line_column_types[len(column_types) :]:
|
||||
column_types.append(column_type)
|
||||
# Now we fill any unknown (None) column_types with data from first line
|
||||
print(column_types)
|
||||
for i in range(len(column_types)):
|
||||
if column_types[i] is None:
|
||||
if len(first_line_column_types) <= i or first_line_column_types[i] is None:
|
||||
|
||||
@@ -22,3 +22,18 @@ def test_tabular_set_meta_large_file():
|
||||
assert dataset.metadata.columns == 2
|
||||
assert dataset.metadata.delimiter == "\t"
|
||||
assert not hasattr(dataset.metadata, "column_names")
|
||||
|
||||
|
||||
def test_tabular_set_meta_empty():
|
||||
with tempfile.NamedTemporaryFile(mode="w") as test_file:
|
||||
test_file.flush()
|
||||
dataset = MockDataset(id=1)
|
||||
dataset.file_name = test_file.name
|
||||
Tabular().set_meta(dataset)
|
||||
# data and comment lines are not stored if more than MAX_DATA_LINES
|
||||
assert dataset.metadata.data_lines == 0
|
||||
assert dataset.metadata.comment_lines == 0
|
||||
assert dataset.metadata.column_types == []
|
||||
assert dataset.metadata.columns == 0
|
||||
assert dataset.metadata.delimiter == "\t"
|
||||
assert not hasattr(dataset.metadata, "column_names")
|
||||
|
||||
Reference in New Issue
Block a user