How to use mock_open method in autotest

Best Python code snippet using autotest_python

config_test.py

Source:config_test.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2import copy3import datetime4import mock5import os6import pytest7import elastalert.alerts8import elastalert.ruletypes9from elastalert.config import get_file_paths10from elastalert.config import load_configuration11from elastalert.config import load_modules12from elastalert.config import load_options13from elastalert.config import load_rules14from elastalert.util import EAException15from elastalert.config import import_rules16test_config = {'rules_folder': 'test_folder',17 'run_every': {'minutes': 10},18 'buffer_time': {'minutes': 10},19 'es_host': 'elasticsearch.test',20 'es_port': 12345,21 'writeback_index': 'test_index'}22test_rule = {'es_host': 'test_host',23 'es_port': 12345,24 'name': 'testrule',25 'type': 'spike',26 'spike_height': 2,27 'spike_type': 'up',28 'timeframe': {'minutes': 10},29 'index': 'test_index',30 'query_key': 'testkey',31 'compare_key': 'comparekey',32 'filter': [{'term': {'key': 'value'}}],33 'alert': 'email',34 'use_count_query': True,35 'doc_type': 'blsh',36 'email': 'test@test.test',37 'aggregation': {'hours': 2},38 'include': ['comparekey', '@timestamp']}39test_args = mock.Mock()40test_args.config = 'test_config'41test_args.rule = None42test_args.debug = False43test_args.es_debug_trace = None44def test_import_rules():45 test_rule_copy = copy.deepcopy(test_rule)46 test_rule_copy['type'] = 'testing.test.RuleType'47 with mock.patch('elastalert.config.yaml_loader') as mock_open:48 mock_open.return_value = test_rule_copy49 # Test that type is imported50 with mock.patch('__builtin__.__import__') as mock_import:51 mock_import.return_value = elastalert.ruletypes52 load_configuration('test_config', test_config)53 assert mock_import.call_args_list[0][0][0] == 'testing.test'54 assert mock_import.call_args_list[0][0][3] == ['RuleType']55 # Test that alerts are imported56 test_rule_copy = copy.deepcopy(test_rule)57 mock_open.return_value = test_rule_copy58 test_rule_copy['alert'] = 'testing2.test2.Alerter'59 with mock.patch('__builtin__.__import__') as mock_import:60 mock_import.return_value = elastalert.alerts61 load_configuration('test_config', test_config)62 assert mock_import.call_args_list[0][0][0] == 'testing2.test2'63 assert mock_import.call_args_list[0][0][3] == ['Alerter']64def test_import_import():65 import_rule = copy.deepcopy(test_rule)66 del(import_rule['es_host'])67 del(import_rule['es_port'])68 import_rule['import'] = 'importme.ymlt'69 import_me = {70 'es_host': 'imported_host',71 'es_port': 12349,72 'email': 'ignored@email', # overwritten by the email in import_rule73 }74 with mock.patch('elastalert.config.yaml_loader') as mock_open:75 mock_open.side_effect = [import_rule, import_me]76 rules = load_configuration('blah.yaml', test_config)77 assert mock_open.call_args_list[0][0] == ('blah.yaml',)78 assert mock_open.call_args_list[1][0] == ('importme.ymlt',)79 assert len(mock_open.call_args_list) == 280 assert rules['es_port'] == 1234981 assert rules['es_host'] == 'imported_host'82 assert rules['email'] == ['test@test.test']83 assert rules['filter'] == import_rule['filter']84 # check global import_rule dependency85 assert import_rules == {'blah.yaml': ['importme.ymlt']}86def test_import_absolute_import():87 import_rule = copy.deepcopy(test_rule)88 del(import_rule['es_host'])89 del(import_rule['es_port'])90 import_rule['import'] = '/importme.ymlt'91 import_me = {92 'es_host': 'imported_host',93 'es_port': 12349,94 'email': 'ignored@email', # overwritten by the email in import_rule95 }96 with mock.patch('elastalert.config.yaml_loader') as mock_open:97 mock_open.side_effect = [import_rule, import_me]98 rules = load_configuration('blah.yaml', test_config)99 assert mock_open.call_args_list[0][0] == ('blah.yaml',)100 assert mock_open.call_args_list[1][0] == ('/importme.ymlt',)101 assert len(mock_open.call_args_list) == 2102 assert rules['es_port'] == 12349103 assert rules['es_host'] == 'imported_host'104 assert rules['email'] == ['test@test.test']105 assert rules['filter'] == import_rule['filter']106def test_import_filter():107 # Check that if a filter is specified the rules are merged:108 import_rule = copy.deepcopy(test_rule)109 del(import_rule['es_host'])110 del(import_rule['es_port'])111 import_rule['import'] = 'importme.ymlt'112 import_me = {113 'es_host': 'imported_host',114 'es_port': 12349,115 'filter': [{'term': {'ratchet': 'clank'}}],116 }117 with mock.patch('elastalert.config.yaml_loader') as mock_open:118 mock_open.side_effect = [import_rule, import_me]119 rules = load_configuration('blah.yaml', test_config)120 assert rules['filter'] == [{'term': {'ratchet': 'clank'}}, {'term': {'key': 'value'}}]121def test_load_inline_alert_rule():122 test_rule_copy = copy.deepcopy(test_rule)123 test_rule_copy['alert'] = [124 {125 'email': {126 'email': 'foo@bar.baz'127 }128 },129 {130 'email': {131 'email': 'baz@foo.bar'132 }133 }134 ]135 test_config_copy = copy.deepcopy(test_config)136 with mock.patch('elastalert.config.yaml_loader') as mock_open:137 mock_open.side_effect = [test_config_copy, test_rule_copy]138 load_modules(test_rule_copy)139 assert isinstance(test_rule_copy['alert'][0], elastalert.alerts.EmailAlerter)140 assert isinstance(test_rule_copy['alert'][1], elastalert.alerts.EmailAlerter)141 assert 'foo@bar.baz' in test_rule_copy['alert'][0].rule['email']142 assert 'baz@foo.bar' in test_rule_copy['alert'][1].rule['email']143def test_load_rules():144 test_rule_copy = copy.deepcopy(test_rule)145 test_config_copy = copy.deepcopy(test_config)146 with mock.patch('elastalert.config.yaml_loader') as mock_open:147 mock_open.side_effect = [test_config_copy, test_rule_copy]148 with mock.patch('os.listdir') as mock_ls:149 mock_ls.return_value = ['testrule.yaml']150 rules = load_rules(test_args)151 assert isinstance(rules['rules'][0]['type'], elastalert.ruletypes.RuleType)152 assert isinstance(rules['rules'][0]['alert'][0], elastalert.alerts.Alerter)153 assert isinstance(rules['rules'][0]['timeframe'], datetime.timedelta)154 assert isinstance(rules['run_every'], datetime.timedelta)155 for included_key in ['comparekey', 'testkey', '@timestamp']:156 assert included_key in rules['rules'][0]['include']157 # Assert include doesn't contain duplicates158 assert rules['rules'][0]['include'].count('@timestamp') == 1159 assert rules['rules'][0]['include'].count('comparekey') == 1160def test_load_default_host_port():161 test_rule_copy = copy.deepcopy(test_rule)162 test_rule_copy.pop('es_host')163 test_rule_copy.pop('es_port')164 test_config_copy = copy.deepcopy(test_config)165 with mock.patch('elastalert.config.yaml_loader') as mock_open:166 mock_open.side_effect = [test_config_copy, test_rule_copy]167 with mock.patch('os.listdir') as mock_ls:168 mock_ls.return_value = ['testrule.yaml']169 rules = load_rules(test_args)170 # Assert include doesn't contain duplicates171 assert rules['es_port'] == 12345172 assert rules['es_host'] == 'elasticsearch.test'173def test_load_ssl_env_false():174 test_rule_copy = copy.deepcopy(test_rule)175 test_rule_copy.pop('es_host')176 test_rule_copy.pop('es_port')177 test_config_copy = copy.deepcopy(test_config)178 with mock.patch('elastalert.config.yaml_loader') as mock_open:179 mock_open.side_effect = [test_config_copy, test_rule_copy]180 with mock.patch('os.listdir') as mock_ls:181 with mock.patch.dict(os.environ, {'ES_USE_SSL': 'false'}):182 mock_ls.return_value = ['testrule.yaml']183 rules = load_rules(test_args)184 assert rules['use_ssl'] is False185def test_load_ssl_env_true():186 test_rule_copy = copy.deepcopy(test_rule)187 test_rule_copy.pop('es_host')188 test_rule_copy.pop('es_port')189 test_config_copy = copy.deepcopy(test_config)190 with mock.patch('elastalert.config.yaml_loader') as mock_open:191 mock_open.side_effect = [test_config_copy, test_rule_copy]192 with mock.patch('os.listdir') as mock_ls:193 with mock.patch.dict(os.environ, {'ES_USE_SSL': 'true'}):194 mock_ls.return_value = ['testrule.yaml']195 rules = load_rules(test_args)196 assert rules['use_ssl'] is True197def test_load_url_prefix_env():198 test_rule_copy = copy.deepcopy(test_rule)199 test_rule_copy.pop('es_host')200 test_rule_copy.pop('es_port')201 test_config_copy = copy.deepcopy(test_config)202 with mock.patch('elastalert.config.yaml_loader') as mock_open:203 mock_open.side_effect = [test_config_copy, test_rule_copy]204 with mock.patch('os.listdir') as mock_ls:205 with mock.patch.dict(os.environ, {'ES_URL_PREFIX': 'es/'}):206 mock_ls.return_value = ['testrule.yaml']207 rules = load_rules(test_args)208 assert rules['es_url_prefix'] == 'es/'209def test_load_disabled_rules():210 test_rule_copy = copy.deepcopy(test_rule)211 test_rule_copy['is_enabled'] = False212 test_config_copy = copy.deepcopy(test_config)213 with mock.patch('elastalert.config.yaml_loader') as mock_open:214 mock_open.side_effect = [test_config_copy, test_rule_copy]215 with mock.patch('os.listdir') as mock_ls:216 mock_ls.return_value = ['testrule.yaml']217 rules = load_rules(test_args)218 # The rule is not loaded for it has "is_enabled=False"219 assert len(rules['rules']) == 0220def test_compound_query_key():221 test_rule_copy = copy.deepcopy(test_rule)222 test_rule_copy.pop('use_count_query')223 test_rule_copy['query_key'] = ['field1', 'field2']224 load_options(test_rule_copy, test_config, 'filename.yaml')225 assert 'field1' in test_rule_copy['include']226 assert 'field2' in test_rule_copy['include']227 assert test_rule_copy['query_key'] == 'field1,field2'228 assert test_rule_copy['compound_query_key'] == ['field1', 'field2']229def test_name_inference():230 test_rule_copy = copy.deepcopy(test_rule)231 test_rule_copy.pop('name')232 load_options(test_rule_copy, test_config, 'msmerc woz ere.yaml')233 assert test_rule_copy['name'] == 'msmerc woz ere'234def test_raises_on_missing_config():235 optional_keys = ('aggregation', 'use_count_query', 'query_key', 'compare_key', 'filter', 'include', 'es_host', 'es_port', 'name')236 test_rule_copy = copy.deepcopy(test_rule)237 for key in test_rule_copy.keys():238 test_rule_copy = copy.deepcopy(test_rule)239 test_config_copy = copy.deepcopy(test_config)240 test_rule_copy.pop(key)241 # Non required keys242 if key in optional_keys:243 continue244 with mock.patch('elastalert.config.yaml_loader') as mock_open:245 mock_open.side_effect = [test_config_copy, test_rule_copy]246 with mock.patch('os.listdir') as mock_ls:247 mock_ls.return_value = ['testrule.yaml']248 with pytest.raises(EAException, message='key %s should be required' % key):249 rule = load_rules(test_args)250 print(rule)251def test_raises_on_bad_generate_kibana_filters():252 test_rule['generate_kibana_link'] = True253 bad_filters = [[{'not': {'terms': {'blah': 'blah'}}}],254 [{'terms': {'blah': 'blah'}}],255 [{'query': {'not_querystring': 'this:that'}}],256 [{'query': {'wildcard': 'this*that'}}],257 [{'blah': 'blah'}]]258 good_filters = [[{'term': {'field': 'value'}}],259 [{'not': {'term': {'this': 'that'}}}],260 [{'not': {'query': {'query_string': {'query': 'this:that'}}}}],261 [{'query': {'query_string': {'query': 'this:that'}}}],262 [{'range': {'blah': {'from': 'a', 'to': 'b'}}}],263 [{'not': {'range': {'blah': {'from': 'a', 'to': 'b'}}}}]]264 # Test that all the good filters work, but fail with a bad filter added265 for good in good_filters:266 test_rule_copy = copy.deepcopy(test_rule)267 test_rule_copy['filter'] = good268 with mock.patch('elastalert.config.yaml_loader') as mock_open:269 mock_open.return_value = test_rule_copy270 load_configuration('blah', test_config)271 for bad in bad_filters:272 test_rule_copy['filter'] = good + bad273 with pytest.raises(EAException):274 load_configuration('blah', test_config)275def test_get_file_paths_recursive():276 conf = {'scan_subdirectories': True, 'rules_folder': 'root'}277 walk_paths = (('root', ('folder_a', 'folder_b'), ('rule.yaml',)),278 ('root/folder_a', (), ('a.yaml', 'ab.yaml')),279 ('root/folder_b', (), ('b.yaml',)))280 with mock.patch('os.walk') as mock_walk:281 mock_walk.return_value = walk_paths282 paths = get_file_paths(conf)283 paths = [p.replace(os.path.sep, '/') for p in paths]284 assert 'root/rule.yaml' in paths285 assert 'root/folder_a/a.yaml' in paths286 assert 'root/folder_a/ab.yaml' in paths287 assert 'root/folder_b/b.yaml' in paths288 assert len(paths) == 4289def test_get_file_paths():290 # Check for no subdirectory291 conf = {'scan_subdirectories': False, 'rules_folder': 'root'}292 files = ['badfile', 'a.yaml', 'b.yaml']293 with mock.patch('os.listdir') as mock_list:294 with mock.patch('os.path.isfile') as mock_path:295 mock_path.return_value = True296 mock_list.return_value = files297 paths = get_file_paths(conf)298 paths = [p.replace(os.path.sep, '/') for p in paths]299 assert 'root/a.yaml' in paths300 assert 'root/b.yaml' in paths...

Full Screen

Full Screen

checkteamtags_test.py

Source:checkteamtags_test.py Github

copy

Full Screen

1# Copyright 2017 The Chromium Authors. All rights reserved.2# Use of this source code is governed by a BSD-style license that can be3# found in the LICENSE file.4import json5import os6import sys7import unittest8import checkteamtags9SRC = os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir)10sys.path.append(os.path.join(SRC, 'third_party', 'pymock'))11import mock12def mock_file(lines):13 inner_mock = mock.MagicMock()14 inner_attrs = {'readlines.return_value': lines,15 '__iter__.return_value': lines}16 inner_mock.configure_mock(**inner_attrs)17 return_val = mock.MagicMock()18 attrs = {'__enter__.return_value': inner_mock}19 return_val.configure_mock(**attrs)20 return return_val21DEFAULT_MAPPING = {22 'dir-to-component': {},23 'component-to-team': {},24}25def mock_url_open(data=None):26 """Simulate the result of fetching the cloud location of the mapping.27 i.e. https://storage.googleapis.com/chromium-owners/component_map.json28 """29 if data is None:30 data = DEFAULT_MAPPING31 class _MockJsonResponse(object):32 def __init__(self, data):33 self.data = data34 def read(self):35 return json.dumps(self.data)36 def inner(url):37 if url.endswith('.json'):38 return _MockJsonResponse(data)39 return inner40NO_TAGS = """41mock@chromium.org42""".splitlines()43MULTIPLE_COMPONENT_TAGS = """44mock@chromium.org45# COMPONENT: Blink>mock_component46# COMPONENT: V8>mock_component47""".splitlines()48MULTIPLE_COMPONENTS_IN_TAG = """49mock@chromium.org50# COMPONENT: Blink>mock_component, V8>mock_component51""".splitlines()52MISSING_COMPONENT = """53mock@chromium.org54# COMPONENT:55""".splitlines()56MULTIPLE_TEAM_TAGS = """57mock@chromium.org58# TEAM: some-team@chromium.org59# TEAM: some-other-team@chromium.org60""".splitlines()61MULTIPLE_TEAMS_IN_TAG = """62mock@chromium.org63# TEAM: some-team@chromium.org some-other-team@chromium.org64""".splitlines()65MISSING_TEAM = """66mock@chromium.org67# TEAM:68""".splitlines()69BASIC = """70mock@chromium.org71# TEAM: some-team@chromium.org72# COMPONENT: V8>mock_component73""".splitlines()74open_name = 'checkteamtags.open'75@mock.patch('sys.stdout', mock.MagicMock())76@mock.patch('os.path.exists', mock.MagicMock())77class CheckTeamTagsTest(unittest.TestCase):78 @mock.patch('urllib2.urlopen', mock_url_open())79 @mock.patch('sys.argv', ['checkteamtags', '--bare' ,'OWNERS'])80 def testNoTags(self):81 with mock.patch(open_name, create=True) as mock_open:82 mock_open.return_value = mock_file(NO_TAGS)83 self.assertEqual(0, checkteamtags.main())84 @mock.patch('urllib2.urlopen', mock_url_open())85 @mock.patch('sys.argv', ['checkteamtags', '--bare' ,'OWNERS'])86 def testMultipleComponentTags(self):87 with mock.patch(open_name, create=True) as mock_open:88 mock_open.return_value = mock_file(MULTIPLE_COMPONENT_TAGS)89 self.assertEqual(1, checkteamtags.main())90 @mock.patch('urllib2.urlopen', mock_url_open())91 @mock.patch('sys.argv', ['checkteamtags', '--bare' ,'OWNERS'])92 def testMultipleComponentsInTag(self):93 with mock.patch(open_name, create=True) as mock_open:94 mock_open.return_value = mock_file(MULTIPLE_COMPONENTS_IN_TAG)95 self.assertEqual(1, checkteamtags.main())96 @mock.patch('urllib2.urlopen', mock_url_open())97 @mock.patch('sys.argv', ['checkteamtags', '--bare' ,'OWNERS'])98 def testMissingComponent(self):99 with mock.patch(open_name, create=True) as mock_open:100 mock_open.return_value = mock_file(MISSING_COMPONENT)101 self.assertEqual(1, checkteamtags.main())102 @mock.patch('urllib2.urlopen', mock_url_open())103 @mock.patch('sys.argv', ['checkteamtags', '--bare' ,'OWNERS'])104 def testMultipleTeamTags(self):105 with mock.patch(open_name, create=True) as mock_open:106 mock_open.return_value = mock_file(MULTIPLE_TEAM_TAGS)107 self.assertEqual(1, checkteamtags.main())108 @mock.patch('urllib2.urlopen', mock_url_open())109 @mock.patch('sys.argv', ['checkteamtags', '--bare' ,'OWNERS'])110 def testMultipleTeamsInTag(self):111 with mock.patch(open_name, create=True) as mock_open:112 mock_open.return_value = mock_file(MULTIPLE_TEAMS_IN_TAG)113 self.assertEqual(1, checkteamtags.main())114 @mock.patch('urllib2.urlopen', mock_url_open())115 @mock.patch('sys.argv', ['checkteamtags', '--bare' ,'OWNERS'])116 def testMissingTeam(self):117 with mock.patch(open_name, create=True) as mock_open:118 mock_open.return_value = mock_file(MISSING_TEAM)119 self.assertEqual(1, checkteamtags.main())120 @mock.patch('urllib2.urlopen', mock_url_open())121 @mock.patch('sys.argv', ['checkteamtags', '--bare' ,'OWNERS'])122 def testBasic(self):123 with mock.patch(open_name, create=True) as mock_open:124 mock_open.return_value = mock_file(BASIC)125 self.assertEqual(0, checkteamtags.main())126 @mock.patch('urllib2.urlopen', mock_url_open({127 'dir-to-component': {128 'some/dir': 'V8>mock_component',129 },130 'component-to-team': {131 'V8>mock_component': 'some-other-team@chromium.org',132 },133 }))134 @mock.patch('sys.argv', ['checkteamtags', '--bare', 'fakepath/OWNERS'])135 def testMappingFail(self):136 with mock.patch(open_name, create=True) as mock_open:137 mock_open.return_value = mock_file(BASIC)138 with mock.patch('owners_file_tags.open', create=True) as mock_open_2:139 mock_open_2.return_value = mock_file(BASIC)140 self.assertEqual(1, checkteamtags.main())141 @mock.patch('urllib2.urlopen', mock_url_open({142 'dir-to-component': {143 'some/dir': 'V8>mock_component',144 },145 'component-to-team': {146 'V8>mock_component': 'some-other-team@chromium.org',147 },148 }))149 @mock.patch('sys.argv', ['checkteamtags', '--bare', 'some/dir/OWNERS'])150 def testMappingPassRename(self):151 with mock.patch(open_name, create=True) as mock_open:152 mock_open.return_value = mock_file(BASIC)153 with mock.patch('owners_file_tags.open', create=True) as mock_open_2:154 mock_open_2.return_value = mock_file(BASIC)155 self.assertEqual(0, checkteamtags.main())156 @mock.patch('urllib2.urlopen', mock_url_open({157 'dir-to-component': {158 'some/dir/': 'V8>mock_component',159 },160 'component-to-team': {161 'V8>mock_component': 'some-team@chromium.org',162 },163 }))164 @mock.patch('sys.argv', ['checkteamtags', '--bare', 'other/dir/OWNERS'])165 def testMappingPassNew(self):166 with mock.patch(open_name, create=True) as mock_open:167 mock_open.return_value = mock_file(BASIC)168 with mock.patch('owners_file_tags.open', create=True) as mock_open_2:169 mock_open_2.return_value = mock_file(BASIC)...

