<s> import unittest <EOL> from biicode . server . model . address_table import AddressTable <EOL> from biicode . server . model . time_base_map import TimeBaseMap , TimeBaseMapDeserializer <EOL> from biicode . server . model . block import Block <EOL> from biicode . server . model . permissions . element_permissions import ElementPermissions <EOL> from biicode . server . model . epoch . utc_datetime import UtcDatetime <EOL> from biicode . common . utils import serializer <EOL> from biicode . server . model . epoch . time_period import TimePeriod <EOL> from biicode . common . model . symbolic . block_version_table import BlockVersionTable <EOL> from biicode . common . utils . serializer import serialize <EOL> from biicode . common . model . id import ID <EOL> from biicode . common . model . symbolic . block_version import BlockVersion <EOL> from biicode . common . model . brl . brl_block import BRLBlock <EOL> from biicode . common . model . brl . cell_name import CellName <EOL> class SerializationTest ( unittest . TestCase ) : <EOL> '''<STR_LIT>''' <EOL> def test_time_base_map ( self ) : <EOL> t = TimeBaseMap ( ) <EOL> mvt = BlockVersionTable ( [ BlockVersion . loads ( "<STR_LIT>" ) ] ) <EOL> t . append ( <NUM_LIT:0> , mvt ) <EOL> t . append ( <NUM_LIT:1> , mvt ) <EOL> s = serialize ( t ) <EOL> t2 = TimeBaseMapDeserializer ( BlockVersionTable ) . deserialize ( s ) <EOL> self . assertEqual ( t , t2 ) <EOL> def test_address_table ( self ) : <EOL> a = AddressTable ( ID ( ( <NUM_LIT:1> , <NUM_LIT:3> ) ) ) <EOL> a . create ( CellName ( '<STR_LIT>' ) , ID ( ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT> ) ) , <NUM_LIT:2> ) <EOL> s = serialize ( a ) <EOL> b = AddressTable . deserialize ( s , ID ( ( <NUM_LIT:1> , <NUM_LIT:3> ) ) ) <EOL> self . assertEqual ( a , b ) <EOL> def test_block ( self ) : <EOL> m = Block ( ID ( ( <NUM_LIT:1> , <NUM_LIT:3> ) ) , BRLBlock ( '<STR_LIT>' , <NUM_LIT:1> ) ) <EOL> s = m . serialize ( ) <EOL> m2 = Block . deserialize ( s ) <EOL> self . assertEqual ( m , m2 ) <EOL> def test_element_permissions ( self ) : <EOL> elem = ElementPermissions ( BRLBlock ( "<STR_LIT>" ) , True ) <EOL> elem . read . grant ( "<STR_LIT>" ) <EOL> elem . write . grant ( "<STR_LIT>" ) <EOL> serial = elem . serialize ( ) <EOL> deserial = ElementPermissions . deserialize ( serial ) <EOL> self . assertEqual ( elem , deserial ) <EOL> def test_periodicity ( self ) : <EOL> elem = TimePeriod ( "<STR_LIT>" , <NUM_LIT:2> ) <EOL> serial = serializer . serialize ( elem ) <EOL> elem2 = TimePeriod . deserialize ( serial ) <EOL> self . assertEqual ( elem , elem2 ) <EOL> def test_utc_datetime ( self ) : <EOL> elem = UtcDatetime . get_current_utc_datetime ( ) <EOL> serial = elem . serialize ( ) <EOL> elem2 = UtcDatetime . deserialize ( serial ) <EOL> self . assertEqual ( elem , elem2 ) </s>
