On Tue, Aug 20, 2013 at 1:08 PM, Thomas Thrainer <[email protected]> wrote: > This patch adds basic unit tests for instance import in > LUInstanceCreate. It does not provide full coverage though. > > Signed-off-by: Thomas Thrainer <[email protected]> > --- > test/py/cmdlib/instance_unittest.py | 121 > ++++++++++++++++++++++++++++++++++++ > 1 file changed, 121 insertions(+) > > diff --git a/test/py/cmdlib/instance_unittest.py > b/test/py/cmdlib/instance_unittest.py > index 4b7e54a..0556978 100644 > --- a/test/py/cmdlib/instance_unittest.py > +++ b/test/py/cmdlib/instance_unittest.py > @@ -626,6 +626,127 @@ class TestLUInstanceCreate(CmdlibTestCase): > wait_for_sync=False) > self.ExecOpCode(op) > > + def testImportPlainFromGivenSrcNode(self): > + exp_info = """ > +[export] > +version=0 > +os=mock_os > +[instance] > +name=old_name.example.com > +""" > + > + self.rpc.call_export_info.return_value = \ > + self.RpcResultsBuilder() \ > + .CreateSuccessfulNodeResult(self.master, exp_info) > + op = self.CopyOpCode(self.plain_op, > + mode=constants.INSTANCE_IMPORT, > + src_node=self.master.name) > + self.ExecOpCode(op) > + > + def testImportPlainWithoutSrcNodeNotFound(self): > + op = self.CopyOpCode(self.plain_op, > + mode=constants.INSTANCE_IMPORT) > + self.ExecOpCodeExpectOpPrereqError( > + op, "No export found for relative path") > + > + def testImportPlainWithoutSrcNode(self): > + exp_info = """ > +[export] > +version=0 > +os=mock_os > +[instance] > +name=old_name.example.com > +"""
Would it be better to keep the export info files under data/ and open them with utils.ReadFile()? Thanks, Guido
