API unittests coverage is unsufficient
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Blazar |
Fix Released
|
Medium
|
Tetsuro Nakamura |
Bug Description
Hi,
I just discovered when trying to add unittests for Host API that the coverage is not sufficient for all the controllers.
For example, this section :
def test_make_
only checks that the remote method is called, but doesn't check the values, which can lead to a successful test while the method could raise an Exception.
Let me give a quick example on why only checking assert_called is not enough.
Provided this code snippet :
import A
def foo()
myA = A()
mydict = myA.to_dict()
return mydict['id']
and provided this unittest method :
def test_foo(self):
fake_Adict = self.patch(
self.
it will work.
If we change foo() to return mydict['name'] instead of mydict['id'], the test will still say OK while it will break at runtime...
The coverage would be better saying :
fake_Adict.
self.assertEqua
Changed in climate: | |
importance: | Undecided → Medium |
Changed in climate: | |
status: | New → Confirmed |
assignee: | nobody → Nikolay Starodubtsev (starodubcevna) |
milestone: | none → icehouse-2 |
Changed in climate: | |
assignee: | Nikolay Starodubtsev (starodubcevna) → Dmitriy Dyachkov (ddyachkov) |
Changed in blazar: | |
status: | Confirmed → Fix Released |
assignee: | Dmitriy Dyachkov (ddyachkov) → Tetsuro Nakamura (tetsuro0907) |
Of course, that's a good idea only in case like 'something interesting is going on in this method, but we check only its calling'. We do not need to test every simple and doing nothing thing.