def test_serialize_every_config_frag(self): for config_frag in (ofconfig.OFPC_FRAG_NORMAL, ofconfig.OFPC_FRAG_DROP, ofconfig.OFPC_FRAG_REASM): sc = ofconfig.SwitchConfig(config_frag=config_frag, miss_send_len=128) self.assertEqual( struct.pack('!H', config_frag) + '\x00\x80', sc.serialize())
def test_get_config(self): self.proto.connectionMade() self._get_next_sent_message() # Initial OFPT_HELLO. self._get_next_sent_message() # Initial OFPT_ECHO_REQUEST. self._get_next_sent_message() # Initial OFPT_FEATURES_REQUEST. def _callback(switch_config, callbacks_made=self.callbacks_made): callbacks_made.append(('get_config', switch_config)) self.proto.get_config(_callback) # Sent OFPT_GET_CONFIG_REQUEST with XID 2. self.assertTupleEqual(('handle_get_config_request', 2), self._get_next_sent_message()) # Send the OFPT_GET_CONFIG_REPLY message to answer the request. sc = ofconfig.SwitchConfig(config_frag=ofconfig.OFPC_FRAG_DROP, miss_send_len=128) self.peerproto.send_get_config_reply(2, sc) self.assertItemsEqual([('get_config', sc)], self.callbacks_made)
def test_serialize_deserialize(self): sc = ofconfig.SwitchConfig(config_frag=ofconfig.OFPC_FRAG_DROP, miss_send_len=128) self.buf.append(sc.serialize()) self.buf.set_message_boundaries(4) self.assertTupleEqual(sc, ofconfig.SwitchConfig.deserialize(self.buf))
def test_serialize(self): sc = ofconfig.SwitchConfig(config_frag=ofconfig.OFPC_FRAG_DROP, miss_send_len=128) self.assertEqual('\x00\x01\x00\x80', sc.serialize())
def test_create(self): sc = ofconfig.SwitchConfig(config_frag=ofconfig.OFPC_FRAG_DROP, miss_send_len=128)