Best Python code snippet using localstack_python
test_common.py
Source: test_common.py
...224 self.assertEqual("None", fn(None))225 self.assertEqual("", fn(""))226 def test_parse_json_or_yaml_with_json(self):227 markup = """{"foo": "bar", "why": 42, "mylist": [1,2,3]}"""228 doc = common.parse_json_or_yaml(markup)229 self.assertDictEqual({"foo": "bar", "why": 42, "mylist": [1, 2, 3]}, doc)230 def test_parse_json_or_yaml_with_yaml(self):231 markup = """232 foo: bar233 why: 42234 mylist:235 - 1236 - 2237 - 3238 """239 doc = common.parse_json_or_yaml(markup)240 self.assertDictEqual({"foo": "bar", "why": 42, "mylist": [1, 2, 3]}, doc)241 def test_parse_json_or_yaml_with_invalid_syntax_returns_content(self):242 markup = "<a href='foobar'>baz</a>"243 doc = common.parse_json_or_yaml(markup)244 self.assertEqual(markup, doc) # FIXME: not sure if this is good behavior245 def test_parse_json_or_yaml_with_empty_string_returns_none(self):246 doc = common.parse_json_or_yaml("")247 self.assertIsNone(doc)248 def test_format_bytes(self):249 fn = common.format_bytes250 self.assertEqual("1B", fn(1))251 self.assertEqual("100B", fn(100))252 self.assertEqual("999B", fn(999))253 self.assertEqual("1KB", fn(1e3))254 self.assertEqual("1MB", fn(1e6))255 self.assertEqual("10MB", fn(1e7))256 self.assertEqual("100MB", fn(1e8))257 self.assertEqual("1GB", fn(1e9))258 self.assertEqual("1TB", fn(1e12))259 # comma values260 self.assertEqual("1.1TB", fn(1e12 + 1e11))...
internal.py
Source: internal.py
...99 if download_url:100 try:101 LOG.debug("Attempting to download CloudFormation template URL: %s", download_url)102 template_body = to_str(requests.get(download_url).content)103 template_body = parse_json_or_yaml(template_body)104 params["templateBody"] = json.dumps(template_body)105 except Exception as e:106 msg = f"Unable to download CloudFormation template URL: {e}"107 LOG.info(msg)108 params["errorMessage"] = json.dumps(msg.replace("\n", " - "))109 # using simple string replacement here, for simplicity (could be replaced with, e.g., jinja)110 for key, value in params.items():111 deploy_html = deploy_html.replace(f"<{key}>", value)112 result = requests_response(deploy_html)113 return result114class LocalstackResources(ResourceRouter):115 """116 Router for localstack-internal HTTP resources.117 """...
provider_asf.py
Source: provider_asf.py
...25 self, context: RequestContext, request: TestInvokeMethodRequest26 ) -> TestInvokeMethodResponse:27 invocation_context = to_invocation_context(context.request)28 invocation_context.method = request["httpMethod"]29 if data := parse_json_or_yaml(to_str(invocation_context.data or b"")):30 orig_data = data31 if path_with_query_string := orig_data.get("pathWithQueryString"):32 invocation_context.path_with_query_string = path_with_query_string33 invocation_context.data = data.get("body")34 invocation_context.headers = orig_data.get("headers", {})35 result = invoke_rest_api_from_request(invocation_context)36 # TODO: implement the other TestInvokeMethodResponse parameters37 # * multiValueHeaders: Optional[MapOfStringToList]38 # * log: Optional[String]39 # * latency: Optional[Long]40 return TestInvokeMethodResponse(41 status=result.status_code,42 headers=dict(result.headers),43 body=to_str(result.content),...
Check out the latest blogs from LambdaTest on this topic:
The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.
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.
Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.
Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.
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!!