diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 2ba713b..e05dcaf 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -1,8 +1,8 @@ beautifulsoup4 DataProperty>=0.12.0 jsonschema -pathvalidate>=0.8.3 -pytablereader>=0.5.2 +pathvalidate>=0.9.0 +pytablereader>=0.6.0 path.py six xlrd diff --git a/setup.py b/setup.py index fe30913..7660e65 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ setuptools.setup( name="SimpleSQLite", - version="0.6.3", + version="0.6.4", url="https://github.com/thombashi/SimpleSQLite", author="Tsuyoshi Hombashi", diff --git a/test/loader/test_gsloader.py b/test/loader/test_gsloader.py index 225ac41..69deba5 100644 --- a/test/loader/test_gsloader.py +++ b/test/loader/test_gsloader.py @@ -18,7 +18,7 @@ def monkey_property(self): @pytest.mark.parametrize(["value", "title", "expected"], [ ["%(sheet)s", "titlename", "testsheet"], ["%(title)s", "titlename", "titlename"], - ["%(title)s", "table", "table_spreadsheet"], + ["%(title)s", "table", "table"], [ "prefix_%(title)s_%(sheet)s", "titlename", diff --git a/test/test_from_file.py b/test/test_from_file.py index 2b2be37..782f92d 100644 --- a/test/test_from_file.py +++ b/test/test_from_file.py @@ -24,8 +24,7 @@ def test_smoke(self, tmpdir, filename): test_data_file_path = os.path.join( os.path.dirname(__file__), "data", filename) - loader_factory = ptr.TableFileLoaderFactory(test_data_file_path) - loader = loader_factory.create_from_path() + loader = ptr.TableFileLoader(test_data_file_path) success_count = 0 diff --git a/test/test_simplesqlite.py b/test/test_simplesqlite.py index 3575700..0fd75f7 100644 --- a/test/test_simplesqlite.py +++ b/test/test_simplesqlite.py @@ -9,6 +9,7 @@ import itertools import dataproperty +import pytablereader as ptr import pytest from simplesqlite import * @@ -818,6 +819,40 @@ def test_null(self, con_null): TEST_TABLE_NAME, [], []) +class Test_SimpleSQLite_create_table_from_tabledata: + + @pytest.mark.parametrize(["value"], [ + [ + ptr.TableData( + "json1", + ["attr_a", "attr_b", "attr_c"], + [ + {u'attr_a': 1, u'attr_b': 4, u'attr_c': u'a'}, + {u'attr_a': 2, u'attr_b': 2.1, u'attr_c': u'bb'}, + {u'attr_a': 3, u'attr_b': 120.9, + u'attr_c': u'ccc'}, + ] + ) + ], + ]) + def test_normal( + self, tmpdir, value): + p_db = tmpdir.join("tmp.db") + + con = SimpleSQLite(str(p_db), "w") + con.create_table_from_tabledata(value) + + assert con.get_table_name_list() == [value.table_name] + assert con.get_attribute_name_list( + value.table_name) == value.header_list + + result = con.select(select="*", table_name=value.table_name) + result_matrix = result.fetchall() + assert len(result_matrix) == 3 + assert result_matrix == [ + (1, 4.0, u'a'), (2, 2.1, u'bb'), (3, 120.9, u'ccc')] + + class Test_SimpleSQLite_create_table_from_csv: @pytest.mark.parametrize(