How to use patched_logger_warning method in molecule

Best Python code snippet using molecule_python

test_prepare.py

Source:test_prepare.py Github

copy

Full Screen

1# Copyright (c) 2015-2018 Cisco Systems, Inc.2#3# Permission is hereby granted, free of charge, to any person obtaining a copy4# of this software and associated documentation files (the "Software"), to5# deal in the Software without restriction, including without limitation the6# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or7# sell copies of the Software, and to permit persons to whom the Software is8# furnished to do so, subject to the following conditions:9#10# The above copyright notice and this permission notice shall be included in11# all copies or substantial portions of the Software.12#13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE16# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER17# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING18# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER19# DEALINGS IN THE SOFTWARE.20import os21import pytest22from molecule import util23from molecule.command import prepare24@pytest.fixture25def _patched_ansible_prepare(mocker):26 return mocker.patch("molecule.provisioner.ansible.Ansible.prepare")27# NOTE(retr0h): The use of the `patched_config_validate` fixture, disables28# config.Config._validate from executing. Thus preventing odd side-effects29# throughout patched.assert_called unit tests.30def test_execute(31 mocker,32 patched_logger_info,33 _patched_ansible_prepare,34 patched_config_validate,35 config_instance,36):37 pb = os.path.join(config_instance.scenario.directory, "prepare.yml")38 util.write_file(pb, "")39 p = prepare.Prepare(config_instance)40 p.execute()41 x = [mocker.call("Scenario: 'default'"), mocker.call("Action: 'prepare'")]42 assert x == patched_logger_info.mock_calls43 _patched_ansible_prepare.assert_called_once_with()44 assert config_instance.state.prepared45def test_execute_skips_when_instances_already_prepared(46 patched_logger_warning, _patched_ansible_prepare, config_instance47):48 config_instance.state.change_state("prepared", True)49 p = prepare.Prepare(config_instance)50 p.execute()51 msg = "Skipping, instances already prepared."52 patched_logger_warning.assert_called_once_with(msg)53 assert not _patched_ansible_prepare.called54def test_execute_skips_when_playbook_not_configured(55 patched_logger_warning, _patched_ansible_prepare, config_instance56):57 p = prepare.Prepare(config_instance)58 p.execute()59 msg = "Skipping, prepare playbook not configured."60 patched_logger_warning.assert_called_once_with(msg)61 assert not _patched_ansible_prepare.called62def test_execute_when_instances_already_prepared_but_force_provided(63 mocker, patched_logger_warning, _patched_ansible_prepare, config_instance64):65 pb = os.path.join(config_instance.scenario.directory, "prepare.yml")66 util.write_file(pb, "")67 config_instance.state.change_state("prepared", True)68 config_instance.command_args = {"force": True}69 p = prepare.Prepare(config_instance)70 p.execute()...

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