Best Python code snippet using localstack_python
test_request.py
Source:test_request.py
...8 output = {9 'arms': 3,10 'move': 'left',11 }12 res = remove_none_values_from_dict(simple)13 assert res == output14def test_remove_none_from_deep_dict():15 deep = {16 'name': 'hardware',17 'sensors': {18 'gps': None,19 'temp': {20 'id': '12345678',21 'value': 100022 }23 }24 }25 output = {26 'name': 'hardware',27 'sensors': {28 'temp': {29 'id': '12345678',30 'value': 100031 }32 }33 }34 res = remove_none_values_from_dict(deep)35 assert res == output36def test_grouping_data_with_underscores():37 data_in = {38 'name': 'my new object',39 'created__gte': '2016011600',40 'created__lte': '2018011600',41 'page__limit': 100,42 'page__offset': 0,43 'order__order': 144 }45 data_out = {46 'name': 'my new object',47 'created': {48 'gte': '2016011600',...
test_util.py
Source:test_util.py
...18 'noneKey': None19 }20def test_data_is_a_dict(data_without_none_values):21 ''' Check returned data is a dict. '''22 data = util.remove_none_values_from_dict(data_without_none_values)23 assert isinstance(data, dict) == True24def test_dict_has_no_none_values(data_without_none_values):25 ''' Check dict has not None values. '''26 data = util.remove_none_values_from_dict(data_without_none_values)27 for _, value in data.items():28 assert value is not None29def test_dict_has_none_values(data_with_none_values):30 ''' Check dict has None values. '''31 for _, value in data_with_none_values.items():32 if not value:...
requests.py
Source:requests.py
1from typing import Dict2def remove_none_values_from_dict(params: Dict):3 result = dict()4 for k, v in list(params.items()):5 if v is not None:6 result[k] = v7 if type(v) is dict:8 res = remove_none_values_from_dict(params[k])9 if res:10 result[k] = res11 return result12def grouping(params: Dict, delimiter: str='__'):13 groups = dict()14 for k, v in params.items():15 keys = k.split(delimiter)16 current = groups17 last = keys[-1]18 for key in keys[:-1]:19 if key not in current:20 current[key] = dict()21 current = current[key]22 current[last] = v...
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!!