How to use push_context method in Slash

Best Python code snippet using slash

results_parser_test.py

Source:results_parser_test.py Github

copy

Full Screen

...78 results_parser.sns_client79 ),80 # Expect data for port 22, but first81 # Expect to push the port context82 call.push_context({83 "port_str": "22",84 "port_id": "22",85 "protocol": "tcp",86 }),87 call.post_results(88 "ports",89 {90 "status": "open",91 "status_reason": "syn-ack",92 "service": "ssh",93 "product": "OpenSSH",94 "version": "6.6.1p1 Ubuntu 2ubuntu2.11",95 "extra_info": "Ubuntu Linux; protocol 2.0",96 "os_type": "Linux",97 "cpes": ["cpe:/a:openbsd:openssh:6.6.1p1", "cpe:/o:linux:linux_kernel"]98 }99 ),100 # Expect to see the pop and push of the new context for port 80 and pusblish101 call.pop_context(),102 call.push_context({103 "port_str": "80",104 "port_id": "80",105 "protocol": "tcp",106 }),107 call.post_results(108 "ports",109 {110 "status": "open",111 "status_reason": "syn-ack",112 "service": "http",113 "product": "Apache httpd",114 "version": "2.4.7",115 "extra_info": "(Ubuntu)",116 "os_type": None,117 "cpes": ["cpe:/a:apache:http_server:2.4.7"],118 "http-server-header": [119 "Apache/2.4.7 (Ubuntu)"120 ]121 }122 ),123 # Now the context that is pushed after popping and is expected to be used in the non temporal key124 # is the os name, since we are expecting to report os level info125 call.pop_context(),126 call.push_context({127 "os_name": "Linux 4.4"128 }),129 call.post_results(130 "os",131 {132 "os_accuracy": 97,133 "os_classes": [134 {135 "os_class_type": "general purpose",136 "os_class_vendor": "Linux",137 "os_class_os_family": "Linux",138 "os_class_os_gen": "4.X",139 "os_class_accuracy": "97",140 "os_cpes": [141 "cpe:/o:linux:linux_kernel:4.4"142 ]143 }144 ]145 }146 ),147 # Since this accuracy of 97% is the highest seen, we expect the summaries to update148 call.add_summary("most_likely_os", "Linux 4.4"),149 call.add_summary("most_likely_os_accuracy", 97),150 # We expect two os docs in the collection151 call.pop_context(),152 call.push_context({153 "os_name": "Linux 3.11 - 4.1"154 }),155 # then the summaries156 call.post_results(157 "os",158 {159 "os_accuracy": 93,160 "os_classes": [161 {162 "os_class_type": "general purpose",163 "os_class_vendor": "Linux",164 "os_class_os_family": "Linux",165 "os_class_os_gen": "3.X",166 "os_class_accuracy": "93",167 "os_cpes": [168 "cpe:/o:linux:linux_kernel:3"169 ]170 },171 {172 "os_class_type": "general purpose",173 "os_class_vendor": "Linux",174 "os_class_os_family": "Linux",175 "os_class_os_gen": "4.X",176 "os_class_accuracy": "93",177 "os_cpes": [178 "cpe:/o:linux:linux_kernel:4"179 ]180 }181 ]182 }183 ),184 # And now finally we expect the big global doc to be published, including summaries185 call.pop_context(),186 call.post_results(187 "data",188 {189 "host_names": [190 {191 "host_name": "scanme.nmap.org",192 "host_name_type": "user"193 },194 {195 "host_name": "scanme.nmap.org",196 "host_name_type": "PTR"197 }198 ],199 "ports": [200 {201 "port_str": "22",202 "port_id": "22",203 "protocol": "tcp",204 "status": "open",205 "status_reason": "syn-ack",206 "service": "ssh",207 "product": "OpenSSH",208 "version": "6.6.1p1 Ubuntu 2ubuntu2.11",209 "extra_info": "Ubuntu Linux; protocol 2.0",210 "os_type": "Linux",211 "cpes": ["cpe:/a:openbsd:openssh:6.6.1p1", "cpe:/o:linux:linux_kernel"]212 },213 {214 "port_str": "80",215 "port_id": "80",216 "protocol": "tcp",217 "status": "open",218 "status_reason": "syn-ack",219 "service": "http",220 "product": "Apache httpd",221 "version": "2.4.7",222 "extra_info": "(Ubuntu)",223 "os_type": None,224 "cpes": ["cpe:/a:apache:http_server:2.4.7"],225 "http-server-header": [226 "Apache/2.4.7 (Ubuntu)"227 ]228 },229 ],230 "os_info": [231 {232 "os_name": "Linux 4.4",233 "os_accuracy": 97,234 "os_classes": [235 {236 "os_class_type": "general purpose",237 "os_class_vendor": "Linux",238 "os_class_os_family": "Linux",239 "os_class_os_gen": "4.X",240 "os_class_accuracy": "97",241 "os_cpes": [242 "cpe:/o:linux:linux_kernel:4.4"243 ]244 }245 ]246 },247 {248 "os_name": "Linux 3.11 - 4.1",249 "os_accuracy": 93,250 "os_classes": [251 {252 "os_class_type": "general purpose",253 "os_class_vendor": "Linux",254 "os_class_os_family": "Linux",255 "os_class_os_gen": "3.X",256 "os_class_accuracy": "93",257 "os_cpes": [258 "cpe:/o:linux:linux_kernel:3"259 ]260 },261 {262 "os_class_type": "general purpose",263 "os_class_vendor": "Linux",264 "os_class_os_family": "Linux",265 "os_class_os_gen": "4.X",266 "os_class_accuracy": "93",267 "os_cpes": [268 "cpe:/o:linux:linux_kernel:4"269 ]270 }271 ]272 }273 ],274 "host_scan_start_time": "2019-04-17T12:55:57Z",275 "host_scan_end_time": "2019-04-17T12:56:27Z",276 "status": "up",277 "status_reason": "echo-reply",278 "uptime": "686432",279 "last_boot": "Tue Apr 9 14:15:55 2019"280 },281 include_summaries=True282 ),283 # expect the publish method to be called at the finish284 call.publish_results()285 ]286 @resetting_mocks(results_context_constructor)287 @pytest.mark.unit288 def test_parses_tls_info():289 results_parser, mock_mgr, mock_results_context = execute_test_using_results_archive(290 "tls-info-nmap.xml.tar.gz"291 )292 # filter all the calls to those that allow us to inspect the behaviour293 posted_cipher_doc = filter_tested_interactions(294 ["ssl_ciphers", "ssl_protos"],295 ["push_context", "pop_context", "add_summaries"],296 mock_mgr297 )298 expected = [299 call.push_context({300 "port_str": "443",301 "port_id": "443",302 "protocol": "tcp",303 }),304 # first publish all the info in one doc305 call.push_context({"ssl_protocol": "TLSv1.2"}),306 call.post_results("ssl_protos", {307 "ciphers": [308 {309 "kex_info": "ecdh_x25519",310 "strength": "A",311 "name": "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"312 },313 {314 "kex_info": "ecdh_x25519",315 "strength": "A",316 "name": "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"317 },318 ],319 "cipher_preference": "server"320 }),321 # Then an entry for each cipher is created322 call.push_context({"name": "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"}),323 call.post_results("ssl_ciphers", {"kex_info": "ecdh_x25519", "strength": "A"}),324 call.pop_context(),325 call.push_context({"name": "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"}),326 call.post_results("ssl_ciphers", {"kex_info": "ecdh_x25519", "strength": "A"}),327 call.pop_context(),328 call.pop_context(),329 call.add_summaries({"lowest_ssl_proto": "TLSv1.2", "lowest_ssl_strength": "A"}),330 call.pop_context(),331 ]332 assert posted_cipher_doc == expected333 @resetting_mocks(results_context_constructor)334 @pytest.mark.unit335 def test_parses_cve_info():336 results_parser, mock_mgr, mock_results_context = execute_test_using_results_archive(337 "cve-info-nmap.xml.tar.gz"338 )339 # filter all the calls to those that allow us to inspect the behaviour340 posted_cipher_doc = filter_tested_interactions(341 ["cves"],342 ["push_context", "pop_context"],343 mock_mgr344 )345 assert posted_cipher_doc == [346 call.push_context({347 "port_str": "80",348 "port_id": "80",349 "protocol": "tcp",350 }),351 call.push_context({"cve_code": "CVE-2017-7679"}),352 call.post_results("cves", {"cve_severity": 7.5}),353 call.pop_context(),354 call.push_context({"cve_code": "CVE-2018-1312"}),355 call.post_results("cves", {"cve_severity": 6.8}),356 call.pop_context(),357 call.pop_context(),358 ]359 @resetting_mocks(results_context_constructor)360 @pytest.mark.unit361 def test_parses_multiple_os_cpes_regression_sa_44():362 results_parser, mock_mgr, mock_results_context = execute_test_using_results_archive(363 "multiple-os-cpes-regression-sa-44-nmap.xml.tar.gz"364 )365 # filter all the calls to those that allow us to inspect the behaviour366 posted_cipher_doc = filter_tested_interactions(367 ["os"],368 ["push_context", "pop_context"],369 mock_mgr370 )371 assert posted_cipher_doc == [372 call.push_context({"os_name": "D-Link DWL-624+ or DWL-2000AP, or TRENDnet TEW-432BRP WAP"}),373 call.post_results("os", {374 "os_accuracy": 90,375 "os_classes": [376 {377 "os_class_type": "WAP",378 "os_class_vendor": "D-Link",379 "os_class_os_family": "embedded",380 "os_class_os_gen": None,381 "os_class_accuracy": "90",382 "os_cpes": ["cpe:/h:dlink:dwl-624%2b", "cpe:/h:dlink:dwl-2000ap"]383 },384 {385 "os_class_type": "WAP",386 "os_class_vendor": "TRENDnet",387 "os_class_os_family": "embedded",388 "os_class_os_gen": None,389 "os_class_accuracy": "90",390 "os_cpes": ["cpe:/h:trendnet:tew-432brp"]391 }392 ]393 }),394 call.pop_context(),395 ]396 @resetting_mocks(results_context_constructor)397 @pytest.mark.unit398 def test_parses_multiple_os_cpes_regression_sa_44():399 results_parser, mock_mgr, mock_results_context = execute_test_using_results_archive(400 "no-timestamps-when-host-down-regression-sa-43-nmap.xml.tar.gz"401 )402 # filter all the calls to those that allow us to inspect the behaviour403 posted_cipher_doc = filter_tested_interactions(404 ["os"],405 ["push_context", "pop_context"],406 mock_mgr407 )408 mock_results_context.publish_results.assert_called_once()409 @resetting_mocks(results_context_constructor)410 @pytest.mark.unit411 def test_parses_os_but_no_osmatch_regression_sa_45():412 results_parser, mock_mgr, mock_results_context = execute_test_using_results_archive(413 "os-but-no-osmatch-regression-sa-45-nmap.xml.tar.gz"414 )415 mock_results_context.publish_results.assert_called_once()416 @resetting_mocks(results_context_constructor)417 @pytest.mark.unit418 def test_parses_http_server_parse_regression_sa_46():419 results_parser, mock_mgr, mock_results_context = execute_test_using_results_archive(420 "http-server-parse-regression-sa-46-nmap.xml.tar.gz"421 )422 # filter all the calls to those that allow us to inspect the behaviour423 posted_cipher_doc = filter_tested_interactions(424 ["ports"],425 ["push_context", "pop_context"],426 mock_mgr427 )428 assert posted_cipher_doc == [429 call.push_context({430 "port_str": "80",431 "port_id": "80",432 "protocol": "tcp",433 }),434 call.post_results("ports", {435 "status": "open",436 "status_reason": "syn-ack",437 "service": "http",438 "product": "Amazon CloudFront httpd",439 "version": None,440 "extra_info": None,441 "os_type": None,442 "http-server-header": ["AmazonS3", "CloudFront"]443 }),444 call.pop_context()445 ]446 @resetting_mocks(results_context_constructor)447 @pytest.mark.unit448 @serialise_mocks()449 @patch("datetime.datetime")450 def test_parses_ssl_certs(datetime):451 datetime.strptime.return_value = datetime_real(2019, 6, 29, 11, 0, 0)452 datetime.now.return_value = datetime_real(2019, 7, 12, 12, 0, 0)453 results_parser, mock_mgr, mock_results_context = execute_test_using_results_archive(454 "test_ssl_cert.xml.tar.gz"455 )456 # filter all the calls to those that allow us to inspect the behaviour457 posted_cipher_doc = filter_tested_interactions(458 ["ssl_cert"],459 ["push_context", "pop_context"],460 mock_mgr461 )462 assert posted_cipher_doc == [463 call.push_context({464 "port_str": "443",465 "port_id": "443",466 "protocol": "tcp",467 }),468 call.post_results("ssl_cert", {469 "extensions": [{"name": "X509v3 Subject Alternative Name", "value": "DNS:scottlogic.com"}],470 "issuer": {471 "commonName": "Let's Encrypt Authority X3",472 "countryName": "US",473 "organizationName": "Let's Encrypt"474 },475 "subject": {"commonName": "scottlogic.com"},476 "validity": {"notAfter": "2019-06-29T06:52:46", "notBefore": "2019-03-31T06:52:46"},477 "expiry_diff_at_scan": -14478 }),479 call.pop_context()480 ]481 @resetting_mocks(results_context_constructor)482 @pytest.mark.unit483 def test_regression_table_format_for_vulns():484 results_parser, mock_mgr, mock_results_context = execute_test_using_results_archive(485 "regression-SA-174-table-format-for-vulns.xml.tar.gz"486 )487 # filter all the calls to those that allow us to inspect the behaviour488 posted_cipher_doc = filter_tested_interactions(489 ["cve_code", "cves"],490 ["push_context", "pop_context"],491 mock_mgr492 )493 assert posted_cipher_doc == [494 call.push_context({495 "port_str": "80",496 "port_id": "80",497 "protocol": "tcp",498 }),499 call.push_context({"cve_code": "CVE-2017-7679"}),500 call.post_results("cves", {"cve_severity": 7.5, "is_exploit": "false", "type": "cve"}),501 call.pop_context(),502 call.push_context({"cve_code": "CVE-2018-1312"}),503 call.post_results("cves", {"cve_severity": 6.8, "is_exploit": "false", "type": "cve"}),504 call.pop_context(),505 call.pop_context(),506 ]507 @serialise_mocks()508 def execute_test_using_results_archive(filename):509 with patch("aioboto3.client"), \510 patch.dict(os.environ, TEST_ENV):511 results_parser = NmapResultsParser()512 results_context_constructor.return_value = mock_results_context = MagicMock()513 mock_mgr = Mock()514 mock_mgr.attach_mock(results_context_constructor, "ResultsContext")515 mock_mgr.attach_mock(mock_results_context.push_context, "push_context")516 mock_mgr.attach_mock(mock_results_context.pop_context, "pop_context")...

Full Screen

Full Screen

csharp_interpreter.py

Source:csharp_interpreter.py Github

copy

Full Screen

...71 def __init__(self, file = None):72 self.file = file73 self.contexts = []74 self.currentContext = None75 def push_context(self, context):76 self.contexts.append(context)77 self.currentContext = context78 def pop_context(self):79 if self.contexts:80 self.contexts.pop()81 if self.contexts:82 self.currentContext = self.contexts[-1]83 else:84 self.currentContext = None85 86 def start_class(self, name, ast):87 cl = CSharpClass(name, self.currentContext.currentObject if self.currentContext else None, ast, self.file)88 self.push_context(ClassContext(cl, self.currentContext))89 return cl90 91 def end_class(self):92 self.pop_context()93 94 def start_method(self, name, returnType, accessibility, ast):95 isConstructor = self.currentContext.is_class(name)96 meth = CSharpMethod(name, returnType, accessibility, self.currentContext.currentObject, ast, self.file, isConstructor)97 self.currentContext.add_method(meth)98 self.push_context(MethodContext(meth, self.currentContext))99 return meth100 101 def add_attribute(self, attribute, ast):102 self.currentContext.add_attribute(attribute, ast)103 104 def end_method(self):105 self.pop_context()106 107 def start_block(self, ast):108 block = StatementsBlock(self.currentContext.currentObject if self.currentContext else None, ast)109 self.push_context(BlockContext(block, self.currentContext))110 return block111 112 def end_block(self):113 self.pop_context()114 115 def start_parenthesed_list(self, ast):116 lst = ParenthesedList(self.currentContext.currentObject if self.currentContext else None, ast)117 self.push_context(ParenthesedListContext(lst, self.currentContext))118 return lst119 120 def end_parenthesed_list(self):121 self.pop_context()122 123 def start_expression(self, ast):124 expr = AnyExpression(self.currentContext.currentObject if self.currentContext else None, ast)125 self.push_context(ExpressionContext(expr, self.currentContext))126 return expr127 128 def end_expression(self):129 self.pop_context()130 131 def add_element(self, element):132 if self.currentContext:133 self.currentContext.add_element(element)134 135 def add_any_statement(self, tokens):136 statement = AnyStatement(self.currentContext.currentObject if self.currentContext else None, tokens)137 if self.currentContext:138 self.currentContext.add_statement(statement)139 140 def add_any_expression(self, tokens):141 expr = AnyExpression(self.currentContext.currentObject if self.currentContext else None, tokens)142# if self.currentContext:143# self.currentContext.add_statement(statement)144 145 def set_left_operand(self, ast):146 self.currentContext.set_left_operand(ast)147 148 def set_right_operand(self, ast):149 self.currentContext.set_right_operand(ast)150 151 def start_equality_expression(self, ast):152 expr = EqualityExpression(self.currentContext.currentObject if self.currentContext else None, ast)153 self.push_context(BinaryExpressionContext(expr, self.currentContext))154 return expr155 156 def end_equality_expression(self):157 self.pop_context()158 159 def start_assignment_expression(self, ast):160 expr = AssignmentExpression(self.currentContext.currentObject if self.currentContext else None, ast)161 self.push_context(BinaryExpressionContext(expr, self.currentContext))162 return expr163 164 def end_assignment_expression(self):165 self.pop_context()166 167 def start_new_anonymous_expression(self, ast):168 expr = NewAnonymousExpression(self.currentContext.currentObject if self.currentContext else None, ast)169 self.push_context(ParenthesedListContext(expr, self.currentContext))170 return expr171 172 def end_new_anonymous_expression(self):...

