# Path: test/_common.py
# def print_test_result(expected, actual, error=None):
#     print(f"[expected]\n{expected}\n")
#     print(f"[actual]\n{actual}\n")
# 
#     if error:
#         print(error, file=sys.stderr)
# 
#     print("----------------------------------------")
# 
# Path: test/data.py
# TIME = datetime.datetime(2017, 1, 1, 0, 0, 0)
# INF = float("inf")
# NAN = float("nan")


import collections
import pytest
import pytablewriter as ptw
from collections import OrderedDict
from decimal import Decimal
from pytablereader import SqliteFileLoader
from sqliteschema import SQLiteSchemaExtractor
from tabledata import TableData
from ..._common import print_test_result
from ...data import headers, mix_header_list, mix_value_matrix, value_matrix, value_matrix_iter
class Test_SqliteTableWriter_write_table_iter:
    @pytest.mark.parametrize(
        ["table", "header", "value", "expected"],
        [
            [
                "tablename",
                ["ha", "hb", "hc"],
                value_matrix_iter,
                TableData(
                    "tablename",
                    ["ha", "hb", "hc"],
                    [
                        [1.0, 2.0, 3.0],
                        [11.0, 12.0, 13.0],
                        [1.0, 2.0, 3.0],
                        [11.0, 12.0, 13.0],
                        [101.0, 102.0, 103.0],
                        [1001.0, 1002.0, 1003.0],
                    ],
                ),
            ]
        ],
    )
    def test_normal(self, tmpdir, table, header, value, expected):
        test_file_path = tmpdir.join("test.sqlite")

        writer = ptw.SqliteTableWriter()
        writer.open(str(test_file_path))
        writer.table_name = table
        writer.headers = header

# Path: test/_common.py
# def print_test_result(expected, actual, error=None):
#     print(f"[expected]\n{expected}\n")
#     print(f"[actual]\n{actual}\n")
# 
#     if error:
#         print(error, file=sys.stderr)
# 
#     print("----------------------------------------")
# 
# Path: test/data.py
# TIME = datetime.datetime(2017, 1, 1, 0, 0, 0)
# INF = float("inf")
# NAN = float("nan")


# Path: test/writer/binary/test_sqlite_writer.py
import collections
import pytest
import pytablewriter as ptw
from collections import OrderedDict
from decimal import Decimal
from pytablereader import SqliteFileLoader
from sqliteschema import SQLiteSchemaExtractor
from tabledata import TableData
from ..._common import print_test_result
from ...data import headers, mix_header_list, mix_value_matrix, value_matrix, value_matrix_iter

class Test_SqliteTableWriter_write_table_iter:
    @pytest.mark.parametrize(
        ["table", "header", "value", "expected"],
        [
            [
                "tablename",
                ["ha", "hb", "hc"],
                value_matrix_iter,
                TableData(
                    "tablename",
                    ["ha", "hb", "hc"],
                    [
                        [1.0, 2.0, 3.0],
                        [11.0, 12.0, 13.0],
                        [1.0, 2.0, 3.0],
                        [11.0, 12.0, 13.0],
                        [101.0, 102.0, 103.0],
                        [1001.0, 1002.0, 1003.0],
                    ],
                ),
            ]
        ],
    )
    def test_normal(self, tmpdir, table, header, value, expected):
        test_file_path = tmpdir.join("test.sqlite")

        writer = ptw.SqliteTableWriter()
        writer.open(str(test_file_path))
        writer.table_name = table
        writer.headers = header

        writer.value_matrix = value