Signed-off-by: itoyuichi <[email protected]>
---
ryu/tests/unit/packet/test_udp.py | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/ryu/tests/unit/packet/test_udp.py
b/ryu/tests/unit/packet/test_udp.py
index 6418743..286c08a 100644
--- a/ryu/tests/unit/packet/test_udp.py
+++ b/ryu/tests/unit/packet/test_udp.py
@@ -16,6 +16,7 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
import unittest
+import json
import logging
import struct
from struct import *
@@ -42,6 +43,18 @@ class Test_udp(unittest.TestCase):
u = udp(src_port, dst_port, total_length, csum)
buf = pack(udp._PACK_STR, src_port, dst_port, total_length, csum)
+ jsonstr = '''
+ {
+ "udp": {
+ "src_port": 6431,
+ "dst_port": 8080,
+ "total_length": 65507,
+ "csum": 12345
+ }
+ }
+ '''
+ jsondict = json.loads(jsonstr)
+
def setUp(self):
pass
@@ -94,3 +107,10 @@ class Test_udp(unittest.TestCase):
def test_malformed_udp(self):
m_short_buf = self.buf[1:udp._MIN_LEN]
udp.parser(m_short_buf)
+
+ def test_to_jsondict(self):
+ eq_(self.jsondict, self.u.to_jsondict())
+
+ def test_from_jsondict(self):
+ u = udp.from_jsondict(self.jsondict['udp'])
+ eq_(str(u), str(self.u))
--
1.7.10.4
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel