def test_sanity(self): """ encode(decode(obj)) is equal to obj. """ rec = recoder.DaphneCorbaRecode("utf-8") reg = fredcorba.Registry.Registrar.Detail(id=19, ico='', dic='', varSymb='', vat=False, handle='NEW REG', name='name 1', organization='', street1='', street2='', street3='', city='', stateorprovince='state', postalcode='', country='CZ', telephone='', fax='', email='', url='', credit='0.00', unspec_credit=u"0.00", access=[], zones=[], hidden=False) decoded_reg = rec.decode(reg) encoded_reg = rec.encode(decoded_reg) assert_equal(encoded_reg.__dict__, reg.__dict__)
def test_decode_date_type(self): rec = recoder.DaphneCorbaRecode("utf-8") d = fredcorba.ccReg.DateType(10, 10, 2009) res = rec.decode(d) assert_equal(res, datetime.date(2009, 10, 10))
def test_encode_date(self): rec = recoder.DaphneCorbaRecode("utf-8") p_obj = datetime.date(1, 2, 3) expected = fredcorba.ccReg.DateType(3, 2, 1) res = rec.encode(p_obj) assert_equal(res.__dict__, expected.__dict__)
def test_decode_date_type(self): rec = recoder.DaphneCorbaRecode("utf-8") d = fredcorba.ccReg.DateType(10, 10, 2009) res = rec.decode(d) requiring(res).is_not_none() requiring(res).equal_to(datetime.date(2009, 10, 10))
def test_encode_date(self): rec = recoder.DaphneCorbaRecode("utf-8") p_obj = datetime.date(1, 2, 3) expected = fredcorba.ccReg.DateType(3, 2, 1) res = rec.encode(p_obj) requiring(res).is_not_none() requiring(res.__dict__).equal_to(expected.__dict__)
def test_decode(self): """ DaphneCorbaRecoder decodes corba entity to python correctly . """ rec = recoder.DaphneCorbaRecode("utf-8") reg = fredcorba.Registry.Registrar.Detail(id=19, ico='', dic='', varSymb='', vat=False, handle='NEW REG', name='name 1', organization='', street1='', street2='', street3='', city='', stateorprovince='state', postalcode='', country='CZ', telephone='', fax='', email='', url='', credit='0.00', unspec_credit=u"0.00", access=[], zones=[], hidden=False) expected = fredcorba.Registry.Registrar.Detail( id=19, ico=u'', dic=u'', varSymb=u'', vat=False, handle=u'NEW REG', name=u'name 1', organization=u'', street1=u'', street2=u'', street3=u'', city=u'', stateorprovince=u'state', postalcode=u'', country=u'CZ', telephone=u'', fax=u'', email=u'', url=u'', credit=u'0.00', unspec_credit=u"0.00", access=[], zones=[], hidden=False) decoded_reg = rec.decode(reg) requiring(decoded_reg).is_not_none() requiring(decoded_reg.__dict__).equal_to(expected.__dict__)
def test_encode(self): rec = recoder.DaphneCorbaRecode("utf-8") python_entity = fredcorba.Registry.Registrar.Detail( id=19, ico=u'', dic=u'', varSymb=u'', vat=False, handle=u'NEW REG', name=u'name 1', organization=u'', street1=u'', street2=u'', street3=u'', city=u'', stateorprovince=u'state', postalcode=u'', country=u'CZ', telephone=u'', fax=u'', email=u'', url=u'', credit=u'0.00', unspec_credit=u"0.00", access=[], zones=[], hidden=False) expected = fredcorba.Registry.Registrar.Detail(id=19, ico='', dic='', varSymb='', vat=False, handle='NEW REG', name='name 1', organization='', street1='', street2='', street3='', city='', stateorprovince='state', postalcode='', country='CZ', unspec_credit=u"0.00", telephone='', fax='', email='', url='', credit='0.00', access=[], zones=[], hidden=False) encoded_entity = rec.encode(python_entity) assert_equal(encoded_entity.__dict__, expected.__dict__)
def test_encode_double_nested_oldstyle_class(self): """ Nested class gets encoded OK. Note: We're using old-style classes, because that's what omniORBpy does. """ rec = recoder.DaphneCorbaRecode("utf-8") p_ent = TestDaphneCorbaRecoder.Foo( 1, TestDaphneCorbaRecoder.Bar( 2, TestDaphneCorbaRecoder.Bar(3, fredtypes.NullDate(), "5"), 6.0), fredtypes.NullInt()) exp = TestDaphneCorbaRecoder.Foo( 1, TestDaphneCorbaRecoder.Bar( 2, TestDaphneCorbaRecoder.Bar(3, fredcorba.ccReg.DateType(0, 0, 0), "5"), 6.0), 0) res = rec.encode(p_ent) requiring(res).equal_to(exp)
def test_create(self): """ DaphneCorbaRecoder is created with supported encoding. """ rec = recoder.DaphneCorbaRecode("utf-8") requiring(rec).is_not_none()
def test_encode_nested_date(self): rec = recoder.DaphneCorbaRecode("utf-8") entity = fredcorba.Registry.Registrar.Detail( id=19, ico=u'', dic=u'', varSymb=u'', vat=False, handle=u'NEW REG', name=u'name 1', organization=u'', street1=u'', street2=u'', street3=u'', city=u'', stateorprovince=u'state', postalcode=u'', country=u'CZ', telephone=u'', fax=u'', email=u'', url=u'', credit=u'0.00', unspec_credit=u"0.00", access=[], zones=[ fredcorba.ccReg.AdminZoneAccess(id=0, name=u'cz', fromDate=datetime.date( 2009, 12, 11), toDate=fredtypes.NullDate()) ], hidden=False) expected = fredcorba.Registry.Registrar.Detail( id=19, ico='', dic='', varSymb='', vat=False, handle='NEW REG', name='name 1', organization='', street1='', street2='', street3='', city='', stateorprovince='state', postalcode='', country='CZ', telephone='', fax='', email='', url='', unspec_credit=u"0.00", credit='0.00', access=[], zones=[ fredcorba.ccReg.AdminZoneAccess( id=0, name='cz', fromDate=fredcorba.ccReg.DateType(day=11, month=12, year=2009), toDate='') ], hidden=False) res = rec.encode(entity) requiring(res).is_not_none() requiring(expected.__dict__['zones'][0].fromDate.__dict__).\ equal_to(res.__dict__['zones'][0].fromDate.__dict__)