Full Screen

Full Screen

test_context.py

Source:test_context.py Github

copy

Full Screen

...9 purge_context()10@with_setup(setup, tear_down)11def test_push_pop_context():12 root_a = Root()13 push_context(root_a)14 assert_equals(len(CONTEXTS), 1)15 root_b = Root()16 push_context(root_b)17 assert_equals(len(CONTEXTS), 2)18 poped = pop_context()19 assert_equals(len(CONTEXTS), 1)20 assert_equals(poped.block, root_b)21 poped = pop_context()22 assert_equals(len(CONTEXTS), 0)23 assert_equals(poped.block, root_a)24@with_setup(setup, tear_down)25def test_push_get_purge_context():26 root = Root()27 push_context(root)28 assert_equals(len(CONTEXTS), 1)29 assert_equals(get_context().block, root)30 root = Root()31 push_context(root)32 assert_equals(len(CONTEXTS), 2)33 assert_equals(get_context().block, root)34 purge_context()35 assert_equals(len(CONTEXTS), 0)36@with_setup(setup, tear_down)37def test_add_variables():38 context = push_context(Root())39 assert_equals(len(context.variables['index']), 0)40 assert_equals(len(context.variables['name']), 0)41 one_str_var = Variable('1')42 context.add_var('1', one_str_var)43 one_int_var = Variable(1)44 context.add_var(1, one_int_var)45 some_var = Variable('some')46 context.add_var('some', some_var)47 assert_equals(len(context.variables['index']), 1)48 assert_equals(context.variables['index'][1], one_int_var)49 assert_equals(len(context.variables['name']), 1)50 assert_equals(context.variables['name']['some'], some_var)51 context.clear_index_vars()52 assert_equals(len(context.variables['index']), 0)53 assert_equals(len(context.variables['name']), 1)54 assert_equals(context.variables['name']['some'], some_var)55@with_setup(setup, tear_down)56def test_get_variables():57 context = push_context(Root())58 assert_equals(len(context.variables['index']), 0)59 assert_equals(len(context.variables['name']), 0)60 one_var = Variable(1)61 context.add_var(1, one_var)62 some_var = Variable('some')63 context.add_var('some', some_var)64 assert_equals(context.get_var(1), one_var)65 assert_equals(context.get_var('some'), some_var)66 # Checks not existed variables, for now context may return None67 assert_equals(context.get_var(0), None)68 assert_equals(context.get_var('not_existed'), None)69 # Checks builtins variables70 assert_true(context.get_var('uri'))71 assert_true(context.get_var('document_uri'))72 assert_true(context.get_var('arg_asdsadasd'))73 assert_true(context.get_var('args'))74@with_setup(setup, tear_down)75def test_context_depend_variables():76 push_context(Root())77 assert_equals(len(get_context().variables['index']), 0)78 assert_equals(len(get_context().variables['name']), 0)79 get_context().add_var(1, Variable(1, value='one'))80 get_context().add_var('some', Variable('some', value='some'))81 assert_equals(get_context().get_var(1).value, 'one')82 assert_equals(get_context().get_var('some').value, 'some')83 # Checks top context variables are still exists84 push_context(Root())85 assert_equals(get_context().get_var(1).value, 'one')86 assert_equals(get_context().get_var('some').value, 'some')87 # Checks variable overriding88 get_context().add_var('some', Variable('some', value='some_new'))89 get_context().add_var('foo', Variable('foo', value='foo'))90 assert_not_equals(get_context().get_var('some').value, 'some')91 assert_equals(get_context().get_var('some').value, 'some_new')92 assert_equals(get_context().get_var('foo').value, 'foo')93 assert_equals(get_context().get_var(1).value, 'one')94 # Checks variables after restore previous context95 pop_context()96 assert_not_equals(get_context().get_var('some').value, 'some_new')97 assert_equals(get_context().get_var('some').value, 'some')98 assert_equals(get_context().get_var('foo'), None)99 assert_equals(get_context().get_var(1).value, 'one')100@with_setup(setup, tear_down)101def test_push_failed_with_regexp_py35_gixy_10():102 push_context(Root())103 assert_equals(len(get_context().variables['index']), 0)104 assert_equals(len(get_context().variables['name']), 0)105 regexp = Regexp('^/some/(.*?)')106 for name, group in regexp.groups.items():107 get_context().add_var(name, Variable(name=name, value=group))...