Full Screen

Full Screen

test_utils.py

Source:test_utils.py Github

copy

Full Screen

...5from .base import BaseTestCase6class UtilsTestCase(BaseTestCase):7 def setUp(self):8 super(UtilsTestCase, self).setUp()9 self.mock_open = mock_open()10 self.mock_mkdir = patch('statikos.utils.os.mkdir').start()11 self.mock_json_dump = patch.object(utils.json, 'dump').start()12 self.mock_yaml_dump = patch.object(utils.yaml, 'dump').start()13 self.path = Mock()14 self.mock_path = patch('statikos.utils.Path').start()15 self.mock_path.return_value = self.path16 def test_touch(self):17 utils.touch('filename')18 self.path.touch.assert_called_once()19 def test_mkdir_directory_does_not_exist(self):20 utils.mkdir('path/to/directory')21 self.mock_mkdir.assert_called_once_with('path/to/directory')22 def test_mkdir_directory_does_exist(self):23 self.mock_mkdir.side_effect = FileExistsError24 utils.mkdir('path/to/directory')25 def test_read_file(self):26 read_data = 'data'27 self.mock_open = mock_open(read_data=read_data)28 with patch('builtins.open', self.mock_open):29 result = utils.read_file('filename')30 self.mock_open.assert_called_once_with('filename', 'r')31 self.assertEqual('data', result)32 def test_append_file(self):33 data = 'data'34 with patch('builtins.open', self.mock_open):35 utils.append_file(data, 'filename')36 self.mock_open.assert_called_once_with('filename', 'a')37 self.mock_open.return_value.write.assert_called_once_with('data')38 def test_write_file(self):39 data = 'data'40 with patch('builtins.open', self.mock_open):41 utils.write_file(data, 'filename')42 self.mock_open.assert_called_once_with('filename', 'w')43 self.mock_open.return_value.write.assert_called_once_with('data')44 def test_read_json_file(self):45 read_data = '{"a": 1, "b": 2, "c": 3}'46 self.mock_open = mock_open(read_data=read_data)47 with patch('builtins.open', self.mock_open):48 result = utils.read_json_file('filename')49 self.mock_open.assert_called_once_with('filename', 'r')50 self.assertEqual({'a': 1, 'b': 2, 'c': 3}, result)51 def test_write_json_file(self):52 data = {'a': 1, 'b': 2, 'c': 3}53 with patch('builtins.open', self.mock_open) as mock_file:54 utils.write_json_file(data, 'filename')55 self.mock_open.assert_called_once_with('filename', 'w')56 self.mock_json_dump.assert_called_once_with(57 data, mock_file.return_value, indent=258 )59 def test_read_yaml_file(self):60 read_data = \61 """62 a: 163 b: 264 c: 365 """66 self.mock_open = mock_open(read_data=read_data)67 with patch('builtins.open', self.mock_open):68 result = utils.read_yaml_file('filename')69 self.mock_open.assert_called_once_with('filename', 'r')70 self.assertEqual({'a': 1, 'b': 2, 'c': 3}, result)71 def test_write_yaml_file(self):72 data = {'a': 1, 'b': 2, 'c': 3}73 with patch('builtins.open', self.mock_open) as mock_file:74 utils.write_yaml_file(data, 'filename')75 self.mock_open.assert_called_once_with('filename', 'w')76 self.mock_yaml_dump.assert_called_once_with(77 data, mock_file.return_value, default_flow_style=False...

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 autotest 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