<s> import unittest <EOL> from coloredcoinlib import ( ColorSet , ColorDataBuilderManager , <EOL> AidedColorDataBuilder , ThinColorData ) <EOL> from ngcccbase . deterministic import DWalletAddressManager <EOL> from ngcccbase . pwallet import PersistentWallet <EOL> from ngcccbase . txcons import BasicTxSpec , InvalidTargetError <EOL> from ngcccbase . txdb import TxDb <EOL> from ngcccbase . utxodb import UTXOQuery <EOL> from ngcccbase . wallet_model import CoinQueryFactory <EOL> from ngcccbase . wallet_controller import WalletController <EOL> class TestWalletModel ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . path = "<STR_LIT>" <EOL> self . config = { <EOL> '<STR_LIT>' : <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : { '<STR_LIT>' : self . path } , <EOL> } <EOL> self . pwallet = PersistentWallet ( self . path , self . config ) <EOL> self . pwallet . init_model ( ) <EOL> self . model = self . pwallet . get_model ( ) <EOL> self . colormap = self . model . get_color_map ( ) <EOL> self . bcolorset = ColorSet ( self . colormap , [ '<STR_LIT>' ] ) <EOL> self . basset = self . model . get_asset_definition_manager ( <EOL> ) . get_asset_by_moniker ( '<STR_LIT>' ) <EOL> self . cqf = self . model . get_coin_query_factory ( ) <EOL> def test_get_tx_db ( self ) : <EOL> self . assertTrue ( isinstance ( self . model . get_tx_db ( ) , TxDb ) ) <EOL> def test_is_testnet ( self ) : <EOL> self . assertTrue ( self . model . is_testnet ( ) ) <EOL> def test_get_coin_query_factory ( self ) : <EOL> self . assertTrue ( isinstance ( self . cqf , CoinQueryFactory ) ) <EOL> self . cqf . make_query ( { '<STR_LIT>' : self . bcolorset } ) <EOL> self . cqf . make_query ( { '<STR_LIT>' : self . bcolorset . color_id_set } ) <EOL> self . cqf . make_query ( { '<STR_LIT>' : self . basset } ) <EOL> self . assertRaises ( Exception , self . cqf . make_query , { } ) <EOL> def test_transform ( self ) : <EOL> tx_spec = BasicTxSpec ( self . model ) <EOL> self . assertRaises ( InvalidTargetError , <EOL> self . model . transform_tx_spec , tx_spec , '<STR_LIT>' ) <EOL> def test_make_query ( self ) : <EOL> q = self . model . make_coin_query ( { '<STR_LIT>' : self . bcolorset } ) <EOL> self . assertTrue ( isinstance ( q , UTXOQuery ) ) <EOL> def test_get_address_manager ( self ) : <EOL> m = self . model . get_address_manager ( ) <EOL> self . assertTrue ( issubclass ( m . __class__ , DWalletAddressManager ) ) <EOL> def test_get_history ( self ) : <EOL> self . config [ '<STR_LIT>' ] = [ <EOL> { "<STR_LIT>" : [ "<STR_LIT>" ] , "<STR_LIT>" : [ "<STR_LIT>" ] , "<STR_LIT>" : <NUM_LIT> } , <EOL> { "<STR_LIT>" : [ "<STR_LIT>" ] , "<STR_LIT>" : [ '<STR_LIT:test>' ] , "<STR_LIT>" : <NUM_LIT:1> } , ] <EOL> self . config [ '<STR_LIT>' ] = { <EOL> "<STR_LIT>" : [ <EOL> [ "<STR_LIT>" ] , <EOL> ] , <EOL> "<STR_LIT>" : [ <EOL> { "<STR_LIT>" : [ "<STR_LIT>" ] , "<STR_LIT>" : <NUM_LIT:1> } , <EOL> { "<STR_LIT>" : [ "<STR_LIT>" ] , "<STR_LIT>" : <NUM_LIT:7> } , <EOL> ] <EOL> } <EOL> self . config [ '<STR_LIT>' ] = True <EOL> self . pwallet = PersistentWallet ( self . path , self . config ) <EOL> self . pwallet . init_model ( ) <EOL> self . model = self . pwallet . get_model ( ) <EOL> ccc = self . model . ccc <EOL> cdbuilder = ColorDataBuilderManager ( <EOL> ccc . colormap , ccc . blockchain_state , ccc . cdstore , <EOL> ccc . metastore , AidedColorDataBuilder ) <EOL> ccc . colordata = ThinColorData ( <EOL> cdbuilder , ccc . blockchain_state , ccc . cdstore , ccc . colormap ) <EOL> wc = WalletController ( self . model ) <EOL> adm = self . model . get_asset_definition_manager ( ) <EOL> asset = adm . get_asset_by_moniker ( '<STR_LIT:test>' ) <EOL> self . model . utxo_man . update_all ( ) <EOL> cq = self . model . make_coin_query ( { "<STR_LIT>" : asset } ) <EOL> utxo_list = cq . get_result ( ) <EOL> addrs = wc . get_all_addresses ( asset ) <EOL> wc . send_coins ( asset , [ addrs [ <NUM_LIT:1> ] . get_color_address ( ) ] , [ <NUM_LIT:1000> ] ) <EOL> history = self . model . get_history_for_asset ( asset ) <EOL> self . assertTrue ( len ( history ) > <NUM_LIT:30> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
