How to use config_instance method in molecule

Best Python code snippet using molecule_python

test_eventgenconfig.py

Source:test_eventgenconfig.py Github

copy

Full Screen

1import json2import os3from configparser import ConfigParser4import pytest5from splunk_eventgen.lib.eventgensamples import Sample6def test_makeSplunkEmbedded(eventgen_config):7 """Test makeSplunkEmbedded works"""8 config_instance = eventgen_config()9 session_key = "ea_IO86v01Xipz8BuB_Ako9rMoc5_HNn6UQrBhVQY5zj68LN2J2xVrLzYD^XEgVTWyKrXva6r8yZ2gtEuv9nnZ"10 config_instance.makeSplunkEmbedded(session_key)11 assert config_instance.splunkEmbedded12 # reset splunkEmbedded since all instances share the attribute13 config_instance.splunkEmbedded = False14def test_buildConfDict(eventgen_config):15 """Test buildConfDict returns the same as reading directly from file"""16 config_instance = eventgen_config()17 config_instance._buildConfDict()18 configparser = ConfigParser()19 splunk_eventgen_folder = os.path.join(20 os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))),21 "splunk_eventgen",22 )23 configparser.read(os.path.join(splunk_eventgen_folder, "default", "eventgen.conf"))24 configparser.set("global", "eai:acl", {"app": "splunk_eventgen"})25 for key, value in config_instance._confDict["global"].items():26 assert value == configparser.get("global", key)27def test_validate_setting_count(eventgen_config):28 """Test count config is int with right value"""29 config_instance = eventgen_config(configfile="eventgen.conf.config")30 assert type(config_instance._validateSetting("sample", "count", "0")) == int31 assert config_instance._validateSetting("sample", "count", "0") == 032def test_validate_setting_delay(eventgen_config):33 """Test delay config is int with right value"""34 config_instance = eventgen_config(configfile="eventgen.conf.config")35 assert type(config_instance._validateSetting("sample", "delay", "10")) == int36 assert config_instance._validateSetting("sample", "delay", "10") == 1037def test_validate_setting_interval(eventgen_config):38 """Test interval config is int with right value"""39 config_instance = eventgen_config(configfile="eventgen.conf.config")40 assert type(config_instance._validateSetting("sample", "interval", "3")) == int41 assert config_instance._validateSetting("sample", "interval", "3") == 342def test_validate_setting_perdayvolume(eventgen_config):43 """Test perdayvolume config is float with right value"""44 config_instance = eventgen_config(configfile="eventgen.conf.config")45 assert (46 type(config_instance._validateSetting("sample", "perDayVolume", "1")) == float47 )48 assert config_instance._validateSetting("sample", "perDayVolume", "1") == 1.049def test_validate_setting_randomizeCount(eventgen_config):50 """Test randomizeCount config is float with right value"""51 config_instance = eventgen_config(configfile="eventgen.conf.config")52 assert (53 type(config_instance._validateSetting("sample", "randomizeCount", "0.2"))54 == float55 )56 assert config_instance._validateSetting("sample", "randomizeCount", "0.2") == 0.257def test_validate_setting_timeMultiple(eventgen_config):58 """Test timeMultiple config is float with right value"""59 config_instance = eventgen_config(configfile="eventgen.conf.config")60 assert (61 type(config_instance._validateSetting("sample", "timeMultiple", "2")) == float62 )63 assert config_instance._validateSetting("sample", "timeMultiple", "2") == 2.064def test_validate_setting_disabled(eventgen_config):65 """Test disabled config is bool with right value"""66 config_instance = eventgen_config(configfile="eventgen.conf.config")67 assert type(config_instance._validateSetting("sample", "disabled", "false")) == bool68 assert config_instance._validateSetting("sample", "disabled", "false") is False69def test_validate_setting_profiler(eventgen_config):70 """Test profiler config is bool with right value"""71 config_instance = eventgen_config(configfile="eventgen.conf.config")72 assert type(config_instance._validateSetting("sample", "profiler", "false")) == bool73 assert config_instance._validateSetting("sample", "profiler", "false") is False74def test_validate_setting_useOutputQueue(eventgen_config):75 """Test useOutputQueue config is bool with right value"""76 config_instance = eventgen_config(configfile="eventgen.conf.config")77 assert (78 type(config_instance._validateSetting("sample", "useOutputQueue", "false"))79 == bool80 )81 assert (82 config_instance._validateSetting("sample", "useOutputQueue", "false") is False83 )84def test_validate_setting_bundlelines(eventgen_config):85 """Test bundlelines config is bool with right value"""86 config_instance = eventgen_config(configfile="eventgen.conf.config")87 assert (88 type(config_instance._validateSetting("sample", "bundlelines", "false")) == bool89 )90 assert config_instance._validateSetting("sample", "bundlelines", "false") is False91def test_validate_setting_httpeventWaitResponse(eventgen_config):92 """Test httpeventWaitResponse config is bool with right value"""93 config_instance = eventgen_config(configfile="eventgen.conf.config")94 assert (95 type(96 config_instance._validateSetting("sample", "httpeventWaitResponse", "false")97 )98 == bool99 )100 assert (101 config_instance._validateSetting("sample", "httpeventWaitResponse", "false")102 is False103 )104def test_validate_setting_sequentialTimestamp(eventgen_config):105 """Test sequentialTimestamp config is bool with right value"""106 config_instance = eventgen_config(configfile="eventgen.conf.config")107 assert (108 type(config_instance._validateSetting("sample", "sequentialTimestamp", "false"))109 == bool110 )111 assert (112 config_instance._validateSetting("sample", "sequentialTimestamp", "false")113 is False114 )115def test_validate_setting_autotimestamp(eventgen_config):116 """Test autotimestamp config is bool with right value"""117 config_instance = eventgen_config(configfile="eventgen.conf.config")118 assert (119 type(config_instance._validateSetting("sample", "autotimestamp", "false"))120 == bool121 )122 assert config_instance._validateSetting("sample", "autotimestamp", "false") is False123def test_validate_setting_randomizeEvents(eventgen_config):124 """Test randomizeEvents config is bool with right value"""125 config_instance = eventgen_config(configfile="eventgen.conf.config")126 assert (127 type(config_instance._validateSetting("sample", "randomizeEvents", "false"))128 == bool129 )130 assert (131 config_instance._validateSetting("sample", "randomizeEvents", "false") is False132 )133def test_validate_setting_outputCounter(eventgen_config):134 """Test outputCounter config is bool with right value"""135 config_instance = eventgen_config(configfile="eventgen.conf.config")136 assert (137 type(config_instance._validateSetting("sample", "outputCounter", "false"))138 == bool139 )140 assert config_instance._validateSetting("sample", "outputCounter", "false") is False141def test_validate_setting_minuteOfHourRate(eventgen_config):142 """Test minuteOfHourRate config is dict with right value"""143 config_instance = eventgen_config(configfile="eventgen.conf.config")144 minuteOfHourRate = (145 '{ "0": 1, "1": 1, "2": 1, "3": 1, "4": 1, "5": 1, "6": 1, "7": 1, "8": 1, "9": 1,'146 ' "10": 1, "11": 1, "12": 1, "13": 1, "14": 1, "15": 1, "16": 1, "17": 1, "18": 1,'147 ' "19": 1, "20": 1, "21": 1, "22": 1, "23": 1, "24": 1, "25": 1, "26": 1, "27": 1,'148 ' "28": 1, "29": 1, "30": 1, "31": 1, "32": 1, "33": 1, "34": 1, "35": 4, "36": 0.1,'149 ' "37": 0.1, "38": 1, "39": 1, "40": 1, "41": 1, "42": 1, "43": 1, "44": 1, "45": 1,'150 ' "46": 1, "47": 1, "48": 1, "49": 1, "50": 1, "51": 1, "52": 1, "53": 1, "54": 1,'151 ' "55": 1, "56": 1, "57": 1, "58": 1, "59": 1 }'152 )153 assert (154 type(155 config_instance._validateSetting(156 "sample", "minuteOfHourRate", minuteOfHourRate157 )158 )159 == dict160 )161 result = json.loads(minuteOfHourRate)162 assert (163 config_instance._validateSetting("sample", "minuteOfHourRate", minuteOfHourRate)164 == result165 )166def test_validate_setting_hourOfDayRate(eventgen_config):167 """Test hourOfDayRate config is dict with right value"""168 config_instance = eventgen_config(configfile="eventgen.conf.config")169 hourOfDayRate = (170 '{ "0": 0.30, "1": 0.20, "2": 0.20, "3": 0.20, "4": 0.20, "5": 0.25, "6": 0.35, "7": 0.50,'171 ' "8": 0.60, "9": 0.65, "10": 0.70, "11": 0.75, "12": 0.77, "13": 0.80, "14": 0.82,'172 ' "15": 0.85, "16": 0.87, "17": 0.90, "18": 0.95, "19": 1.0, "20": 0.85, "21": 0.70,'173 ' "22": 0.60, "23": 0.45 }'174 )175 assert (176 type(config_instance._validateSetting("sample", "hourOfDayRate", hourOfDayRate))177 == dict178 )179 result = json.loads(hourOfDayRate)180 assert (181 config_instance._validateSetting("sample", "hourOfDayRate", hourOfDayRate)182 == result183 )184def test_validate_setting_dayOfWeekRate(eventgen_config):185 """Test dayOfWeekRate config is dict with right value"""186 config_instance = eventgen_config(configfile="eventgen.conf.config")187 dayOfWeekRate = (188 '{ "0": 0.97, "1": 0.95, "2": 0.90, "3": 0.97, "4": 1.0, "5": 0.99, "6": 0.55 }'189 )190 assert (191 type(config_instance._validateSetting("sample", "dayOfWeekRate", dayOfWeekRate))192 == dict193 )194 result = json.loads(dayOfWeekRate)195 assert (196 config_instance._validateSetting("sample", "dayOfWeekRate", dayOfWeekRate)197 == result198 )199def test_validate_setting_dayOfMonthRate(eventgen_config):200 """Test dayOfMonthRate config is dict with right value"""201 config_instance = eventgen_config(configfile="eventgen.conf.config")202 dayOfMonthRate = (203 '{ "1": 1, "2": 1, "3": 1, "4": 1, "5": 1, "6": 1, "7": 1, "8": 1, "9": 1, "10": 1,'204 ' "11": 1, "12": 1, "13": 1, "14": 1, "15": 1, "16": 1, "17": 1, "18": 1, "19": 1, "20": 1,'205 ' "21": 1, "22": 1, "23": 1, "24": 1, "25": 1, "26": 1, "27": 1, "28": 1, "29": 1, "30": 1,'206 ' "31": 1 }'207 )208 assert (209 type(210 config_instance._validateSetting("sample", "dayOfMonthRate", dayOfMonthRate)211 )212 == dict213 )214 result = json.loads(dayOfMonthRate)215 assert (216 config_instance._validateSetting("sample", "dayOfMonthRate", dayOfMonthRate)217 == result218 )219def test_validate_setting_monthOfYearRate(eventgen_config):220 """Test monthOfYearRate config is dict with right value"""221 config_instance = eventgen_config(configfile="eventgen.conf.config")222 monthOfYearRate = (223 '{ "1": 1, "2": 1, "3": 1, "4": 1, "5": 1, "6": 1, "7": 1,'224 ' "8": 1, "9": 1, "10": 1, "11": 1, "12": 1 }'225 )226 assert (227 type(228 config_instance._validateSetting(229 "sample", "monthOfYearRate", monthOfYearRate230 )231 )232 == dict233 )234 result = json.loads(monthOfYearRate)235 assert (236 config_instance._validateSetting("sample", "monthOfYearRate", monthOfYearRate)237 == result238 )239def test_validate_setting_httpeventServers(eventgen_config):240 """Test httpeventServers config is dict with right value"""241 config_instance = eventgen_config(configfile="eventgen.conf.config")242 httpeventServers = (243 '{"servers":[{ "protocol":"https", "address":"127.0.0.1",'244 ' "port":"8088", "key":"8d5ab52c-3759-49e3-b66a-5213ce525692"}]}'245 )246 assert (247 type(248 config_instance._validateSetting(249 "sample", "httpeventServers", httpeventServers250 )251 )252 == dict253 )254 result = json.loads(httpeventServers)255 assert (256 config_instance._validateSetting("sample", "httpeventServers", httpeventServers)257 == result258 )259def test_validate_setting_autotimestamps(eventgen_config):260 """Test autotimestamps config is dict with right value"""261 config_instance = eventgen_config(configfile="eventgen.conf.config")262 autotimestamps = (263 r'[["\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}", "%Y-%m-%d %H:%M:%S"], '264 r'["\\d{1,2}\\/\\w{3}\\/\\d{4}\\s\\d{2}:\\d{2}:\\d{2}:\\d{1,3}", "%d/%b/%Y %H:%M:%S:%f"], '265 r'["\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}", "%Y-%m-%dT%H:%M:%S.%f"], '266 r'["\\d{1,2}/\\w{3}/\\d{4}\\s\\d{2}:\\d{2}:\\d{2}:\\d{1,3}", "%d/%b/%Y %H:%M:%S:%f"], '267 r'["\\d{1,2}/\\d{2}/\\d{2}\\s\\d{1,2}:\\d{2}:\\d{2}", "%m/%d/%y %H:%M:%S"], '268 r'["\\d{2}-\\d{2}-\\d{4} \\d{2}:\\d{2}:\\d{2}", "%m-%d-%Y %H:%M:%S"], '269 r'["\\w{3} \\w{3} +\\d{1,2} \\d{2}:\\d{2}:\\d{2}", "%a %b %d %H:%M:%S"], '270 r'["\\w{3} \\w{3} \\d{2} \\d{4} \\d{2}:\\d{2}:\\d{2}", "%a %b %d %Y %H:%M:%S"], '271 r'["^(\\w{3}\\s+\\d{1,2}\\s\\d{2}:\\d{2}:\\d{2})", "%b %d %H:%M:%S"], '272 r'["(\\w{3}\\s+\\d{1,2}\\s\\d{1,2}:\\d{1,2}:\\d{1,2})", "%b %d %H:%M:%S"], '273 r'["(\\w{3}\\s\\d{1,2}\\s\\d{1,4}\\s\\d{1,2}:\\d{1,2}:\\d{1,2})", "%b %d %Y %H:%M:%S"], '274 r'["\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\.\\d{3}", "%Y-%m-%d %H:%M:%S.%f"], '275 r'["\\,\\d{2}\\/\\d{2}\\/\\d{2,4}\\s+\\d{2}:\\d{2}:\\d{2}\\s+[AaPp][Mm]\\,", '276 r'",%m/%d/%Y %I:%M:%S %p,"], '277 r'["^\\w{3}\\s+\\d{2}\\s+\\d{2}:\\d{2}:\\d{2}", "%b %d %H:%M:%S"], '278 r'["\\d{2}/\\d{2}/\\d{4} \\d{2}:\\d{2}:\\d{2}", "%m/%d/%Y %H:%M:%S"], '279 r'["^\\d{2}\\/\\d{2}\\/\\d{2,4}\\s+\\d{2}:\\d{2}:\\d{2}\\s+[AaPp][Mm]", "%m/%d/%Y %I:%M:%S %p"],'280 r'["\\d{2}\\/\\d{2}\\/\\d{4}\\s\\d{2}:\\d{2}:\\d{2}", "%m-%d-%Y %H:%M:%S"], '281 r'["\\\"timestamp\\\":\\s\\\"(\\d+)", "%s"], '282 r'["\\d{2}\\/\\w+\\/\\d{4}\\s\\d{2}:\\d{2}:\\d{2}:\\d{3}", "%d-%b-%Y %H:%M:%S:%f"], '283 r'["\\\"created\\\":\\s(\\d+)", "%s"], ["\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}", '284 r'"%Y-%m-%dT%H:%M:%S"], '285 r'["\\d{1,2}/\\w{3}/\\d{4}:\\d{2}:\\d{2}:\\d{2}:\\d{1,3}", "%d/%b/%Y:%H:%M:%S:%f"], '286 r'["\\d{1,2}/\\w{3}/\\d{4}:\\d{2}:\\d{2}:\\d{2}", "%d/%b/%Y:%H:%M:%S"]]'287 )288 assert (289 type(290 config_instance._validateSetting("sample", "autotimestamps", autotimestamps)291 )292 == list293 )294 result = json.loads(autotimestamps)295 assert (296 config_instance._validateSetting("sample", "autotimestamps", autotimestamps)297 == result298 )299def test_getPlugin(eventgen_config):300 """Test getPlugin method without loading any plugins"""301 config_instance = eventgen_config(configfile="eventgen.conf.config")302 with pytest.raises(KeyError):303 config_instance.getPlugin("output.awss3")304def test_getSplunkUrl(eventgen_config):305 """Test getSplunkUrl with provided sample object"""306 config_instance = eventgen_config(configfile="eventgen.conf.config")307 sample = Sample("test")308 sample.splunkHost = "localhost"309 sample.splunkMethod = "https"310 sample.splunkPort = "8088"311 assert (312 "https://localhost:8088",313 "https",314 "localhost",315 "8088",316 ) == config_instance.getSplunkUrl(sample)317def test_validateTimeZone(eventgen_config):318 """Test _validateTimeZone method"""319 pass320def test_validateSeed(eventgen_config):321 """Test _validateSeed method"""322 pass323def test_punct(eventgen_config):324 """Test _punct method with given string"""325 config_instance = eventgen_config(configfile="eventgen.conf.config")326 assert "--:\n$^" == config_instance._punct("this-is-a: test \ntest $^")327def test_parse(eventgen_config):328 """Test parse method with given evengen config"""329 config_instance = eventgen_config(configfile="eventgen.conf.config")330 config_instance.parse()...

Full Screen

Full Screen

test_config.py

Source:test_config.py Github

copy

Full Screen

1# Copyright (c) 2020 John Dewey2#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 os21def test_kindly_file_property(config_instance):22 x = os.path.abspath('test/resources/kindly.yml')23 assert x == config_instance.kindly_file24def test_debug_property(config_instance):25 assert not config_instance.debug26def test_debug_setter(config_instance):27 config_instance.debug = True28 assert config_instance.debug29def test_env_property(config_instance):30 env = os.environ.copy()31 assert env == config_instance.env32def test_stream_property(config_instance):33 assert not config_instance.stream34def test_stream_property_true_when_debug_enabled(config_instance):35 config_instance.debug = True36 assert config_instance.stream37def test_spinner_property(config_instance):38 assert config_instance.spinner39def test_spinner_property_false_when_debug_enabled(config_instance):40 config_instance.debug = True...

Full Screen

Full Screen

binarisation_test.py

Source:binarisation_test.py Github

copy

Full Screen

1# coding: utf-82# Copyright (c) 2001-2022, Hove and/or its affiliates. All rights reserved.3#4# This file is part of Navitia,5# the software to build cool stuff with public transport.6#7# powered by Hove (www.hove.com).8# Help us simplify mobility and open public transport:9# a non ending quest to the responsive locomotion way of traveling!10#11# LICENCE: This program is free software; you can redistribute it and/or modify12# it under the terms of the GNU Affero General Public License as published by13# the Free Software Foundation, either version 3 of the License, or14# (at your option) any later version.15#16# This program is distributed in the hope that it will be useful,17# but WITHOUT ANY WARRANTY; without even the implied warranty of18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19# GNU Affero General Public License for more details.20#21# You should have received a copy of the GNU Affero General Public License22# along with this program. If not, see <http://www.gnu.org/licenses/>.23#24# Stay tuned using25# twitter @navitia26# channel `#navitia` on riot https://riot.im/app/#/room/#navitia:matrix.org27# https://groups.google.com/d/forum/navitia28# www.navitia.io29from __future__ import absolute_import, print_function, division30from tyr.binarisation import make_connection_string31from tyr.helper import InstanceConfig32def test_make_connection_string():33 config_instance = InstanceConfig()34 config_instance.pg_host = 'localhost'35 config_instance.pg_username = 'user'36 config_instance.pg_dbname = 'test'37 config_instance.pg_password = 'pwd'38 config_instance.pg_port = 123439 connection_string = make_connection_string(config_instance)...

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