Inconsistent deserialization of integers
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
neutron |
Fix Released
|
High
|
dan wendlandt | ||
quantum (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Bug Description
The PortCount attribute of a network is returned as an integer in /quantum/
The json deserializer properly converts this into a python integer, but the XML deserialization returns it as a string.
The unit test checks for an integer and fails.
I confirmed that if I change networks.py and the unit test to use a string, the test passes for both JSON and XML.
Seems like two fixes are possible:
1) change the XML deserialization to be able to recognize when something is an integer and parse it into a python int.
2) say that the API does not support passing integer values and change the PortCount field to be a string (PortCount does not appear anywhere on the API spec page, http://
Related branches
- Somik Behera: Approve (netstack-core)
- Salvatore Orlando: Approve
-
Diff: 40 lines (+3/-9)2 files modifiedquantum/api/views/networks.py (+1/-5)
tests/unit/test_api.py (+2/-4)
Changed in quantum: | |
importance: | Critical → High |
Changed in quantum: | |
status: | In Progress → Fix Committed |
Changed in quantum: | |
status: | Fix Committed → Fix Released |
Changed in quantum (Ubuntu): | |
status: | New → Fix Released |
FYI, below are the tests that are failing
======= ======= ======= ======= ======= ======= ======= ======= ======= ======= network_ xml (tests. unit.test_ api.APITest) ------- ------- ------- ------- ------- ------- ------- ------- ------- danwent/ quantum2/ tests/unit/ test_api. py", line 694, in test_rename_ network_ xml _test_rename_ network( 'xml') danwent/ quantum2/ tests/unit/ test_api. py", line 152, in _test_rename_ network data['network' ]) 9c66-491a- b97d-3c4d2a7621 77', 'name': 'new_net [truncated]... != {u'PortCount': u'0', u'id': u'0d63c0ba- 9c66-491a- b97d-3c4d2a7621 77', u'name': u' [truncated]...
FAIL: test_rename_
-------
Traceback (most recent call last):
File "/home/
self.
File "/home/
network_
AssertionError: {'PortCount': 0, 'id': u'0d63c0ba-
- {'PortCount': 0,
+ {u'PortCount': u'0',
? + ++ +
- 'id': u'0d63c0ba- 9c66-491a- b97d-3c4d2a7621 77', 9c66-491a- b97d-3c4d2a7621 77',
+ u'id': u'0d63c0ba-
? +
- 'name': 'new_network_name'} name'}
+ u'name': u'new_network_
? + +
======= ======= ======= ======= ======= ======= ======= ======= ======= ======= network_ xml (tests. unit.test_ api.APITest) ------- ------- ------- ------- ------- ------- ------- ------- ------- danwent/ quantum2/ tests/unit/ test_api. py", line 682, in test_show_ network_ xml _test_show_ network( 'xml') danwent/ quantum2/ tests/unit/ test_api. py", line 119, in _test_show_network data['network' ]) de74-4dc3- 9428-38551af79e 08', 'name': 'test_ne [truncated]... != {u'PortCount': u'0', u'id': u'86fbc2af- de74-4dc3- 9428-38551af79e 08', u'name': u' [truncated]...
FAIL: test_show_
-------
Traceback (most recent call last):
File "/home/
self.
File "/home/
network_
AssertionError: {'PortCount': 0, 'id': u'86fbc2af-
- {'PortCount': 0,
+ {u'PortCount': u'0',
? + ++ +
- 'id': u'86fbc2af- de74-4dc3- 9428-38551af79e 08', de74-4dc3- 9428-38551af79e 08',
+ u'id': u'86fbc2af-
? +
- 'name': 'test_network'}
+ u'name': u'test_network'}
? + +