Full Screen

Full Screen

utils.py

Source:utils.py Github

copy

Full Screen

1from django.template.loader import select_template, get_template, find_template2def push_context(context,indices = ["generic_object","object","generic_object_list"]):3 save = {}4 for i in indices:5 save[i] = context.get(i)6 return save7def pop_context(context,save):8 for i in save.keys():9 context[i] = save[i]10 return context11def GetTemplatesPath(appname,modelname,type,template_path=None):12 template_paths = []13 if template_path:14 template_paths.append(template_path)15 template_paths.append('%s/%s/%s.html' % (appname.lower(),modelname.lower(),type))16 return template_paths17def GetBlockContent(obj,context,template_path=None):18 template_paths = GetTemplatesPath(obj.content_type.app_label,obj.content_type.model,'object',template_path)19 template_paths.append("flatblocks/object.html")20 try:21 t = select_template(template_paths)22 except:23 return ''24 save = push_context(context,["generic_object","object"])25 context["generic_object"] = obj26 context["object"] = obj.content_object27 res = t.render(context)28 context = pop_context(context,save)29 return res30def GetUnknowObjectContent(obj,context,template_path=None):31 template_paths = GetTemplatesPath(obj._meta.app_label.lower(),obj._meta.object_name.lower(),'object',template_path)32 template_paths.append("flatblocks/unknow_object.html")33 try:34 t = select_template(template_paths)35 except Exception,e:36 return 'no template find to display %s.%s object (or not valid).\n Exception : %s' % ( obj._meta.app_label.lower(),obj._meta.object_name.lower(),e )37 save = push_context(context,["object",])38 context["object"] = obj39 res = t.render(context)40 context = pop_context(context,save)41 return res42def Getm2mContent(obj,context,template_path=None):43 template_paths = GetTemplatesPath(obj.model._meta.app_label.lower(),obj.model._meta.object_name.lower(),'m2m',template_path)44 template_paths.append("flatblocks/m2m.html")45 try:46 t = select_template(template_paths)47 except Exception,e:48 return 'no template find to display %s.%s m2m (or not valid).\n Exception : %s' % ( obj.model._meta.app_label.lower(),obj.model._meta.object_name.lower(),e )49 save = push_context(context,["object_list",])50 context["object_list"] = obj.all()51 res = t.render(context)52 context = pop_context(context,save)53 54 return res55def GetListContent(obj,context,template_path=None):56 template_paths = GetTemplatesPath(obj.content_type.app_label,obj.content_type.model,'object_list',template_path)57 simple_obj_template_path = GetTemplatesPath(obj.content_type.app_label,obj.content_type.model,'object',template_path)[0]58 try:59 t = find_template(simple_obj_template_path)60 template_paths.append("flatblocks/object_list_by_object.html")61 context["object_file_to_include"] = simple_obj_template_path62 except Exception,e:63 pass64 template_paths.append("flatblocks/object_list.html")65 try:66 t = select_template(template_paths)67 except:68 return ''69 save = push_context(context,["generic_object_list",])70 context['generic_object_list'] = obj71 res = t.render(context)72 context = pop_context(context,save)73 return res74def GetTemplateContent(context,template_path,**kwargs):75 try:76 t = get_template(template_path)77 except:78 return ''79 save = push_context(context,**kwargs)80 context.update(kwargs)81 res = t.render(context)82 context = pop_context(context,save)...

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