Best Python code snippet using lemoncheesecake
test_delay.py
Source:test_delay.py
...11 'body': 'Hello from Lambda!'12 }13class TestDelayMethods(TestBase):14 @pytest.fixture(autouse=True)15 def inject_fixtures(self, caplog):16 self._caplog = caplog17 @ignore_warnings18 def _setTestUp(self, subfolder):19 class_name = self.__class__.__name__20 self._setUp(class_name, subfolder)21 config = "{ \"delay\": 400, \"is_enabled\": true, \"error_code\": 404, \"exception_msg\": \"This is chaos\", \"rate\": 1, \"fault_type\": \"latency\"}"22 self._create_params(name='test.config', value=config)23 @ignore_warnings24 def test_get_delay(self):25 method_name = sys._getframe().f_code.co_name26 self._setTestUp(method_name)27 with self._caplog.at_level(logging.DEBUG, logger="chaos_lambda"):28 response = handler('foo', 'bar')29 assert (30 'Injecting 400 ms of delay with a rate of 1' in self._caplog.text31 )32 assert (33 'sleeping now' in self._caplog.text34 )35 self.assertEqual(36 str(response), "{'statusCode': 200, 'body': 'Hello from Lambda!'}")37class TestDelayMethodsnotEnabled(TestBase):38 @pytest.fixture(autouse=True)39 def inject_fixtures(self, caplog):40 self._caplog = caplog41 @ignore_warnings42 def _setTestUp(self, subfolder):43 class_name = self.__class__.__name__44 self._setUp(class_name, subfolder)45 config = "{ \"delay\": 400, \"is_enabled\": false, \"error_code\": 404, \"exception_msg\": \"This is chaos\", \"rate\": 1, \"fault_type\": \"latency\"}"46 self._create_params(name='test.config', value=config)47 @ignore_warnings48 def test_delay_not_enabled(self):49 method_name = sys._getframe().f_code.co_name50 self._setTestUp(method_name)51 with self._caplog.at_level(logging.DEBUG, logger="chaos_lambda"):52 response = handler('foo', 'bar')53 assert (54 len(self._caplog.text) == 055 )56 assert (57 'sleeping now' not in self._caplog.text58 )59 self.assertEqual(60 str(response), "{'statusCode': 200, 'body': 'Hello from Lambda!'}")61class TestDelayMethodslowrate(TestBase):62 @pytest.fixture(autouse=True)63 def inject_fixtures(self, caplog):64 self._caplog = caplog65 @ignore_warnings66 def _setTestUp(self, subfolder):67 class_name = self.__class__.__name__68 self._setUp(class_name, subfolder)69 config = "{ \"delay\": 400, \"is_enabled\": true, \"error_code\": 404, \"exception_msg\": \"This is chaos\", \"rate\": 0.000001, \"fault_type\": \"latency\"}"70 self._create_params(name='test.config', value=config)71 @ignore_warnings72 def test_delay_low_rate(self):73 method_name = sys._getframe().f_code.co_name74 self._setTestUp(method_name)75 with self._caplog.at_level(logging.DEBUG, logger="chaos_lambda"):76 response = handler('foo', 'bar')77 assert (78 'sleeping now' not in self._caplog.text79 )80 self.assertEqual(81 str(response), "{'statusCode': 200, 'body': 'Hello from Lambda!'}")82class TestDelayEnabledNoDelay(TestBase):83 @pytest.fixture(autouse=True)84 def inject_fixtures(self, caplog):85 self._caplog = caplog86 @ignore_warnings87 def _setTestUp(self, subfolder):88 class_name = self.__class__.__name__89 self._setUp(class_name, subfolder)90 config = "{ \"delay\": 0, \"is_enabled\": true, \"error_code\": 404, \"exception_msg\": \"This is chaos\", \"rate\": 0.000001, \"fault_type\": \"latency\"}"91 self._create_params(name='test.config', value=config)92 @ignore_warnings93 def test_delay_zero(self):94 method_name = sys._getframe().f_code.co_name95 self._setTestUp(method_name)96 with self._caplog.at_level(logging.DEBUG, logger="chaos_lambda"):97 response = handler('foo', 'bar')98 assert (99 'sleeping now' not in self._caplog.text100 )101 self.assertEqual(102 str(response), "{'statusCode': 200, 'body': 'Hello from Lambda!'}")103class TestDelayEnabledDelayNotInt(TestBase):104 @pytest.fixture(autouse=True)105 def inject_fixtures(self, caplog):106 self._caplog = caplog107 @ignore_warnings108 def _setTestUp(self, subfolder):109 class_name = self.__class__.__name__110 self._setUp(class_name, subfolder)111 config = "{ \"delay\": \"boo\", \"is_enabled\": true, \"error_code\": 404, \"exception_msg\": \"This is chaos\", \"rate\": 0.000001, \"fault_type\": \"latency\"}"112 self._create_params(name='test.config', value=config)113 @ignore_warnings114 def test_delay_not_int(self):115 method_name = sys._getframe().f_code.co_name116 self._setTestUp(method_name)117 with self._caplog.at_level(logging.DEBUG, logger="chaos_lambda"):118 response = handler('foo', 'bar')119 assert (...
test_rps.py
Source:test_rps.py
...6import utils.config7from tests.utils import inject_fixtures8log = logging.getLogger(__name__)9task = "rps"10inject_fixtures(11 globals(),12 task,13 {14 "prd": utils.config.get_configs(task, ""),15 "stg": utils.config.get_configs(task, "staging"),16 "dbg": utils.config.get_configs(task, "debug"),17 },18)19@pytest.mark.envtest20def test_read_api(req: requests, api_src: Dict[str, Any]):21 """Test calling APIs in source configs."""22 r = req.get(api_src["url"], allow_redirects=True)23 assert len(r.text) > 024@pytest.mark.envtest...
conftest.py
Source:conftest.py
1# -*- coding: utf-8 -*-...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!