def test_create(): """ Test if create the named vm """ mock = MagicMock(return_value="""{"foo": "bar"}""") mock_json_loads = MagicMock(side_effect=ValueError()) with patch.dict(saltcloudmod.__salt__, {"cmd.run_stdout": mock}): assert saltcloudmod.create("webserver", "rackspace_centos_512") with patch.object(salt.utils.json, "loads", mock_json_loads): assert saltcloudmod.create("webserver", "rackspace_centos_512") == {}
def test_create(self): """ Test if create the named vm """ mock = MagicMock(return_value="""{"foo": "bar"}""") with patch.dict(saltcloudmod.__salt__, {"cmd.run_stdout": mock}): self.assertTrue(saltcloudmod.create("webserver", "rackspace_centos_512")) with patch.object(salt.utils.json, "loads", self.mock_json_loads): self.assertDictEqual( saltcloudmod.create("webserver", "rackspace_centos_512"), {} )
def test_create(self): ''' Test if create the named vm ''' mock = MagicMock(return_value='''{"foo": "bar"}''') with patch.dict(saltcloudmod.__salt__, {'cmd.run_stdout': mock}): self.assertTrue( saltcloudmod.create("webserver", "rackspace_centos_512")) with patch.object(salt.utils.json, 'loads', self.mock_json_loads): self.assertDictEqual( saltcloudmod.create("webserver", "rackspace_centos_512"), {})
def test_create(self): ''' Test if create the named vm ''' MockJson.flag = True mock = MagicMock(return_value=True) with patch.dict(saltcloudmod.__salt__, {'cmd.run_stdout': mock}): self.assertTrue( saltcloudmod.create("webserver", "rackspace_centos_512")) MockJson.flag = False self.assertDictEqual( saltcloudmod.create("webserver", "rackspace_centos_512"), {})
def test_create(self): ''' Test if create the named vm ''' MockJson.flag = True mock = MagicMock(return_value=True) with patch.dict(saltcloudmod.__salt__, {'cmd.run_stdout': mock}): self.assertTrue(saltcloudmod.create("webserver", "rackspace_centos_512" ) ) MockJson.flag = False self.assertDictEqual(saltcloudmod.create("webserver", "rackspace_centos_512" ), {} )