Skip to content

Instantly share code, notes, and snippets.

@cemsbr
Created July 27, 2016 14:52
Show Gist options
  • Save cemsbr/34d8f4cbec615fb18d7da63c637176f9 to your computer and use it in GitHub Desktop.
Save cemsbr/34d8f4cbec615fb18d7da63c637176f9 to your computer and use it in GitHub Desktop.
Pattern for testing raw dumps
import unittest
from pyof.v0x01.controller2switch.barrier_reply import BarrierReply
from tests.rawdump import RawDump
class TestBarrierReply(unittest.TestCase):
def setUp(self):
self.message = BarrierReply(xid=5)
self.raw_file = RawDump('v0x01').read('ofpt_barrier_reply')
def test_get_size(self):
self.assertEqual(self.message.get_size(), 8)
def test_pack(self):
raw_obj = self.message.pack()
self.assertEqual(raw_obj, self.raw_file)
def test_unpack(self):
unpacked = BarrierReply()
unpacked.unpack(self.raw_file)
self.assertEqual(unpacked, self.message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment