<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> import unittest <EOL> import model <EOL> TEST_WAVE_DATA = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> } <EOL> TEST_WAVELET_DATA = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:100> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:title>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : TEST_WAVE_DATA [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : '<STR_LIT>' + model . ROOT_WAVELET_ID_SUFFIX , <EOL> } <EOL> TEST_GADGET_URL = '<STR_LIT>' <EOL> TEST_GADGET = { <EOL> '<STR_LIT:type>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT:url>' : TEST_GADGET_URL , <EOL> '<STR_LIT>' : '<STR_LIT:value>' } <EOL> } <EOL> TEST_BLIP_DATA = { <EOL> '<STR_LIT>' : TEST_WAVELET_DATA [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT:content>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ TEST_WAVELET_DATA [ '<STR_LIT>' ] , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : TEST_WAVELET_DATA [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : TEST_WAVELET_DATA [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : TEST_WAVE_DATA [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : { '<STR_LIT>' : TEST_GADGET } , <EOL> '<STR_LIT>' : TEST_WAVELET_DATA [ '<STR_LIT>' ] , <EOL> } <EOL> class TestWaveModel ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> self . test_wave_data = TEST_WAVE_DATA . copy ( ) <EOL> self . test_wavelet_data = TEST_WAVELET_DATA . copy ( ) <EOL> self . test_blip_data = TEST_BLIP_DATA . copy ( ) <EOL> self . wave = model . Wave ( self . test_wave_data ) <EOL> self . wavelet = model . Wavelet ( self . test_wavelet_data ) <EOL> self . blip = model . Blip ( self . test_blip_data ) <EOL> self . test_context = model . Context ( ) <EOL> self . test_context . waves [ self . wave . waveId ] = self . wave <EOL> self . test_context . wavelets [ self . wavelet . waveletId ] = self . wavelet <EOL> self . test_context . blips [ self . blip . blipId ] = self . blip <EOL> def verifySameAttributes ( self , source , target ) : <EOL> for attr_name in dir ( source ) : <EOL> self . assertTrue ( hasattr ( target , attr_name ) ) <EOL> def testDefaults ( self ) : <EOL> empty_json = { } <EOL> self . verifySameAttributes ( self . blip , model . Blip ( empty_json ) ) <EOL> self . verifySameAttributes ( self . wave , model . Wave ( empty_json ) ) <EOL> self . verifySameAttributes ( self . wavelet , model . Wavelet ( empty_json ) ) <EOL> def testWaveFields ( self ) : <EOL> w = self . wave <EOL> self . assertEquals ( self . test_wave_data [ '<STR_LIT>' ] , w . waveId ) <EOL> self . assertEquals ( set ( self . test_wave_data [ '<STR_LIT>' ] ) , w . waveletIds ) <EOL> def testWaveMethods ( self ) : <EOL> w = self . wave <EOL> self . assertEquals ( self . test_wave_data [ '<STR_LIT>' ] , w . GetId ( ) ) <EOL> self . assertEquals ( set ( self . test_wave_data [ '<STR_LIT>' ] ) , w . GetWaveletIds ( ) ) <EOL> def testWaveletFields ( self ) : <EOL> w = self . wavelet <EOL> self . assertEquals ( self . test_wavelet_data [ '<STR_LIT>' ] , w . creator ) <EOL> self . assertEquals ( self . test_wavelet_data [ '<STR_LIT>' ] , w . creationTime ) <EOL> self . assertEquals ( self . test_wavelet_data [ '<STR_LIT>' ] , <EOL> w . lastModifiedTime ) <EOL> self . assertEquals ( set ( self . test_wavelet_data [ '<STR_LIT>' ] ) , <EOL> w . participants ) <EOL> self . assertEquals ( self . test_wavelet_data [ '<STR_LIT>' ] , w . rootBlipId ) <EOL> self . assertEquals ( self . test_wavelet_data [ '<STR_LIT:title>' ] , w . title ) <EOL> self . assertEquals ( self . test_wavelet_data [ '<STR_LIT>' ] , w . waveId ) <EOL> self . assertEquals ( self . test_wavelet_data [ '<STR_LIT>' ] , w . waveletId ) <EOL> def testWaveletMethods ( self ) : <EOL> w = self . wavelet <EOL> self . assertEquals ( self . test_wavelet_data [ '<STR_LIT>' ] , w . GetCreator ( ) ) <EOL> self . assertEquals ( self . test_wavelet_data [ '<STR_LIT>' ] , <EOL> w . GetCreationTime ( ) ) <EOL> self . assertEquals ( None , w . GetDataDocument ( '<STR_LIT:foo>' ) ) <EOL> self . assertEquals ( <NUM_LIT> , w . GetDataDocument ( '<STR_LIT:foo>' , <NUM_LIT> ) ) <EOL> self . assertEquals ( self . test_wavelet_data [ '<STR_LIT>' ] , <EOL> w . GetLastModifiedTime ( ) ) <EOL> self . assertEquals ( set ( self . test_wavelet_data [ '<STR_LIT>' ] ) , <EOL> w . GetParticipants ( ) ) <EOL> self . assertEquals ( self . test_wavelet_data [ '<STR_LIT>' ] , w . GetRootBlipId ( ) ) <EOL> self . assertEquals ( self . test_wavelet_data [ '<STR_LIT:title>' ] , w . GetTitle ( ) ) <EOL> self . assertEquals ( self . test_wavelet_data [ '<STR_LIT>' ] , w . GetWaveId ( ) ) <EOL> self . assertEquals ( self . test_wavelet_data [ '<STR_LIT>' ] , w . GetId ( ) ) <EOL> def testBlipFields ( self ) : <EOL> b = self . blip <EOL> self . assertEquals ( self . test_blip_data [ '<STR_LIT>' ] , b . blipId ) <EOL> self . assertEquals ( set ( self . test_blip_data [ '<STR_LIT>' ] ) , b . childBlipIds ) <EOL> self . assertEquals ( set ( self . test_blip_data [ '<STR_LIT>' ] ) , b . contributors ) <EOL> self . assertEquals ( self . test_blip_data [ '<STR_LIT>' ] , b . creator ) <EOL> self . assertEquals ( self . test_blip_data [ '<STR_LIT:content>' ] , b . document . GetText ( ) ) <EOL> self . assertEquals ( self . test_blip_data [ '<STR_LIT>' ] , <EOL> b . lastModifiedTime ) <EOL> self . assertEquals ( self . test_blip_data [ '<STR_LIT>' ] , b . parentBlipId ) <EOL> self . assertEquals ( self . test_blip_data [ '<STR_LIT>' ] , b . waveId ) <EOL> self . assertEquals ( self . test_blip_data [ '<STR_LIT>' ] , b . waveletId ) <EOL> self . assertEquals ( self . test_blip_data [ '<STR_LIT>' ] , b . waveletId ) <EOL> self . assertTrue ( b . IsRoot ( ) ) <EOL> def testBlipMethods ( self ) : <EOL> b = self . blip <EOL> self . assertEquals ( self . test_blip_data [ '<STR_LIT>' ] , b . GetId ( ) ) <EOL> self . assertEquals ( set ( self . test_blip_data [ '<STR_LIT>' ] ) , <EOL> b . GetChildBlipIds ( ) ) <EOL> self . assertEquals ( set ( self . test_blip_data [ '<STR_LIT>' ] ) , <EOL> b . GetContributors ( ) ) <EOL> self . assertEquals ( self . test_blip_data [ '<STR_LIT>' ] , b . GetCreator ( ) ) <EOL> self . assertEquals ( self . test_blip_data [ '<STR_LIT:content>' ] , b . GetDocument ( ) . GetText ( ) ) <EOL> self . assertEquals ( self . test_blip_data [ '<STR_LIT>' ] , <EOL> b . GetLastModifiedTime ( ) ) <EOL> self . assertEquals ( self . test_blip_data [ '<STR_LIT>' ] , b . GetParentBlipId ( ) ) <EOL> self . assertEquals ( self . test_blip_data [ '<STR_LIT>' ] , b . GetWaveId ( ) ) <EOL> self . assertEquals ( len ( self . test_blip_data [ '<STR_LIT>' ] ) , len ( b . GetElements ( ) ) ) <EOL> self . assertTrue ( b . IsRoot ( ) ) <EOL> self . assertEquals ( b . GetGadgetByUrl ( TEST_GADGET_URL ) . url , TEST_GADGET_URL ) <EOL> def testBlipIsNotRoot ( self ) : <EOL> self . test_blip_data [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> b = model . Blip ( self . test_blip_data ) <EOL> self . assertFalse ( b . IsRoot ( ) ) <EOL> def testDocument ( self ) : <EOL> b = model . Blip ( self . test_blip_data ) <EOL> doc = model . Document ( b ) <EOL> self . assertEquals ( b . content , doc . GetText ( ) ) <EOL> def testEvent ( self ) : <EOL> data = { '<STR_LIT:type>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> event_data = model . Event ( data ) <EOL> self . assertEquals ( data [ '<STR_LIT:type>' ] , event_data . type ) <EOL> self . assertEquals ( data [ '<STR_LIT>' ] , event_data . properties ) <EOL> self . assertEquals ( data [ '<STR_LIT>' ] , event_data . timestamp ) <EOL> self . assertEquals ( data [ '<STR_LIT>' ] , event_data . modifiedBy ) <EOL> def testContext ( self ) : <EOL> self . assertEquals ( self . blip , <EOL> self . test_context . GetBlipById ( self . blip . blipId ) ) <EOL> self . assertEquals ( self . blip , self . test_context . blips [ self . blip . blipId ] ) <EOL> self . assertEquals ( self . wave , <EOL> self . test_context . GetWaveById ( self . wave . waveId ) ) <EOL> self . assertEquals ( self . wave , self . test_context . waves [ self . wave . waveId ] ) <EOL> self . assertEquals ( self . wavelet , <EOL> self . test_context . GetWaveletById ( self . wavelet . waveletId ) ) <EOL> self . assertEquals ( self . wavelet , <EOL> self . test_context . wavelets [ self . wavelet . waveletId ] ) <EOL> self . assertEquals ( self . wavelet , self . test_context . GetRootWavelet ( ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
