def test_should_create_Prefix_from_bytearray_when_parse_method_is_called( self): # GIVEN domain_id = any_domain_id() prefix_length = any_prefix_length() prefix = any_prefix(prefix_length) sub_tlvs = any_prefix_sub_tlvs() factory = network_data.PrefixFactory( config.create_default_network_data_prefix_sub_tlvs_factory()) data = (bytearray([domain_id, prefix_length]) + prefix + convert_prefix_sub_tlvs_to_bytearray(sub_tlvs)) message_info = common.MessageInfo() # WHEN actual_prefix = factory.parse(io.BytesIO(data), message_info) # THEN self.assertTrue(isinstance(actual_prefix, network_data.Prefix)) self.assertEqual(domain_id, actual_prefix.domain_id) self.assertEqual(prefix_length, actual_prefix.prefix_length) self.assertEqual(prefix, actual_prefix.prefix) self.assertEqual(sub_tlvs, actual_prefix.sub_tlvs)
def test_should_create_Prefix_from_bytearray_when_parse_method_is_called(self): # GIVEN domain_id = any_domain_id() prefix_length = any_prefix_length() prefix = any_prefix(prefix_length) sub_tlvs = any_prefix_sub_tlvs() factory = network_data.PrefixFactory(config.create_default_network_data_prefix_sub_tlvs_factory()) data = bytearray([domain_id, prefix_length]) + prefix + convert_prefix_sub_tlvs_to_bytearray(sub_tlvs) message_info = common.MessageInfo() # WHEN actual_prefix = factory.parse(io.BytesIO(data), message_info) # THEN self.assertTrue(isinstance(actual_prefix, network_data.Prefix)) self.assertEqual(domain_id, actual_prefix.domain_id) self.assertEqual(prefix_length, actual_prefix.prefix_length) self.assertEqual(prefix, actual_prefix.prefix) self.assertEqual(sub_tlvs, actual_prefix.sub_tlvs)