Best Python code snippet using assertpy_python
test_req_store.py
Source:test_req_store.py
1import copy2import json3from unittest.mock import MagicMock4import pytest5from data_acquisition.acquisition_request import AcquisitionRequest, AcquisitionRequestStore6from tests.consts import TEST_ACQUISITION_REQ, TEST_ACQUISITION_REQ_STR, TEST_ACQUISITION_REQ_JSON7@pytest.fixture8def redis_mock():9 return MagicMock()10@pytest.fixture11def req_store(redis_mock):12 return AcquisitionRequestStore(redis_mock)13def test_get_request_redis_id(req_store):14 request_redis_id = req_store.get_request_redis_id(TEST_ACQUISITION_REQ)15 assert request_redis_id == '{}:{}'.format(TEST_ACQUISITION_REQ.orgUUID, TEST_ACQUISITION_REQ.id)16def test_put(req_store, redis_mock):17 req_store.put(TEST_ACQUISITION_REQ)18 redis_mock.hset.assert_called_with(19 AcquisitionRequestStore.REDIS_HASH_NAME,20 AcquisitionRequestStore.get_request_redis_id(TEST_ACQUISITION_REQ),21 TEST_ACQUISITION_REQ_STR)22def _get_store_id(acquisition_req):23 return '{}:{}'.format(acquisition_req.orgUUID, acquisition_req.id).encode()24def test_get_for_org(req_store, redis_mock):25 test_requests = [copy.deepcopy(TEST_ACQUISITION_REQ) for _ in range(3)]26 test_requests[1].orgUUID = 'other-fake-uuid'27 test_requests[2].id = 'other-fake-id'28 redis_mock.hgetall.return_value = {_get_store_id(req): str(req).encode()29 for req in test_requests}30 acquisition_requests = req_store.get_for_org('fake-org-uuid')31 assert test_requests[0] in acquisition_requests32 assert test_requests[2] in acquisition_requests33def test_get_from_old_base(req_store, redis_mock):34 old_request = dict(TEST_ACQUISITION_REQ_JSON)35 old_request.update({'unnecessary_field': 'blablabla'})36 redis_mock.hgetall.return_value = {b'fake-org-uuid:fake-id': json.dumps(old_request).encode()}37 acquisition_req = req_store.get('fake-id')38 assert acquisition_req == AcquisitionRequest(**TEST_ACQUISITION_REQ_JSON)...
urls.py
Source:urls.py
1from server.requesthandlers import test_requests2from server.requesthandlers.virus_info_request import virus_info_handler3from server.requesthandlers.single_request import single_handler4from server.requesthandlers.cycle_request import cycle_handler5URLS = {"GET/test/default": test_requests.default_handler,6 "POST/test/scheduler": test_requests.scheduler_handler,7 "POST/test/binary": test_requests.binary_handler,8 "POST/api/virus": virus_info_handler,9 "POST/api/singleVirusTotal": single_handler,...
test_anonymize.py
Source:test_anonymize.py
1import requests2from anonymize import enable_proxy, disable_proxy3#This url returns your ip as plain text4url = 'http://icanhazip.com'5def test_requests():6 print('requests: %s' % requests.get(url).text)7enable_proxy()8test_requests()9disable_proxy()...
Check out the latest blogs from LambdaTest on this topic:
QA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.
One of the most important skills for leaders to have is the ability to prioritize. To understand how we can organize all of the tasks that must be completed in order to complete a project, we must first understand the business we are in, particularly the project goals. There might be several project drivers that stimulate project execution and motivate a company to allocate the appropriate funding.
I was once asked at a testing summit, “How do you manage a QA team using scrum?” After some consideration, I realized it would make a good article, so here I am. Understand that the idea behind developing software in a scrum environment is for development teams to self-organize.
Coaching is a term that is now being mentioned a lot more in the leadership space. Having grown successful teams I thought that I was well acquainted with this subject.
In today’s world, an organization’s most valuable resource is its customers. However, acquiring new customers in an increasingly competitive marketplace can be challenging while maintaining a strong bond with existing clients. Implementing a customer relationship management (CRM) system will allow your organization to keep track of important customer information. This will enable you to market your services and products to these customers better.
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!!