def test_gemset_present(): with patch.object(rvm, "_check_rvm") as mock_method: mock_method.return_value = {"result": True, "changes": {}} gems = ["global", "foo", "bar"] gemset_list = MagicMock(return_value=gems) gemset_create = MagicMock(return_value=True) check_ruby = MagicMock(return_value={"result": False, "changes": {}}) with patch.object(rvm, "_check_ruby", new=check_ruby): with patch.dict( rvm.__salt__, {"rvm.gemset_list": gemset_list, "rvm.gemset_create": gemset_create}, ): ret = rvm.gemset_present("foo") assert True is ret["result"] ret = rvm.gemset_present("quux") assert True is ret["result"] gemset_create.assert_called_once_with("default", "quux", runas=None)
def test_gemset_present(self): with patch.object(rvm, '_check_rvm') as mock_method: mock_method.return_value = {'result': True, 'changes': {}} gems = ['global', 'foo', 'bar'] gemset_list = MagicMock(return_value=gems) gemset_create = MagicMock(return_value=True) check_ruby = MagicMock( return_value={'result': False, 'changes': {}}) with patch.object(rvm, '_check_ruby', new=check_ruby): with patch.dict(rvm.__salt__, {'rvm.gemset_list': gemset_list, 'rvm.gemset_create': gemset_create}): ret = rvm.gemset_present('foo') self.assertEqual(True, ret['result']) ret = rvm.gemset_present('quux') self.assertEqual(True, ret['result']) gemset_create.assert_called_once_with( 'default', 'quux', runas=None)