How to use test_execute_command method in autotest

Best Python code snippet using autotest_python

test_execute_command.py

Source:test_execute_command.py Github

copy

Full Screen

1# Copyright 2010 New Relic, Inc.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.14import pytest15import redis16from newrelic.api.background_task import background_task17from testing_support.fixtures import (validate_transaction_metrics,18 override_application_settings)19from testing_support.db_settings import redis_settings20from testing_support.util import instance_hostname21DB_SETTINGS = redis_settings()[0]22REDIS_PY_VERSION = redis.VERSION23# Settings24_enable_instance_settings = {25 'datastore_tracer.instance_reporting.enabled': True,26}27_disable_instance_settings = {28 'datastore_tracer.instance_reporting.enabled': False,29}30# Metrics31_base_scoped_metrics = (32 ('Datastore/operation/Redis/client_list', 1),33)34_base_rollup_metrics = (35 ('Datastore/all', 1),36 ('Datastore/allOther', 1),37 ('Datastore/Redis/all', 1),38 ('Datastore/Redis/allOther', 1),39 ('Datastore/operation/Redis/client_list', 1),40)41_disable_scoped_metrics = list(_base_scoped_metrics)42_disable_rollup_metrics = list(_base_rollup_metrics)43_enable_scoped_metrics = list(_base_scoped_metrics)44_enable_rollup_metrics = list(_base_rollup_metrics)45_host = instance_hostname(DB_SETTINGS['host'])46_port = DB_SETTINGS['port']47_instance_metric_name = 'Datastore/instance/Redis/%s/%s' % (_host, _port)48_enable_rollup_metrics.append(49 (_instance_metric_name, 1)50)51_disable_rollup_metrics.append(52 (_instance_metric_name, None)53)54def exercise_redis_multi_args(client):55 client.execute_command('CLIENT', 'LIST', parse='LIST')56def exercise_redis_single_arg(client):57 client.execute_command('CLIENT LIST')58@override_application_settings(_enable_instance_settings)59@validate_transaction_metrics(60 'test_execute_command:test_strict_redis_execute_command_two_args_enable',61 scoped_metrics=_enable_scoped_metrics,62 rollup_metrics=_enable_rollup_metrics,63 background_task=True)64@background_task()65def test_strict_redis_execute_command_two_args_enable():66 r = redis.StrictRedis(host=DB_SETTINGS['host'],67 port=DB_SETTINGS['port'], db=0)68 exercise_redis_multi_args(r)69@override_application_settings(_disable_instance_settings)70@validate_transaction_metrics(71 'test_execute_command:test_strict_redis_execute_command_two_args_disabled',72 scoped_metrics=_disable_scoped_metrics,73 rollup_metrics=_disable_rollup_metrics,74 background_task=True)75@background_task()76def test_strict_redis_execute_command_two_args_disabled():77 r = redis.StrictRedis(host=DB_SETTINGS['host'],78 port=DB_SETTINGS['port'], db=0)79 exercise_redis_multi_args(r)80@override_application_settings(_enable_instance_settings)81@validate_transaction_metrics(82 'test_execute_command:test_redis_execute_command_two_args_enable',83 scoped_metrics=_enable_scoped_metrics,84 rollup_metrics=_enable_rollup_metrics,85 background_task=True)86@background_task()87def test_redis_execute_command_two_args_enable():88 r = redis.Redis(host=DB_SETTINGS['host'],89 port=DB_SETTINGS['port'], db=0)90 exercise_redis_multi_args(r)91@override_application_settings(_disable_instance_settings)92@validate_transaction_metrics(93 'test_execute_command:test_redis_execute_command_two_args_disabled',94 scoped_metrics=_disable_scoped_metrics,95 rollup_metrics=_disable_rollup_metrics,96 background_task=True)97@background_task()98def test_redis_execute_command_two_args_disabled():99 r = redis.Redis(host=DB_SETTINGS['host'],100 port=DB_SETTINGS['port'], db=0)101 exercise_redis_multi_args(r)102@pytest.mark.skipif(REDIS_PY_VERSION < (2, 10),103 reason='This command is not implemented yet')104@override_application_settings(_enable_instance_settings)105@validate_transaction_metrics(106 'test_execute_command:test_strict_redis_execute_command_as_one_arg_enable',107 scoped_metrics=_enable_scoped_metrics,108 rollup_metrics=_enable_rollup_metrics,109 background_task=True)110@background_task()111def test_strict_redis_execute_command_as_one_arg_enable():112 r = redis.StrictRedis(host=DB_SETTINGS['host'],113 port=DB_SETTINGS['port'], db=0)114 exercise_redis_single_arg(r)115@pytest.mark.skipif(REDIS_PY_VERSION < (2, 10),116 reason='This command is not implemented yet')117@override_application_settings(_disable_instance_settings)118@validate_transaction_metrics(119 'test_execute_command:test_strict_redis_execute_command_as_one_arg_disabled',120 scoped_metrics=_disable_scoped_metrics,121 rollup_metrics=_disable_rollup_metrics,122 background_task=True)123@background_task()124def test_strict_redis_execute_command_as_one_arg_disabled():125 r = redis.StrictRedis(host=DB_SETTINGS['host'],126 port=DB_SETTINGS['port'], db=0)127 exercise_redis_single_arg(r)128@pytest.mark.skipif(REDIS_PY_VERSION < (2, 10),129 reason='This command is not implemented yet')130@override_application_settings(_enable_instance_settings)131@validate_transaction_metrics(132 'test_execute_command:test_redis_execute_command_as_one_arg_enable',133 scoped_metrics=_enable_scoped_metrics,134 rollup_metrics=_enable_rollup_metrics,135 background_task=True)136@background_task()137def test_redis_execute_command_as_one_arg_enable():138 r = redis.Redis(host=DB_SETTINGS['host'],139 port=DB_SETTINGS['port'], db=0)140 exercise_redis_single_arg(r)141@pytest.mark.skipif(REDIS_PY_VERSION < (2, 10),142 reason='This command is not implemented yet')143@override_application_settings(_disable_instance_settings)144@validate_transaction_metrics(145 'test_execute_command:test_redis_execute_command_as_one_arg_disabled',146 scoped_metrics=_disable_scoped_metrics,147 rollup_metrics=_disable_rollup_metrics,148 background_task=True)149@background_task()150def test_redis_execute_command_as_one_arg_disabled():151 r = redis.Redis(host=DB_SETTINGS['host'],152 port=DB_SETTINGS['port'], db=0)...

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