Skip to content

Commit

Permalink
Merge pull request #13 from thombashi/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
thombashi committed Sep 10, 2016
2 parents 4962cf3 + 6705530 commit 01768b2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion sqlitebiter/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "0.1.6"
VERSION = "0.1.7"
4 changes: 3 additions & 1 deletion sqlitebiter/sqlitebiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def file(ctx, files, output_path):
con = create_database(output_path)
result_counter = ResultCounter()

logger = logbook.Logger("sqlitebiter")
logger = logbook.Logger("sqlitebiter file")
_setup_logger_from_context(ctx, logger)

for file_path in files:
Expand All @@ -139,6 +139,8 @@ def file(ctx, files, output_path):
"path={:s}, message={:s}".format(file_path, e))
result_counter.inc_fail()
continue
except OpenError as e:
logger.error(e)
except ValidationError as e:
logger.error(
"invalid {:s} data format: path={:s}, message={:s}".format(
Expand Down
27 changes: 18 additions & 9 deletions test/test_sqlitebiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import click
from click.testing import CliRunner
import path
import pytest
import simplesqlite
import xlsxwriter
Expand Down Expand Up @@ -150,6 +151,13 @@ def invalid_excel_file():
return file_path


def invalid_excel_file2():
file_path = "invalid2.xlsx"
path.Path(file_path).touch()

return file_path


class Test_sqlitebiter:

@pytest.mark.parametrize(["option_list", "expected"], [
Expand All @@ -166,18 +174,19 @@ def test_normal(self):
db_path = "test.sqlite"
runner = CliRunner()
with runner.isolated_filesystem():
file_list = []

file_list.append(valid_json_single_file())
file_list.append(invalid_json_single_file())
file_list = [
valid_json_single_file(),
invalid_json_single_file(),

file_list.append(valid_json_multi_file())
file_list.append(invalid_json_multi_file())
valid_json_multi_file(),
invalid_json_multi_file(),

file_list.append(csv_file())
csv_file(),

file_list.append(valid_excel_file())
file_list.append(invalid_excel_file())
valid_excel_file(),
invalid_excel_file(),
invalid_excel_file2(),
]

result = runner.invoke(cmd, ["file"] + file_list + ["-o", db_path])
assert result.exit_code == 0
Expand Down

0 comments on commit 01768b2

Please sign in to comment.