<s> from oppy . cell . cell import Cell <EOL> from oppy . cell . exceptions import BadPayloadData <EOL> CIRC_ID = <NUM_LIT:1> <EOL> class CellTestBase ( object ) : <EOL> def test_parse ( self ) : <EOL> '''<STR_LIT>''' <EOL> cell = Cell . parse ( self . cell_constants [ '<STR_LIT>' ] , <EOL> encrypted = self . encrypted ) <EOL> assert isinstance ( cell , self . cell_constants [ '<STR_LIT>' ] ) <EOL> assert cell . header . __dict__ == self . cell_header <EOL> for key in self . cell_attributes : <EOL> assert getattr ( cell , key ) == self . cell_attributes [ key ] <EOL> cell2 = Cell . parse ( cell . getBytes ( ) , encrypted = self . encrypted ) <EOL> assert cell . getBytes ( ) == cell2 . getBytes ( ) <EOL> assert cell == cell2 <EOL> def test_parse_bad ( self ) : <EOL> '''<STR_LIT>''' <EOL> for bad_input in self . bad_parse_inputs : <EOL> self . assertRaises ( BadPayloadData , Cell . parse , bad_input , <EOL> encrypted = self . encrypted ) <EOL> def test_getBytes ( self ) : <EOL> '''<STR_LIT>''' <EOL> cell = Cell . parse ( self . cell_constants [ '<STR_LIT>' ] , <EOL> encrypted = self . encrypted ) <EOL> assert cell . getBytes ( ) == self . cell_constants [ '<STR_LIT>' ] <EOL> def test_make ( self ) : <EOL> '''<STR_LIT>''' <EOL> cell = self . cell_constants [ '<STR_LIT>' ] . make ( <EOL> self . cell_header [ '<STR_LIT>' ] , <EOL> * self . cell_attributes . values ( ) ) <EOL> assert isinstance ( cell , self . cell_constants [ '<STR_LIT>' ] ) <EOL> assert cell . getBytes ( ) == self . cell_constants [ '<STR_LIT>' ] <EOL> assert cell . header . __dict__ == self . cell_header <EOL> for key in self . cell_attributes : <EOL> assert getattr ( cell , key ) == self . cell_attributes [ key ] <EOL> def test_make_bad ( self ) : <EOL> '''<STR_LIT>''' <EOL> for bad_input in self . bad_make_inputs : <EOL> self . assertRaises ( BadPayloadData , <EOL> self . cell_constants [ '<STR_LIT>' ] . make , <EOL> * bad_input ) <EOL> def test_repr ( self ) : <EOL> '''<STR_LIT>''' <EOL> from oppy . cell . fixedlen import ( <EOL> FixedLenCell , <EOL> Create2Cell , <EOL> Created2Cell , <EOL> DestroyCell , <EOL> EncryptedCell , <EOL> NetInfoCell , <EOL> PaddingCell , <EOL> ) <EOL> from oppy . cell . varlen import ( <EOL> VarLenCell , <EOL> AuthChallengeCell , <EOL> CertsCell , <EOL> VersionsCell , <EOL> VPaddingCell , <EOL> ) <EOL> from oppy . cell . util import ( <EOL> TLVTriple , <EOL> CertsCellPayloadItem , <EOL> ) <EOL> cell = Cell . parse ( self . cell_constants [ '<STR_LIT>' ] , <EOL> encrypted = self . encrypted ) <EOL> cell2 = eval ( repr ( cell ) ) <EOL> assert cell . getBytes ( ) == cell2 . getBytes ( ) <EOL> assert len ( cell ) == len ( cell2 ) <EOL> assert cell == cell2 <EOL> class FixedLenTestBase ( CellTestBase ) : <EOL> def test_getBytes_trimmed ( self ) : <EOL> cell = Cell . parse ( self . cell_constants [ '<STR_LIT>' ] , <EOL> encrypted = self . encrypted ) <EOL> assert cell . getBytes ( trimmed = True ) == self . cell_constants [ '<STR_LIT>' ] <EOL> def test_len ( self ) : <EOL> '''<STR_LIT>''' <EOL> cell = Cell . parse ( self . cell_constants [ '<STR_LIT>' ] , <EOL> encrypted = self . encrypted ) <EOL> cell_2 = self . cell_constants [ '<STR_LIT>' ] . make ( <EOL> self . cell_header [ '<STR_LIT>' ] , <EOL> * self . cell_attributes . values ( ) ) <EOL> assert len ( cell ) == len ( cell_2 ) <EOL> assert len ( cell ) == len ( self . cell_constants [ '<STR_LIT>' ] ) <EOL> if cell . header . link_version < <NUM_LIT:4> : <EOL> assert len ( cell ) == <NUM_LIT> <EOL> else : <EOL> assert len ( cell ) == <NUM_LIT> <EOL> class VarLenTestBase ( CellTestBase ) : <EOL> def test_len ( self ) : <EOL> '''<STR_LIT>''' <EOL> cell = Cell . parse ( self . cell_constants [ '<STR_LIT>' ] , <EOL> encrypted = self . encrypted ) <EOL> cell_2 = self . cell_constants [ '<STR_LIT>' ] . make ( <EOL> self . cell_header [ '<STR_LIT>' ] , <EOL> * self . cell_attributes . values ( ) ) <EOL> assert len ( cell ) == len ( cell_2 ) <EOL> assert len ( cell ) == len ( self . cell_constants [ '<STR_LIT>' ] ) </s>
