Skip to content

Commit

Permalink
Modify to accept underscore-character for attribute names
Browse files Browse the repository at this point in the history
  • Loading branch information
thombashi committed Oct 1, 2017
1 parent 52ab9ee commit 0ebfa15
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ appconfigpy>=0.0.2
click>=6.7
logbook
path.py
pytablereader>=0.13.3
pytablereader>=0.13.4
SimpleSQLite>=0.15.0
sqliteschema>=0.9.3
typepy>=0.0.20
20 changes: 20 additions & 0 deletions test/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,26 @@ def valid_excel_file():
return str(file_path)


def valid_excel_file_1():
file_path = "valid_underscore.xlsx"
workbook = xlsxwriter.Workbook(str(file_path))

worksheet = workbook.add_worksheet("sheet_a")
table = [
["data", "_data", "da_ta", "data_"],
[1, 0.0, "a", "aaaa"],
[2, 0.1, "b", "bbbb"],
[3, 0.2, "c", "cccc"],
]
for row_idx, row in enumerate(table):
for col_idx, item in enumerate(row):
worksheet.write(row_idx, col_idx, item)

workbook.close()

return str(file_path)


def invalid_excel_file_1():
file_path = "invalid.xlsx"
workbook = xlsxwriter.Workbook(file_path)
Expand Down
15 changes: 15 additions & 0 deletions test/test_file_subcommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
valid_tsv_file,
invalid_tsv_file,
valid_excel_file,
valid_excel_file_1,
invalid_excel_file_1,
invalid_excel_file_2,
valid_html_file,
Expand Down Expand Up @@ -167,6 +168,20 @@ def test_abnormal_smoke(self):
assert result.exit_code in (
ExitCode.FAILED_CONVERT, ExitCode.NO_INPUT), file_path

@pytest.mark.parametrize(["file_creator", "expected"], [
[valid_excel_file_1, ExitCode.SUCCESS],
])
def test_normal_one_file(self, file_creator, expected):
db_path = "test.sqlite"
runner = CliRunner()

with runner.isolated_filesystem():
file_path = file_creator()
result = runner.invoke(
cmd, ["file", file_path, "-o", db_path])

assert result.exit_code == expected, file_path

def test_normal_multi_file_different_table(self):
db_path = "test.sqlite"
runner = CliRunner()
Expand Down

0 comments on commit 0ebfa15

Please sign in to comment.