diff options
author | YAMAMOTO Takashi <yamamoto@valinux.co.jp> | 2013-09-02 15:06:25 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2013-09-02 19:41:39 +0900 |
commit | baddcecedccc2ce200e4e3699eee126b624e9f37 (patch) | |
tree | 63dce9ab664927d87daa82b8d30d9d86061da590 | |
parent | 6a099204c3432e4fd6827c830f7464c92e7694f3 (diff) |
test_parser: ensure that "len" "length" fields can be omitted
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/tests/unit/ofproto/test_parser.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/ryu/tests/unit/ofproto/test_parser.py b/ryu/tests/unit/ofproto/test_parser.py index 4cf5641f..6ad64c03 100644 --- a/ryu/tests/unit/ofproto/test_parser.py +++ b/ryu/tests/unit/ofproto/test_parser.py @@ -159,6 +159,26 @@ class Test_Parser(unittest.TestCase): eq_(self._msg_to_jsondict(msg2), json_dict) eq_(wire_msg, msg2.buf) + # check if "len" "length" fields can be omitted + + def _remove(d, names): + f = lambda x: _remove(x, names) + if isinstance(d, list): + return map(f, d) + if isinstance(d, dict): + d2 = {} + for k, v in d.iteritems(): + if k in names: + continue + d2[k] = f(v) + return d2 + return d + + json_dict3 = _remove(json_dict, ['len', 'length']) + msg3 = self._jsondict_to_msg(dp, json_dict3) + msg3.serialize() + eq_(wire_msg, msg3.buf) + def _add_tests(): import os |