# Path: bitcoinlib/main.py
# def script_type_default(witness_type=None, multisig=False, locking_script=False):
# def get_encoding_from_witness(witness_type=None):
# def deprecated(func):
#     def new_func(*args, **kwargs):
# 
# Path: bitcoinlib/db.py
# def compile_largebinary_mysql(type_, compiler, **kwargs):
#     def __init__(self, db_uri=None, password=None):
#     def drop_db(self, yes_i_am_sure=False):
#     def _import_config_data(ses):
# def add_column(engine, table_name, column):
#     def __repr__(self):
#     def __repr__(self):
#     def __repr__(self):
#     def __repr__(self):
# def db_update_version_id(db, version):
# def db_update(db, version_db, code_version=BITCOINLIB_VERSION):
# class Db:
# class DbConfig(Base):
# class DbWallet(Base):
# class DbKeyMultisigChildren(Base):
# class DbKey(Base):
# class DbNetwork(Base):
# class DbTransaction(Base):
# class DbTransactionInput(Base):
# class DbTransactionOutput(Base):
# 
# Path: bitcoinlib/encoding.py
# def normalize_string(string):
#     """
#     Normalize a string to the default NFKD unicode format
#     See https://en.wikipedia.org/wiki/Unicode_equivalence#Normalization
# 
#     :param string: string value
#     :type string: bytes, str
# 
#     :return: string
#     """
#     if isinstance(string, bytes):
#         utxt = string.decode('utf8')
#     elif isinstance(string, TYPE_TEXT):
#         utxt = string
#     else:
#         raise TypeError("String value expected")
# 
#     return unicodedata.normalize('NFKD', utxt)


import os
import sys
import unittest
    import mysql.connector
    import psycopg2
from subprocess import Popen, PIPE
    from parameterized import parameterized_class
    from psycopg2 import sql
    from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
from bitcoinlib.main import UNITTESTS_FULL_DATABASE_TEST
from bitcoinlib.db import BCL_DATABASE_DIR
from bitcoinlib.encoding import normalize_string


db_uris = (('sqlite:///' + SQLITE_DATABASE_FILE, init_sqlite),)
if UNITTESTS_FULL_DATABASE_TEST:
    db_uris += (
        # ('mysql://root@localhost:3306/' + DATABASE_NAME, init_mysql),
        ('postgresql://postgres:postgres@localhost:5432/' + DATABASE_NAME, init_postgresql),
    )


@parameterized_class(('DATABASE_URI', 'init_fn'), db_uris)
class TestToolsCommandLineWallet(unittest.TestCase):

    def setUp(self):
        self.init_fn()
        self.python_executable = sys.executable
        self.clw_executable = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                                            '../bitcoinlib/tools/clw.py'))

    def test_tools_clw_create_wallet(self):
        cmd_wlt_create = '%s %s test --passphrase "emotion camp sponsor curious bacon squeeze bean world ' \
                         'actual chicken obscure spray" -r -d %s' % \
                         (self.python_executable, self.clw_executable, self.DATABASE_URI)
        cmd_wlt_delete = "%s %s test --wallet-remove -d %s" % \
                         (self.python_executable, self.clw_executable, self.DATABASE_URI)
        output_wlt_create = "14guS7uQpEbgf1e8TDo1zTEURJW3NGPc9E"
        output_wlt_delete = "Wallet test has been removed"

        process = Popen(cmd_wlt_create, stdin=PIPE, stdout=PIPE, shell=True)
        poutput = process.communicate(input=b'y')

# Path: bitcoinlib/main.py
# def script_type_default(witness_type=None, multisig=False, locking_script=False):
# def get_encoding_from_witness(witness_type=None):
# def deprecated(func):
#     def new_func(*args, **kwargs):
# 
# Path: bitcoinlib/db.py
# def compile_largebinary_mysql(type_, compiler, **kwargs):
#     def __init__(self, db_uri=None, password=None):
#     def drop_db(self, yes_i_am_sure=False):
#     def _import_config_data(ses):
# def add_column(engine, table_name, column):
#     def __repr__(self):
#     def __repr__(self):
#     def __repr__(self):
#     def __repr__(self):
# def db_update_version_id(db, version):
# def db_update(db, version_db, code_version=BITCOINLIB_VERSION):
# class Db:
# class DbConfig(Base):
# class DbWallet(Base):
# class DbKeyMultisigChildren(Base):
# class DbKey(Base):
# class DbNetwork(Base):
# class DbTransaction(Base):
# class DbTransactionInput(Base):
# class DbTransactionOutput(Base):
# 
# Path: bitcoinlib/encoding.py
# def normalize_string(string):
#     """
#     Normalize a string to the default NFKD unicode format
#     See https://en.wikipedia.org/wiki/Unicode_equivalence#Normalization
# 
#     :param string: string value
#     :type string: bytes, str
# 
#     :return: string
#     """
#     if isinstance(string, bytes):
#         utxt = string.decode('utf8')
#     elif isinstance(string, TYPE_TEXT):
#         utxt = string
#     else:
#         raise TypeError("String value expected")
# 
#     return unicodedata.normalize('NFKD', utxt)


# Path: tests/test_tools.py
import os
import sys
import unittest
    import mysql.connector
    import psycopg2
from subprocess import Popen, PIPE
    from parameterized import parameterized_class
    from psycopg2 import sql
    from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
from bitcoinlib.main import UNITTESTS_FULL_DATABASE_TEST
from bitcoinlib.db import BCL_DATABASE_DIR
from bitcoinlib.encoding import normalize_string



db_uris = (('sqlite:///' + SQLITE_DATABASE_FILE, init_sqlite),)
if UNITTESTS_FULL_DATABASE_TEST:
    db_uris += (
        # ('mysql://root@localhost:3306/' + DATABASE_NAME, init_mysql),
        ('postgresql://postgres:postgres@localhost:5432/' + DATABASE_NAME, init_postgresql),
    )


@parameterized_class(('DATABASE_URI', 'init_fn'), db_uris)
class TestToolsCommandLineWallet(unittest.TestCase):

    def setUp(self):
        self.init_fn()
        self.python_executable = sys.executable
        self.clw_executable = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                                            '../bitcoinlib/tools/clw.py'))

    def test_tools_clw_create_wallet(self):
        cmd_wlt_create = '%s %s test --passphrase "emotion camp sponsor curious bacon squeeze bean world ' \
                         'actual chicken obscure spray" -r -d %s' % \
                         (self.python_executable, self.clw_executable, self.DATABASE_URI)
        cmd_wlt_delete = "%s %s test --wallet-remove -d %s" % \
                         (self.python_executable, self.clw_executable, self.DATABASE_URI)
        output_wlt_create = "14guS7uQpEbgf1e8TDo1zTEURJW3NGPc9E"
        output_wlt_delete = "Wallet test has been removed"

        process = Popen(cmd_wlt_create, stdin=PIPE, stdout=PIPE, shell=True)
        poutput = process.communicate(input=b'y')

        self.assertIn(output_wlt_create, normalize_string(poutput[0]))