On 11/10/2014 06:20 PM, Aaron Karper wrote: > On Thu, Nov 06, 2014 at 12:30:49AM +0200, Alex Pyrgiotis wrote: >> Also, test if the ConvertNicDiskModifications function operates as >> expected. >> >> Signed-off-by: Alex Pyrgiotis <[email protected] <mailto:[email protected]>> >> >> diff --git a/test/py/ganeti.client.gnt___instance_unittest.py > <http://ganeti.client.gnt_instance_unittest.py> > b/test/py/ganeti.client.gnt___instance_unittest.py > <http://ganeti.client.gnt_instance_unittest.py> >> index 3349c1a..3159284 100755 >> --- a/test/py/ganeti.client.gnt___instance_unittest.py > <http://ganeti.client.gnt_instance_unittest.py> >> +++ b/test/py/ganeti.client.gnt___instance_unittest.py > <http://ganeti.client.gnt_instance_unittest.py> >> @@ -135,18 +135,26 @@ class > TestConvertNicDiskModification__s(unittest.TestCase): >> self.assertEqual(fn([]), []) >> >> # Error cases >> - self.assertRaises(errors.__OpPrereqError, fn, [ >> - (constants.DDM_REMOVE, { "param": "value", }), >> - ]) >> - self.assertRaises(errors.__OpPrereqError, fn, [ >> - (0, { constants.DDM_REMOVE: True, "param": "value", }), >> - ]) >> + for op in [constants.DDM_REMOVE, constants.DDM_DETACH]: >> + self.assertRaises(errors.__OpPrereqError, fn, [ >> + (op, { "param": "value", }), >> + ]) >> + self.assertRaises(errors.__OpPrereqError, fn, [ >> + (0, { op: True, "param": "value", }), >> + ]) >> + >> self.assertRaises(errors.__OpPrereqError, fn, [ >> (0, { >> constants.DDM_REMOVE: True, >> constants.DDM_ADD: True, >> }), >> ]) >> + self.assertRaises(errors.__OpPrereqError, fn, [ >> + (0, { >> + constants.DDM_DETACH: True, >> + constants.DDM_MODIFY: True, >> + }), >> + ]) >> >> # Legacy calls >> for action in constants.DDMS_VALUES: >> diff --git a/test/py/ganeti.opcodes___unittest.py > <http://ganeti.opcodes_unittest.py> > b/test/py/ganeti.opcodes___unittest.py <http://ganeti.opcodes_unittest.py> >> index 010ea0c..7abb9b3 100755 >> --- a/test/py/ganeti.opcodes___unittest.py > <http://ganeti.opcodes_unittest.py> >> +++ b/test/py/ganeti.opcodes___unittest.py > <http://ganeti.opcodes_unittest.py> >> @@ -377,7 +377,9 @@ class TestOpInstanceSetParams(__unittest.TestCase): >> def _GenericTests(self, fn): >> self.assertTrue(fn([])) >> self.assertTrue(fn([(__constants.DDM_ADD, {})])) >> + self.assertTrue(fn([(__constants.DDM_ATTACH, {})])) >> self.assertTrue(fn([(__constants.DDM_REMOVE, {})])) >> + self.assertTrue(fn([(__constants.DDM_DETACH, {})])) >> for i in [0, 1, 2, 3, 9, 10, 1024]: >> self.assertTrue(fn([(i, {})])) >> >> @@ -404,6 +406,7 @@ class TestOpInstanceSetParams(__unittest.TestCase): >> for param in constants.IDISK_PARAMS: >> self.assertTrue(fn([[__constants.DDM_ADD, {param: 0}]])) >> self.assertTrue(fn([[__constants.DDM_ADD, {param: param}]])) >> + self.assertTrue(fn([[__constants.DDM_ATTACH, {param: param}]])) >> >> >> if __name__ == "__main__": >> -- >> 1.7.10.4 >> > > My dislike for multiple tests in a test method aside, LGTM >
Well, it is quite long for a test case. I'll try to split it nevertheless. > > -- > Google Germany GmbH > Dienerstr. 12 > 80331 München > > Registergericht und -nummer: Hamburg, HRB 86891 > Sitz der Gesellschaft: Hamburg > Geschäftsführer: Graham Law, Christine Elizabeth Flores -- Alex | [email protected]
