How to use _get_request_id method in tempest

Best Python code snippet using tempest_python

log.py

Source:log.py Github

copy

Full Screen

...43 global loglevel44 loglevel = level45def debug(message):46 if loglevel <= LOG_LEVEL_DEBUG:47 print >> sys.stderr, _get_time() + " DEBUG " + _get_request_id() + " " + str(message)48 sys.stderr.flush()49def info(message):50 if loglevel <= LOG_LEVEL_INFO:51 print >> sys.stderr, _get_time() + " INFO " + _get_request_id() + " " + str(message)52 sys.stderr.flush()53def error(message):54 if loglevel <= LOG_LEVEL_ERROR:55 print >> sys.stderr, _get_time() + " ERROR " + _get_request_id() + " " + str(message)56 sys.stderr.flush()57def critical(message):58 if loglevel <= LOG_LEVEL_CRITICAL:59 print >> sys.stderr, _get_time() + " CRITICAL " + _get_request_id() + " " + str(message)60 sys.stderr.flush()61def _get_request_id():62 if not hasattr(request_context, 'request_id'):63 set_request_id()64 return request_context.request_id65def _get_time():66 return "[" + datetime.now().isoformat(' ') + "]"67def log_start_request(request):68 """69 Create a unique request id and store it in request_context if it isn't70 already set there. This way it will be available to future log calls.71 """72 request_id = _generate_request_id_from_request(request)73 set_request_id(request_id)74 messagelist = []75 messagelist.append("Request started.")...

Full Screen

Full Screen

main.py

Source:main.py Github

copy

Full Screen

...15 if 'nodes' in kwargs:16 self._nodes = kwargs.get('nodes')17 self._default_node = kwargs.get('default_node', self.get_nodes()[0])18 self._private_key = kwargs.get('private_key', None)19 def _get_request_id(self):20 self._request_id += 121 return self._request_id22 def get_nodes(self) -> List[str]:23 return self._nodes24 def is_valid_address(self, check_address: str, node: Optional[str] = None) -> bool:25 request_id = self._get_request_id()26 payload = {27 'method': 'validateaddress',28 'params': [check_address],29 'jsonrpc': '2.0',30 'id': request_id,31 }32 response = requests.post(node or self._default_node, json=payload).json()33 assert response["jsonrpc"]34 assert response["id"] == request_id35 if 'error' in response:36 raise RuntimeError(f"EC: {response['error']['code']}\nError: {response['error']['message']}")37 return response['result']['isvalid']38 def get_token_balances(self, check_address: str, node: Optional[str] = None) -> Dict[str, int]:39 request_id = self._get_request_id()40 payload = {41 'method': 'getnep17balances',42 'params': [check_address],43 'jsonrpc': '2.0',44 'id': request_id,45 }46 response = requests.post(node or self._default_node, json=payload).json()47 assert response["jsonrpc"]48 assert response["id"] == request_id49 print(response)50 if 'error' in response:51 raise RuntimeError(f"EC: {response['error']['code']}\nError: {response['error']['message']}")52 return {token['assethash']: token['amount'] for token in response['result']['balance']}53 def get_block_count(self, node: Optional[str] = None):54 request_id = self._get_request_id()55 payload = {56 'jsonrpc': '2.0',57 'method': 'getblockcount',58 'params': [],59 'id': request_id,60 }61 response = requests.post(node or self._default_node, data=json.dumps(payload)).json()62 assert response["jsonrpc"]63 assert response['id'] == request_id...

Full Screen

Full Screen

test_requests.py

Source:test_requests.py Github

copy

Full Screen

1from unittest import mock2from thunderstorm_auth.logging import requests3@mock.patch('thunderstorm_auth.logging.requests._get')4@mock.patch('thunderstorm_auth.logging.requests._get_request_id')5def test_get(mock_get_request_id, mock_get):6 mock_get_request_id.return_value = 'request-id'7 requests.get('/')8 mock_get.assert_called_with('/', headers={'TS-Request-ID': 'request-id'})9@mock.patch('thunderstorm_auth.logging.requests._get')10@mock.patch('thunderstorm_auth.logging.requests._get_request_id')11def test_get_with_headers(mock_get_request_id, mock_get):12 mock_get_request_id.return_value = 'request-id'13 requests.get('/', headers={'foo': 'bar'})14 mock_get.assert_called_with(15 '/', headers={16 'TS-Request-ID': 'request-id',17 'foo': 'bar',18 }19 )20@mock.patch('thunderstorm_auth.logging.requests._get')21@mock.patch('thunderstorm_auth.logging.requests._get_request_id')22def test_get_with_request_id(mock_get_request_id, mock_get):23 mock_get_request_id.return_value = 'request-id'24 requests.get('/', headers={'TS-Request-ID': 'my-id'})25 mock_get.assert_called_with(26 '/', headers={27 'TS-Request-ID': 'my-id',28 }...

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