| Summary: | XMLRPC driver does not allow None values | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Other] TCMS | Reporter: | Petr Šplíchal <psplicha> | ||||
| Component: | Application | Assignee: | jianchen <jianchen> | ||||
| Status: | CLOSED CURRENTRELEASE | QA Contact: | tools-bugs <tools-bugs> | ||||
| Severity: | medium | Docs Contact: | |||||
| Priority: | medium | ||||||
| Version: | 3.4.1 | CC: | aigao, azelinka, jianchen, junzhang, nli, ohudlick, ryang, tools-bugs, vchen, xchu, xgao, yuwang, zheliu | ||||
| Target Milestone: | --- | ||||||
| Target Release: | 3.8.0 | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Whiteboard: | |||||||
| Fixed In Version: | 3.8.0-3 | Doc Type: | Bug Fix | ||||
| Doc Text: | Story Points: | --- | |||||
| Clone Of: | Environment: | ||||||
| Last Closed: | 2014-09-26 13:21:05 UTC | Type: | --- | ||||
| Regression: | --- | Mount Type: | --- | ||||
| Documentation: | --- | CRM: | |||||
| Verified Versions: | Category: | --- | |||||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
| Cloudforms Team: | --- | Target Upstream Version: | |||||
| Bug Depends On: | |||||||
| Bug Blocks: | 593666 | ||||||
| Attachments: |
|
||||||
Created attachment 506233 [details]
Simple patch allowing None values
Simple patch allowing None values
Well, the patch fixes the traceback, however the value on the server is still not updated. Is there any other way how to update field value to None? Sorry for late reply.
Do you really need to set notes = None, how about leave it blank.
See codes below:
if form.cleaned_data['notes']:
tcrs.update(notes = form.cleaned_data['notes'])
Set notes = None, the 'tcrs.update()' will never execute, this is the reason.
I see, using empty string could be a solution here. But similar
problems appear at other places. For example when trying to clear
the default tester for a test run:
TestRun.update(6757, {'default_tester': None })
This will not clear the default tester id and using and empty
string here is not an option. I believe there should be a clean
way how to set values to None.
I also suffer from this 'does not allow none values' while calling rpc. I'll take it, will do some research on it and update afterwards. Thanks for reporting. Test case "arguments" field started to return "None" while before it returned "" when the field was empty. Is that connected with implementation of this bug? Is that expected behavior? Thanks. See case 32768 as an example. from Web, https://tcms.engineering.redhat.com/case/32768/ The fields 'arguments' are displayed as "None" from rpc, it returns empty string: >>> n.server.TestCase.get(32768).get('arguments') '' In db: mysql> select arguments from test_cases where case_id=32768; +-----------+ | arguments | +-----------+ | | +-----------+ The 'arguments' field is empty while through Web you'll see 'None' instead of empty. But this differs from case to case, see bug 740220 for an example where for one test case '' is returned and for the other 'None'. In the web interface both show as None. In TCMS 3.6 Hotfix which is already now alive, the driver initialization will set allow_none=True. Thanks for updating the driver. However, this is only a part of the problem. We're still unable to update object with a 'None' value, see comment #4 for an example. This still does not work. Hi, any progress here? This bug was fixed in tcms 3.8.0. Thanks. This seems to be working with the example in comment #4 but I am still not able to update the test case run notes to None. Also providing an empty string does not have any effect: >>> TestCaseRun.update(1205413, {"notes": "hmmm" }) [{'case': 'Blah blah blah blah', 'build_id': 1156, 'tested_by_id': 2117, 'environment_id': 0, 'run': 'Test run', 'links': [], 'run_id': 41118, 'notes': 'hmmm', <------------------- here -------------- 'sortkey': 0, 'running_date': None, 'assignee': 'mfranc', 'build': 'unspecified', 'case_id': 35269, 'is_current': False, 'case_run_status': 'IDLE', 'assignee_id': 2739, 'case_run_id': 1205413, 'tested_by': 'psplicha', 'case_text_version': 1, 'case_run_status_id': 1, 'close_date': '2012-07-25 17:27:14'}] >>> TestCaseRun.update(1205413, {"notes": "" }) [{'case': 'Blah blah blah blah', 'build_id': 1156, 'tested_by_id': 2117, 'environment_id': 0, 'run': 'Test run', 'links': [], 'run_id': 41118, 'notes': 'hmmm', <------------------- here -------------- 'sortkey': 0, 'running_date': None, 'assignee': 'mfranc', 'build': 'unspecified', 'case_id': 35269, 'is_current': False, 'case_run_status': 'IDLE', 'assignee_id': 2739, 'case_run_id': 1205413, 'tested_by': 'psplicha', 'case_text_version': 1, 'case_run_status_id': 1, 'close_date': '2012-07-25 17:27:14'}] >>> TestCaseRun.update(1205413, {"notes": None }) [{'case': 'Blah blah blah blah', 'build_id': 1156, 'tested_by_id': 2117, 'environment_id': 0, 'run': 'Test run', 'links': [], 'run_id': 41118, 'notes': 'hmmm', <------------------- here -------------- 'sortkey': 0, 'running_date': None, 'assignee': 'mfranc', 'build': 'unspecified', 'case_id': 35269, 'is_current': False, 'case_run_status': 'IDLE', 'assignee_id': 2739, 'case_run_id': 1205413, 'tested_by': 'psplicha', 'case_text_version': 1, 'case_run_status_id': 1, 'close_date': '2012-07-25 17:27:14'}] Now TestCaseRun.update() and TestRun.update() suport notes None or ''. There still some field can't support None or '', we will continuous improvement that. Thanks, Thanks for the quick fix. Last thing: I've noticed that when
supplying en empty string the value is converted to None. I'm not
sure whether this would be expected / desired behaviour:
>>> TestCaseRun.update(1205413, {"notes": '' })
[{'case': 'Blah blah blah blah',
'build_id': 1156,
'tested_by_id': 2117,
'environment_id': 0,
'run': 'Test run',
'links': [],
'run_id': 41118,
'notes': None, <--------------- here ---------
'sortkey': 0,
'running_date': None,
'assignee': 'mfranc',
'build': 'unspecified',
'case_id': 35269,
'is_current': False,
'case_run_status': 'IDLE',
'assignee_id': 2739,
'case_run_id': 1205413,
'tested_by': 'psplicha',
'case_text_version': 1,
'case_run_status_id': 1,
'close_date': '2012-07-25 17:27:14'}]
(In reply to comment #15) > Thanks for the quick fix. Last thing: I've noticed that when > supplying en empty string the value is converted to None. I'm not > sure whether this would be expected / desired behaviour: > > >>> TestCaseRun.update(1205413, {"notes": '' }) > [{'case': 'Blah blah blah blah', > 'build_id': 1156, > 'tested_by_id': 2117, > 'environment_id': 0, > 'run': 'Test run', > 'links': [], > 'run_id': 41118, > 'notes': None, <--------------- here --------- > 'sortkey': 0, > 'running_date': None, > 'assignee': 'mfranc', > 'build': 'unspecified', > 'case_id': 35269, > 'is_current': False, > 'case_run_status': 'IDLE', > 'assignee_id': 2739, > 'case_run_id': 1205413, > 'tested_by': 'psplicha', > 'case_text_version': 1, > 'case_run_status_id': 1, > 'close_date': '2012-07-25 17:27:14'}] Hi Petr, i'm just treat empty string equal to Python build-in None type. It is reasonable that keep user's initial input. what's your opinion? (In reply to comment #16) > (In reply to comment #15) > > Thanks for the quick fix. Last thing: I've noticed that when > > supplying en empty string the value is converted to None. I'm not > > sure whether this would be expected / desired behaviour: > > > > >>> TestCaseRun.update(1205413, {"notes": '' }) > > [{'case': 'Blah blah blah blah', > > 'build_id': 1156, > > 'tested_by_id': 2117, > > 'environment_id': 0, > > 'run': 'Test run', > > 'links': [], > > 'run_id': 41118, > > 'notes': None, <--------------- here --------- > > 'sortkey': 0, > > 'running_date': None, > > 'assignee': 'mfranc', > > 'build': 'unspecified', > > 'case_id': 35269, > > 'is_current': False, > > 'case_run_status': 'IDLE', > > 'assignee_id': 2739, > > 'case_run_id': 1205413, > > 'tested_by': 'psplicha', > > 'case_text_version': 1, > > 'case_run_status_id': 1, > > 'close_date': '2012-07-25 17:27:14'}] > Hi Petr, i'm just treat empty string equal to Python build-in None type. > It is reasonable that keep user's initial input. > what's your opinion? i'm means will keep user's input, retain empty string. Yes, I think '' and 'None' should be treated as different values and should be retained in their original form, not converted. Verify 3.8.0-3 on stage --->PASS
Verify steps:
In [11]: tcms.TestCaseRun.update([12345], {'notes': ''})
Actual result:
Out[11]:
[{'assignee': 'xkuang',
'assignee_id': 2206,
'build': '4.2.0.GA_CP06-CR1',
'build_id': 93,
'case': 'compat12',
'case_id': 4617,
'case_run_id': 12345,
'case_run_status': 'PASSED',
'case_run_status_id': 2,
'case_text_version': 1,
'close_date': '2009-02-12 09:07:31',
'environment_id': 118,
'is_current': True,
'links': [],
'notes': '', <----------- it was retained in original form -----------
'run': 'TCK1.4 EAP4.2 CP06',
'run_id': 758,
'running_date': None,
'sortkey': None,
'tested_by': 'istudens',
'tested_by_id': 2160}]
Great, thanks for the quick fix! |
Description of problem: Currently it's not possible to update a field value to "None", for example: TestCaseRun.update(1234, {"notes": None } gives the following traceback: Traceback (most recent call last): File "<string>", line 1, in <module> File "/usr/lib64/python2.6/xmlrpclib.py", line 1199, in __call__ return self.__send(self.__name, args) File "/usr/lib64/python2.6/xmlrpclib.py", line 1483, in __request allow_none=self.__allow_none) File "/usr/lib64/python2.6/xmlrpclib.py", line 1132, in dumps data = m.dumps(params) File "/usr/lib64/python2.6/xmlrpclib.py", line 677, in dumps dump(v, write) File "/usr/lib64/python2.6/xmlrpclib.py", line 699, in __dump f(self, value, write) File "/usr/lib64/python2.6/xmlrpclib.py", line 780, in dump_struct dump(v, write) File "/usr/lib64/python2.6/xmlrpclib.py", line 699, in __dump f(self, value, write) File "/usr/lib64/python2.6/xmlrpclib.py", line 703, in dump_nil raise TypeError, "cannot marshal None unless allow_none is enabled" TypeError: cannot marshal None unless allow_none is enabled This can be easily fixed by providing xmlrpclib.ServerProxy with a "allow_none = 1" parameter. Version-Release number of selected component (if applicable): Nitrate 3.4.1 Additional info: Simple patch attached.