-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from thombashi/develop
Fix failed to conversion
- Loading branch information
Showing
8 changed files
with
86 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
``sqlitebiter`` command help | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
:: | ||
|
||
Usage: sqlitebiter [OPTIONS] COMMAND [ARGS]... | ||
|
||
Options: | ||
--version Show the version and exit. | ||
--debug for debug print. | ||
--quiet suppress execution log messages. | ||
-h, --help Show this message and exit. | ||
|
||
Commands: | ||
file Convert CSV/Excel/HTML/JSON file(s) to a... | ||
gs Convert Google Sheets to a SQLite database... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,6 @@ Usage | |
.. toctree:: | ||
:maxdepth: 3 | ||
|
||
common | ||
file/index | ||
gs/index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
click | ||
DataProperty>=0.8.1 | ||
DataProperty>=0.9.0 | ||
logbook | ||
path.py | ||
SimpleSQLite>=0.5.1 | ||
SimpleSQLite>=0.5.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
VERSION = "0.2.0" | ||
VERSION = "0.2.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ | |
.. codeauthor:: Tsuyoshi Hombashi <[email protected]> | ||
""" | ||
|
||
|
||
import pytest | ||
from sqlitebiter._counter import ResultCounter | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,15 +4,14 @@ | |
.. codeauthor:: Tsuyoshi Hombashi <[email protected]> | ||
""" | ||
|
||
|
||
import click | ||
from click.testing import CliRunner | ||
import path | ||
import pytest | ||
import simplesqlite | ||
import xlsxwriter | ||
|
||
from sqlitebiter.sqlitebiter import cmd | ||
from simplesqlite.loader.interface import TableLoader | ||
|
||
|
||
def valid_json_single_file(): | ||
|
@@ -69,7 +68,7 @@ def invalid_json_multi_file(): | |
return file_path | ||
|
||
|
||
def csv_file(): | ||
def valid_csv_file(): | ||
file_path = "csv_a.csv" | ||
with open(file_path, "w") as f: | ||
f.write("\n".join([ | ||
|
@@ -82,6 +81,21 @@ def csv_file(): | |
return file_path | ||
|
||
|
||
def valid_csv_file2(): | ||
# reserved keywod of SQLite | ||
|
||
file_path = "insert.csv" | ||
with open(file_path, "w") as f: | ||
f.write("\n".join([ | ||
'"attr_a","attr_b","attr_c"', | ||
'1,4,"a"', | ||
'2,2.1,"bb"', | ||
'3,120.9,"ccc"', | ||
])) | ||
|
||
return file_path | ||
|
||
|
||
def valid_excel_file(): | ||
file_path = "valid.xlsx" | ||
workbook = xlsxwriter.Workbook(str(file_path)) | ||
|
@@ -225,6 +239,9 @@ def invalid_html_file(): | |
|
||
class Test_sqlitebiter: | ||
|
||
def setup_method(self, method): | ||
TableLoader.clear_table_count() | ||
|
||
@pytest.mark.parametrize(["option_list", "expected"], [ | ||
[["-h"], 0], | ||
[["file", "-h"], 0], | ||
|
@@ -235,7 +252,44 @@ def test_help(self, option_list, expected): | |
result = runner.invoke(cmd, option_list) | ||
assert result.exit_code == 0 | ||
|
||
def test_normal(self): | ||
def test_normal_smoke(self): | ||
db_path = "test.sqlite" | ||
runner = CliRunner() | ||
|
||
with runner.isolated_filesystem(): | ||
file_list = [ | ||
valid_json_single_file(), | ||
valid_json_multi_file(), | ||
valid_csv_file(), | ||
valid_csv_file2(), | ||
valid_excel_file(), | ||
valid_html_file(), | ||
] | ||
|
||
for file_path in file_list: | ||
result = runner.invoke( | ||
cmd, ["file", file_path, "-o", db_path]) | ||
assert result.exit_code == 0, file_path | ||
|
||
def test_abnormal_smoke(self): | ||
db_path = "test.sqlite" | ||
runner = CliRunner() | ||
|
||
with runner.isolated_filesystem(): | ||
file_list = [ | ||
invalid_json_single_file(), | ||
invalid_json_multi_file(), | ||
invalid_excel_file(), | ||
invalid_excel_file2(), | ||
invalid_html_file(), | ||
] | ||
|
||
for file_path in file_list: | ||
result = runner.invoke( | ||
cmd, ["file", file_path, "-o", db_path]) | ||
assert result.exit_code != 0, file_path | ||
|
||
def test_normal_multi(self): | ||
db_path = "test.sqlite" | ||
runner = CliRunner() | ||
with runner.isolated_filesystem(): | ||
|
@@ -246,7 +300,8 @@ def test_normal(self): | |
valid_json_multi_file(), | ||
invalid_json_multi_file(), | ||
|
||
csv_file(), | ||
valid_csv_file(), | ||
valid_csv_file2(), | ||
|
||
valid_excel_file(), | ||
invalid_excel_file(), | ||
|
@@ -262,7 +317,7 @@ def test_normal(self): | |
con = simplesqlite.SimpleSQLite(db_path, "r") | ||
expected_tables = [ | ||
'singlejson_json1', 'multijson_table1', 'multijson_table2', | ||
'csv_a', | ||
'csv_a', "insert_csv", | ||
'excel_sheet_a', 'excel_sheet_c', 'excel_sheet_d', | ||
'htmltable_tablename', 'htmltable_html2', | ||
] | ||
|
@@ -280,6 +335,7 @@ def test_normal(self): | |
"multijson_table2": | ||
[(1, '4'), (2, 'NULL'), (3, '120.9')], | ||
"csv_a": [(1, 4.0, 'a'), (2, 2.1, 'bb'), (3, 120.9, 'ccc')], | ||
"insert_csv": [(1, 4.0, 'a'), (2, 2.1, 'bb'), (3, 120.9, 'ccc')], | ||
"excel_sheet_a": | ||
[(1.0, 1.1, 'a'), (2.0, 2.2, 'bb'), (3.0, 3.3, 'cc')], | ||
"excel_sheet_c": | ||
|