<s> from __future__ import absolute_import <EOL> from copy import deepcopy <EOL> import unittest <EOL> from pyes . tests import ESTestCase <EOL> from pyes . models import DotDict <EOL> class ElasticSearchModelTestCase ( ESTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( ElasticSearchModelTestCase , self ) . setUp ( ) <EOL> self . init_default_index ( ) <EOL> def test_ElasticSearchModel_init ( self ) : <EOL> obj = self . conn . factory_object ( self . index_name , self . document_type , { "<STR_LIT:name>" : "<STR_LIT:test>" , "<STR_LIT>" : <NUM_LIT:1> } ) <EOL> self . assertEqual ( obj . name , "<STR_LIT:test>" ) <EOL> obj . name = "<STR_LIT>" <EOL> self . assertEqual ( obj . name , "<STR_LIT>" ) <EOL> self . assertEqual ( obj . val , <NUM_LIT:1> ) <EOL> self . assertEqual ( obj . _meta . id , None ) <EOL> obj . _meta . id = "<STR_LIT>" <EOL> self . assertEqual ( obj . _meta . id , "<STR_LIT>" ) <EOL> self . assertEqual ( sorted ( obj . keys ( ) ) , [ "<STR_LIT:name>" , "<STR_LIT>" ] ) <EOL> obj . save ( ) <EOL> obj . name = "<STR_LIT>" <EOL> obj . save ( ) <EOL> reloaded = self . conn . get ( self . index_name , self . document_type , obj . _meta . id ) <EOL> self . assertEqual ( reloaded . name , "<STR_LIT>" ) <EOL> def test_DotDict ( self ) : <EOL> dotdict = DotDict ( foo = "<STR_LIT:bar>" ) <EOL> dotdict2 = deepcopy ( dotdict ) <EOL> dotdict2 [ "<STR_LIT:foo>" ] = "<STR_LIT>" <EOL> self . assertEqual ( dotdict [ "<STR_LIT:foo>" ] , "<STR_LIT:bar>" ) <EOL> self . assertEqual ( dotdict2 [ "<STR_LIT:foo>" ] , "<STR_LIT>" ) <EOL> self . assertEqual ( type ( dotdict2 ) , DotDict ) <EOL> dotdict = DotDict ( foo = "<STR_LIT:bar>" , bar = DotDict ( baz = "<STR_LIT>" ) ) <EOL> dotdict2 = deepcopy ( dotdict ) <EOL> dotdict2 [ "<STR_LIT:bar>" ] [ "<STR_LIT>" ] = "<STR_LIT:foo>" <EOL> self . assertEqual ( dotdict [ "<STR_LIT:bar>" ] [ "<STR_LIT>" ] , "<STR_LIT>" ) <EOL> self . assertEqual ( dotdict2 [ "<STR_LIT:bar>" ] [ "<STR_LIT>" ] , "<STR_LIT:foo>" ) <EOL> self . assertEqual ( type ( dotdict2 ) , DotDict ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
