Best Python code snippet using localstack_python
reports.py
Source:reports.py
...21 def process(self, spider):22 self._process_overall(spider)23 self._process_pages(spider)24 def _process_pages(self, spider):25 host = spider.get_origin_host()26 fire = Firebase('%s/pages/%s' % (self.fire_host, host))27 origin_hash = url_hash(host)28 cursor = self.db.cursor()29 query = """30SELECT content_item_id31 , content_node_id32 , object_type33 , lint_critical34 , lint_error35 , lint_warn36 , lint_info37 , lint_results38 FROM page39 WHERE request_method = 'GET'40 AND external = 041 AND object_type IS NOT NULL42 AND content_item_id IS NOT NULL43 ORDER BY lint_critical DESC, lint_error DESC, lint_warn DESC44 LIMIT 2045 """46 cursor.execute(query)47 rows = cursor.fetchall()48 res = {}49 for row in rows:50 res[row.pop('content_item_id')] = row51 fire.update(res)52 def _process_overall(self, spider):53 host = spider.get_origin_host()54 fire = Firebase('%s/reports/%s/%s' % (self.fire_host, host,55 datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S')))56 origin_hash = url_hash(host)57 cursor = self.db.cursor()58 query = """59SELECT COUNT(1) AS pages60 , AVG(p.response_time) AS avg_response_time61 , AVG(p.response_time + al.total_response_time) AS avg_total_response_time62 , AVG(LENGTH(p.body)) AS avg_page_size63 , AVG(LENGTH(p.body) + al.total_size) AS avg_total_page_size64 , SUM(p.lint_critical) AS total_lint_critical65 , SUM(p.lint_error) AS total_lint_error66 , SUM(p.lint_warn) AS total_lint_warn67 , SUM(p.lint_info) AS total_lint_info...
test_settings.py
Source:test_settings.py
...43 def test_raise_exception_when_origin_host_is_not_defined(44 self, settings):45 del(settings.POSTOFFICE['ORIGIN_HOST'])46 with pytest.raises(OriginHostSettingNotDefined):47 get_origin_host()48 def test_raise_exception_when_topics_is_not_defined(49 self, settings, caplog):50 del(settings.POSTOFFICE['TOPICS'])51 assert get_topics() == []52 assert (53 'postoffice_django.settings',54 logging.WARNING,55 'Topics config key is missing'...
middleware.py
Source:middleware.py
...22 return response23class OriginHostMiddleware(object):24 def process_request(self, request, spider):25 if hasattr(spider, 'get_origin_host'):26 request.meta['origin_host'] = spider.get_origin_host()27class ErrorConverterMiddleware(object):28 def process_exception(self, request, exception, spider):...
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!!