44import unittest
55import uuid
66
7+ from cybox .bindings .cybox_common import StringObjectPropertyType
8+ from cybox .bindings .whois_object import (WhoisContactType ,
9+ WhoisRegistrantInfoType )
10+
711from cybox .objects .address_object import Address
812from cybox .objects .uri_object import URI
913from cybox .objects .whois_object import (WhoisEntry , WhoisContact ,
@@ -84,15 +88,17 @@ class TestContact(EntityTestCase, unittest.TestCase):
8488
8589 _full_dict = {
8690 'contact_type' : "ADMIN" ,
87- 'contact_id' : "abc123" ,
88- 'name' : "John Smith" ,
91+ 'contact_id' : u "abc123" ,
92+ 'name' : u "John Smith" ,
8993 'email_address' : {
90- 'address_value' : "john@smith.com" ,
94+ 'address_value' : u "john@smith.com" ,
9195 'category' : Address .CAT_EMAIL ,
9296 'xsi:type' : "AddressObjectType" ,
9397 },
94- 'phone_number' : "(800) 555-1212" ,
95- 'address' : "123 Main St.\n Anytown, CA 01234" ,
98+ 'phone_number' : u"(800) 555-1212" ,
99+ 'fax_number' : u"(800) 555-1200" ,
100+ 'address' : u"123 Main St.\n Anytown, CA 01234" ,
101+ 'organization' : u"XYZ Hosting" ,
96102 }
97103
98104 def test_parse_email_address (self ):
@@ -114,6 +120,31 @@ class TestRegistrant(EntityTestCase, unittest.TestCase):
114120 'registrant_id' : "reg1234" ,
115121 }
116122
123+ # https://github.com/CybOXProject/python-cybox/issues/227
124+ def test_issue_227_binding_init (self ):
125+ # Fax_Number and Organization were added to the __init__ method of
126+ # WhoisContactType, but not to its subclass (WhoisRegistrantType). Once
127+ # the objects are constructed, they should have equivalent dictionary
128+ # represesntations (as long as the extra fields in the subclass are not
129+ # present).
130+ contact_obj = WhoisContactType (
131+ contact_type = "ADMIN" ,
132+ Contact_ID = StringObjectPropertyType (valueOf_ = "abc123" ),
133+ Fax_Number = StringObjectPropertyType (valueOf_ = u"(800) 555-1200" ),
134+ Organization = StringObjectPropertyType (valueOf_ = u"XYZ Hosting" ),
135+ )
136+ contact = WhoisContact .from_obj (contact_obj )
137+
138+ reg_obj = WhoisRegistrantInfoType (
139+ contact_type = "ADMIN" ,
140+ Contact_ID = StringObjectPropertyType (valueOf_ = "abc123" ),
141+ Fax_Number = StringObjectPropertyType (valueOf_ = u"(800) 555-1200" ),
142+ Organization = StringObjectPropertyType (valueOf_ = u"XYZ Hosting" ),
143+ )
144+ registrant = WhoisRegistrant .from_obj (reg_obj )
145+
146+ self .assertEqual (contact .to_dict (), registrant .to_dict ())
147+
117148
118149class TestRegistrar (EntityTestCase , unittest .TestCase ):
119150 klass = WhoisRegistrar
0 commit comments