<s> from __future__ import print_function <EOL> from __future__ import unicode_literals <EOL> try : <EOL> from unittest import mock <EOL> except ImportError : <EOL> import mock <EOL> from tdclient import models <EOL> from tdclient . test . test_helper import * <EOL> def setup_function ( function ) : <EOL> unset_environ ( ) <EOL> def test_database ( ) : <EOL> client = mock . MagicMock ( ) <EOL> database = models . Database ( client , "<STR_LIT>" , tables = [ "<STR_LIT>" , "<STR_LIT>" ] , count = <NUM_LIT> , created_at = "<STR_LIT>" , updated_at = "<STR_LIT>" , org_name = "<STR_LIT>" , permission = "<STR_LIT>" ) <EOL> assert database . org_name == "<STR_LIT>" <EOL> assert database . permission == "<STR_LIT>" <EOL> assert database . count == <NUM_LIT> <EOL> assert database . name == "<STR_LIT>" <EOL> assert database . tables ( ) == [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> assert database . created_at == "<STR_LIT>" <EOL> assert database . updated_at == "<STR_LIT>" <EOL> def test_database_update_tables ( ) : <EOL> client = mock . MagicMock ( ) <EOL> client . tables = mock . MagicMock ( return_value = [ <EOL> models . Table ( client , "<STR_LIT>" , "<STR_LIT:foo>" , "<STR_LIT:type>" , "<STR_LIT>" , "<STR_LIT:count>" ) , <EOL> models . Table ( client , "<STR_LIT>" , "<STR_LIT:bar>" , "<STR_LIT:type>" , "<STR_LIT>" , "<STR_LIT:count>" ) , <EOL> models . Table ( client , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:type>" , "<STR_LIT>" , "<STR_LIT:count>" ) , <EOL> ] ) <EOL> database = models . Database ( client , "<STR_LIT>" , tables = None , count = <NUM_LIT> , created_at = "<STR_LIT>" , updated_at = "<STR_LIT>" , org_name = "<STR_LIT>" , permission = "<STR_LIT>" ) <EOL> tables = database . tables ( ) <EOL> assert [ table . name for table in tables ] == [ "<STR_LIT:foo>" , "<STR_LIT:bar>" , "<STR_LIT>" ] <EOL> client . tables . assert_called_with ( "<STR_LIT>" ) </s>
