def test_vagrant_init_arg_override(self): testdict = dict( cwd="/tmp/there", machine="treetest", runas="anybody", vagrant_provider="spansh", ) mock_sdb = MagicMock(return_value=None) with patch.dict(vagrant.__utils__, {"sdb.sdb_set": mock_sdb}): vagrant.init( "test3", cwd="/tmp", machine="threetest", runas="him", vagrant_provider="polish", vm=testdict, ) expected = dict( name="test3", cwd="/tmp", machine="threetest", runas="him", vagrant_provider="polish", ) mock_sdb.assert_any_call("sdb://vagrant_sdb_data/test3", expected, self.LOCAL_OPTS)
def test_vagrant_get_ssh_config_fails(self): mock_sdb = MagicMock(return_value=None) with patch.dict(vagrant.__utils__, {'sdb.sdb_set': mock_sdb}): mock_sdb = MagicMock(return_value={}) with patch.dict(vagrant.__utils__, {'sdb.sdb_get': mock_sdb}): vagrant.init('test3', cwd='/tmp') with self.assertRaises(salt.exceptions.SaltInvocationError): vagrant.get_ssh_config('test3') # has not been started
def test_vagrant_init_dict(self): testdict = dict(cwd='/tmp/anywhere', machine='twotest', runas='somebody', vagrant_provider='english') expected = testdict.copy() expected['name'] = 'test2' mock_sdb = MagicMock(return_value=None) with patch.dict(vagrant.__utils__, {'sdb.sdb_set': mock_sdb}): vagrant.init('test2', vm=testdict) mock_sdb.assert_any_call('sdb://vagrant_sdb_data/test2', expected, self.LOCAL_OPTS)
def test_vagrant_init_dict(self): testdict = dict( cwd="/tmp/anywhere", machine="twotest", runas="somebody", vagrant_provider="english", ) expected = testdict.copy() expected["name"] = "test2" mock_sdb = MagicMock(return_value=None) with patch.dict(vagrant.__utils__, {"sdb.sdb_set": mock_sdb}): vagrant.init("test2", vm=testdict) mock_sdb.assert_any_call("sdb://vagrant_sdb_data/test2", expected, self.LOCAL_OPTS)
def test_vagrant_init_positional(self): path_nowhere = os.path.join(os.sep, 'tmp', 'nowhere') if salt.utils.platform.is_windows(): path_nowhere = 'c:{0}'.format(path_nowhere) mock_sdb = MagicMock(return_value=None) with patch.dict(vagrant.__utils__, {'sdb.sdb_set': mock_sdb}): resp = vagrant.init( 'test1', path_nowhere, 'onetest', 'nobody', False, 'french', {'different': 'very'} ) self.assertTrue(resp.startswith('Name test1 defined')) expected = dict(name='test1', cwd=path_nowhere, machine='onetest', runas='nobody', vagrant_provider='french', different='very' ) mock_sdb.assert_called_with( 'sdb://vagrant_sdb_data/onetest?{0}'.format(path_nowhere), 'test1', self.LOCAL_OPTS) mock_sdb.assert_any_call( 'sdb://vagrant_sdb_data/test1', expected, self.LOCAL_OPTS)
def test_vagrant_init_positional(self): mock_sdb = MagicMock(return_value=None) with patch.dict(vagrant.__utils__, {'sdb.sdb_set': mock_sdb}): resp = vagrant.init( 'test1', '/tmp/nowhere', 'onetest', 'nobody', False, 'french', {'different': 'very'} ) self.assertTrue(resp.startswith('Name test1 defined')) expected = dict(name='test1', cwd='/tmp/nowhere', machine='onetest', runas='nobody', vagrant_provider='french', different='very' ) mock_sdb.assert_called_with( 'sdb://vagrant_sdb_data/onetest?/tmp/nowhere', 'test1', self.LOCAL_OPTS) mock_sdb.assert_any_call( 'sdb://vagrant_sdb_data/test1', expected, self.LOCAL_OPTS)
def test_vagrant_init_positional(self): path_nowhere = os.path.join(os.sep, "tmp", "nowhere") if salt.utils.platform.is_windows(): path_nowhere = "c:{}".format(path_nowhere) mock_sdb = MagicMock(return_value=None) with patch.dict(vagrant.__utils__, {"sdb.sdb_set": mock_sdb}): resp = vagrant.init( "test1", path_nowhere, "onetest", "nobody", False, "french", {"different": "very"}, ) self.assertTrue(resp.startswith("Name test1 defined")) expected = dict( name="test1", cwd=path_nowhere, machine="onetest", runas="nobody", vagrant_provider="french", different="very", ) mock_sdb.assert_called_with( "sdb://vagrant_sdb_data/onetest?{}".format(path_nowhere), "test1", self.LOCAL_OPTS, ) mock_sdb.assert_any_call("sdb://vagrant_sdb_data/test1", expected, self.LOCAL_OPTS)
def test_vagrant_init_arg_override(self): testdict = dict(cwd='/tmp/there', machine='treetest', runas='anybody', vagrant_provider='spansh') mock_sdb = MagicMock(return_value=None) with patch.dict(vagrant.__utils__, {'sdb.sdb_set': mock_sdb}): vagrant.init('test3', cwd='/tmp', machine='threetest', runas='him', vagrant_provider='polish', vm=testdict) expected = dict(name='test3', cwd='/tmp', machine='threetest', runas='him', vagrant_provider='polish') mock_sdb.assert_any_call('sdb://vagrant_sdb_data/test3', expected, self.LOCAL_OPTS)