How to use test_base_config method in molecule

Best Python code snippet using molecule_python

test_base_config.py

Source:test_base_config.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2#3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14'''15Tests for the base_config module.16'''17from prestoadmin.yarn_slider.config import SliderConfig18from prestoadmin.standalone.config import StandaloneConfig19from prestoadmin.util.base_config import requires_config20from prestoadmin.util.exception import ConfigFileNotFoundError, \21 ConfigurationError22from mock import patch23from tests.base_test_case import BaseTestCase24class TestBaseConfig(BaseTestCase):25 @patch('tests.unit.util.test_base_config.SliderConfig.'26 'get_conf_interactive')27 @patch('tests.unit.util.test_base_config.SliderConfig.read_conf')28 @patch('tests.unit.util.test_base_config.SliderConfig.set_env_from_conf')29 def test_get_config_already_loaded(30 self, set_env_mock, file_conf_mock, interactive_conf_mock):31 config = SliderConfig()32 config.set_config_loaded()33 config.get_config()34 self.assertFalse(file_conf_mock.called)35 self.assertFalse(interactive_conf_mock.called)36 self.assertFalse(set_env_mock.called)37 @patch('tests.unit.util.test_base_config.StandaloneConfig.'38 'get_conf_interactive')39 @patch('tests.unit.util.test_base_config.StandaloneConfig.read_conf')40 @patch('tests.unit.util.test_base_config.StandaloneConfig.'41 'set_env_from_conf')42 def test_get_config_load_file(43 self, set_env_mock, file_conf_mock, interactive_conf_mock):44 config = StandaloneConfig()45 config.get_config()46 self.assertTrue(file_conf_mock.called)47 self.assertFalse(interactive_conf_mock.called)48 self.assertTrue(set_env_mock.called)49 self.assertTrue(config.is_config_loaded())50 @patch('tests.unit.util.test_base_config.StandaloneConfig.'51 'get_conf_interactive')52 @patch('tests.unit.util.test_base_config.StandaloneConfig.read_conf')53 @patch('tests.unit.util.test_base_config.StandaloneConfig.write_conf')54 @patch('tests.unit.util.test_base_config.StandaloneConfig.'55 'set_env_from_conf')56 def test_get_config_load_interactive(57 self, set_env_mock, store_conf_mock, file_conf_mock,58 interactive_conf_mock):59 file_conf_mock.side_effect = ConfigFileNotFoundError(60 message='oops', config_path='/asdf')61 config = StandaloneConfig()62 config.get_config()63 self.assertTrue(file_conf_mock.called)64 self.assertTrue(interactive_conf_mock.called)65 self.assertTrue(set_env_mock.called)66 self.assertTrue(store_conf_mock.called)67 self.assertTrue(config.is_config_loaded())68 @patch('tests.unit.util.test_base_config.SliderConfig.is_config_loaded')69 def test_decorator_has_topology(self, mock_is_config_loaded):70 mock_is_config_loaded.return_value = True71 @requires_config(SliderConfig)72 def func():73 return 'runs'74 self.assertEquals(func(), 'runs')75 @patch('tests.unit.util.test_base_config.StandaloneConfig.'76 'is_config_loaded')77 def test_decorator_no_topology(self, mock_is_config_loaded):78 mock_is_config_loaded.return_value = False79 @requires_config(StandaloneConfig)80 def func():81 return 'runs'...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run molecule automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful