How to use patched_scenario_setup method in molecule

Best Python code snippet using molecule_python

test_scenario.py

Source:test_scenario.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 shutil22import tempfile23import pytest24from molecule import config25from molecule import scenario26# NOTE(retr0h): The use of the `patched_config_validate` fixture, disables27# config.Config._validate from executing. Thus preventing odd side-effects28# throughout patched.assert_called unit tests.29@pytest.fixture30def _instance(patched_config_validate, config_instance):31 return scenario.Scenario(config_instance)32def test_config_member(_instance):33 assert isinstance(_instance.config, config.Config)34def test_init_calls_setup(patched_scenario_setup, _instance):35 patched_scenario_setup.assert_called_once_with()36def test_name_property(_instance):37 assert 'default' == _instance.name38def test_directory_property(molecule_scenario_directory_fixture, _instance):39 assert molecule_scenario_directory_fixture == _instance.directory40def test_ephemeral_directory_property(_instance):41 project_directory = os.path.basename(_instance.config.project_directory)42 scenario_name = _instance.name43 project_scenario_directory = os.path.join('molecule', project_directory,44 scenario_name)45 x = os.path.join(tempfile.gettempdir(), project_scenario_directory)46 assert x == _instance.ephemeral_directory47def test_check_sequence_property(_instance):48 x = [49 'destroy',50 'dependency',51 'create',52 'prepare',53 'converge',54 'check',55 'destroy',56 ]57 assert x == _instance.check_sequence58def test_converge_sequence_property(_instance):59 x = [60 'dependency',61 'create',62 'prepare',63 'converge',64 ]65 assert x == _instance.converge_sequence66def test_create_sequence_property(_instance):67 x = [68 'create',69 'prepare',70 ]71 assert x == _instance.create_sequence72def test_dependency_sequence_property(_instance):73 assert ['dependency'] == _instance.dependency_sequence74def test_destroy_sequence_property(_instance):75 assert ['destroy'] == _instance.destroy_sequence76def test_idempotence_sequence_property(_instance):77 assert ['idempotence'] == _instance.idempotence_sequence78def test_lint_sequence_property(_instance):79 assert ['lint'] == _instance.lint_sequence80def test_prepare_sequence_property(_instance):81 assert ['prepare'] == _instance.prepare_sequence82def test_side_effect_sequence_property(_instance):83 assert ['side_effect'] == _instance.side_effect_sequence84def test_syntax_sequence_property(_instance):85 assert ['syntax'] == _instance.syntax_sequence86def test_test_sequence_property(_instance):87 x = [88 'lint',89 'destroy',90 'dependency',91 'syntax',92 'create',93 'prepare',94 'converge',95 'idempotence',96 'side_effect',97 'verify',98 'destroy',99 ]100 assert x == _instance.test_sequence101def test_verify_sequence_property(_instance):102 assert ['verify'] == _instance.verify_sequence103def test_sequence_property(_instance):104 assert 'lint' == _instance.sequence[0]105def test_sequence_property_with_invalid_subcommand(_instance):106 _instance.config.command_args = {'subcommand': 'invalid'}107 assert [] == _instance.sequence108def test_setup_creates_ephemeral_directory(_instance):109 ephemeral_dir = _instance.config.scenario.ephemeral_directory110 shutil.rmtree(ephemeral_dir)111 _instance._setup()112 assert os.path.isdir(ephemeral_dir)113def test_ephemeral_directory():114 x = os.path.join(tempfile.gettempdir(), 'foo/bar')115 assert x == scenario.ephemeral_directory('foo/bar')116def test_ephemeral_directory_overriden_via_env_var(monkeypatch):117 monkeypatch.setenv('MOLECULE_EPHEMERAL_DIRECTORY', 'foo/bar')118 x = os.path.join(tempfile.gettempdir(), 'foo/bar')119 assert x == scenario.ephemeral_directory('foo/bar')120def test_ephemeral_directory_overriden_via_env_var_uses_absolute_path(121 monkeypatch):122 monkeypatch.setenv('MOLECULE_EPHEMERAL_DIRECTORY', '/foo/bar')...

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