How to use json_value method in Playwright Python

Best Python code snippet using playwright-python

contrail_alarm.py

Source:contrail_alarm.py Github

copy

Full Screen

1#!/usr/bin/python2#3# Copyright (c) 2016 Juniper Networks, Inc. All rights reserved.4#5alarm_list = [6 {7 "alarm_rules": {8 "or_list" : [9 {10 "and_list": [11 {12 "operand1": "ContrailConfig.elements.virtual_router_ip_address",13 "operation": "!=",14 "operand2": {15 "uve_attribute": "VrouterAgent.control_ip"16 }17 }18 ]19 }20 ]21 },22 "alarm_severity": 1,23 "fq_name": [24 "default-global-system-config",25 "system-defined-address-mismatch-compute"26 ],27 "id_perms": {28 "description": "Compute Node IP Address mismatch."29 },30 "parent_type": "global-system-config",31 "uve_keys": {32 "uve_key": [33 "vrouter"34 ]35 }36 },37 {38 "alarm_rules": {39 "or_list": [40 {41 "and_list": [42 {43 "operand1": "ContrailConfig.elements.bgp_router_parameters.address",44 "operation": "not in",45 "operand2": {46 "uve_attribute":47 "BgpRouterState.bgp_router_ip_list"48 }49 }50 ]51 }52 ]53 },54 "alarm_severity": 1,55 "fq_name": [56 "default-global-system-config",57 "system-defined-address-mismatch-control"58 ],59 "id_perms": {60 "description": "Control Node IP Address mismatch."61 },62 "parent_type": "global-system-config",63 "uve_keys": {64 "uve_key": [65 "control-node"66 ]67 }68 },69 {70 "alarm_rules": {71 "or_list": [72 {73 "and_list": [74 {75 "operand1": "BgpRouterState.num_up_bgp_peer",76 "operation": "==",77 "operand2": {78 "json_value": 'null'79 }80 }81 ]82 },83 {84 "and_list": [85 {86 "operand1": "BgpRouterState.num_up_bgp_peer",87 "operation": "!=",88 "operand2": {89 "uve_attribute": "BgpRouterState.num_bgp_peer"90 }91 }92 ]93 }94 ]95 },96 "alarm_severity": 1,97 "fq_name": [98 "default-global-system-config",99 "system-defined-bgp-connectivity"100 ],101 "id_perms": {102 "description": "BGP peer mismatch. Not enough BGP peers are up."103 },104 "parent_type": "global-system-config",105 "uve_keys": {106 "uve_key": [107 "control-node"108 ]109 }110 },111 {112 "alarm_rules": {113 "or_list": [114 {115 "and_list": [116 {117 "operand1": "ContrailConfig",118 "operation": "==",119 "operand2": {120 "json_value": "null"121 }122 }123 ]124 }125 ]126 },127 "alarm_severity": 1,128 "fq_name": [129 "default-global-system-config",130 "system-defined-conf-incorrect"131 ],132 "id_perms": {133 "description": "ContrailConfig missing or incorrect. Configuration pushed to Ifmap as ContrailConfig is missing/incorrect."134 },135 "parent_type": "global-system-config",136 "uve_keys": {137 "uve_key": [138 "analytics-node",139 "config-node",140 "control-node",141 "database-node",142 "vrouter"143 ]144 }145 },146 {147 "alarm_rules": {148 "or_list": [149 {150 "and_list": [151 {152 "operand1": "NodeStatus.disk_usage_info.*.percentage_partition_space_used",153 "operation": "range",154 "operand2": {155 "json_value": "[70, 90]"156 },157 "variables":158 ["NodeStatus.disk_usage_info.__key"]159 }160 ]161 }162 ]163 },164 "alarm_severity": 1,165 "fq_name": [166 "default-global-system-config",167 "system-defined-disk-usage-high"168 ],169 "id_perms": {170 "description": "Disk usage crosses high threshold limit."171 },172 "parent_type": "global-system-config",173 "uve_keys": {174 "uve_key": [175 "analytics-node",176 "config-node",177 "control-node",178 "database-node",179 "vrouter"180 ]181 }182 },183 {184 "alarm_rules": {185 "or_list": [186 {187 "and_list": [188 {189 "operand1": "NodeStatus.disk_usage_info.*.percentage_partition_space_used",190 "operation": ">",191 "operand2": {192 "json_value": "90"193 },194 "variables":195 ["NodeStatus.disk_usage_info.__key"]196 }197 ]198 }199 ]200 },201 "alarm_severity": 0,202 "fq_name": [203 "default-global-system-config",204 "system-defined-disk-usage-critical"205 ],206 "id_perms": {207 "description": "Disk usage crosses critical threshold limit."208 },209 "parent_type": "global-system-config",210 "uve_keys": {211 "uve_key": [212 "analytics-node",213 "config-node",214 "control-node",215 "database-node",216 "vrouter"217 ]218 }219 },220 {221 "alarm_rules": {222 "or_list": [223 {224 "and_list": [225 {226 "operand1": "NodeStatus",227 "operation": "==",228 "operand2": {229 "json_value": "null"230 }231 }232 ]233 }234 ]235 },236 "alarm_severity": 0,237 "fq_name": [238 "default-global-system-config",239 "system-defined-node-status"240 ],241 "id_perms": {242 "description": "Node Failure. NodeStatus UVE not present."243 },244 "parent_type": "global-system-config",245 "uve_keys": {246 "uve_key": [247 "analytics-node",248 "config-node",249 "control-node",250 "database-node",251 "vrouter"252 ]253 }254 },255 {256 "alarm_rules": {257 "or_list": [258 {259 "and_list": [260 {261 "operand1": "NodeStatus.build_info",262 "operation": "==",263 "operand2": {264 "json_value": "null"265 }266 }267 ]268 }269 ]270 },271 "alarm_severity": 1,272 "fq_name": [273 "default-global-system-config",274 "system-defined-partial-sysinfo"275 ],276 "id_perms": {277 "description": "System Info Incomplete."278 },279 "parent_type": "global-system-config",280 "uve_keys": {281 "uve_key": [282 "analytics-node",283 "config-node",284 "control-node",285 "database-node",286 "vrouter"287 ]288 }289 },290 {291 "alarm_rules": {292 "or_list": [293 {294 "and_list": [295 {296 "operand1": "VrouterStatsAgent.out_bps_ewm.*.sigma",297 "operation": ">=",298 "operand2": {299 "json_value": "2"300 },301 "variables": ["VrouterStatsAgent.out_bps_ewm.__key"]302 }303 ]304 },305 {306 "and_list": [307 {308 "operand1": "VrouterStatsAgent.out_bps_ewm.*.sigma",309 "operation": "<=",310 "operand2": {311 "json_value": "-2"312 },313 "variables": ["VrouterStatsAgent.out_bps_ewm.__key"]314 }315 ]316 },317 {318 "and_list": [319 {320 "operand1": "VrouterStatsAgent.in_bps_ewm.*.sigma",321 "operation": ">=",322 "operand2": {323 "json_value": "2"324 },325 "variables": ["VrouterStatsAgent.in_bps_ewm.__key"]326 }327 ]328 },329 {330 "and_list": [331 {332 "operand1": "VrouterStatsAgent.in_bps_ewm.*.sigma",333 "operation": "<=",334 "operand2": {335 "json_value": "-2"336 },337 "variables": ["VrouterStatsAgent.in_bps_ewm.__key"]338 }339 ]340 }341 ]342 },343 "alarm_severity": 2,344 "fq_name": [345 "default-global-system-config",346 "system-defined-phyif-bandwidth"347 ],348 "id_perms": {349 "description": "Physical Bandwidth usage anomaly."350 },351 "parent_type": "global-system-config",352 "uve_keys": {353 "uve_key": [354 "vrouter"355 ]356 }357 },358 {359 "alarm_rules": {360 "or_list": [361 {362 "and_list": [363 {364 "operand1": "NodeStatus.process_status",365 "operation": "==",366 "operand2": {367 "json_value": "null"368 }369 }370 ]371 },372 {373 "and_list": [374 {375 "operand1": "NodeStatus.process_status.state",376 "operation": "!=",377 "operand2": {378 "json_value": "\"Functional\""379 },380 "variables": ["NodeStatus.process_status.module_id",381 "NodeStatus.process_status.instance_id"]382 }383 ]384 }385 ]386 },387 "alarm_severity": 0,388 "fq_name": [389 "default-global-system-config",390 "system-defined-process-connectivity"391 ],392 "id_perms": {393 "description": "Process(es) reporting as non-functional."394 },395 "parent_type": "global-system-config",396 "uve_keys": {397 "uve_key": [398 "analytics-node",399 "config-node",400 "control-node",401 "database-node",402 "vrouter"403 ]404 }405 },406 {407 "alarm_rules": {408 "or_list": [409 {410 "and_list": [411 {412 "operand1": "NodeStatus.process_info",413 "operation": "==",414 "operand2": {415 "json_value": "null"416 }417 }418 ]419 },420 {421 "and_list": [422 {423 "operand1": "NodeStatus.process_info.process_state",424 "operation": "!=",425 "operand2": {426 "json_value": "\"PROCESS_STATE_RUNNING\""427 },428 "variables": ["NodeStatus.process_info.process_name"]429 }430 ]431 }432 ]433 },434 "alarm_severity": 0,435 "fq_name": [436 "default-global-system-config",437 "system-defined-process-status"438 ],439 "id_perms": {440 "description": "Process Failure."441 },442 "parent_type": "global-system-config",443 "uve_keys": {444 "uve_key": [445 "analytics-node",446 "config-node",447 "control-node",448 "database-node",449 "vrouter"450 ]451 }452 },453 {454 "alarm_rules": {455 "or_list": [456 {457 "and_list": [458 {459 "operand1": "ContrailConfig.elements.virtual_router_refs",460 "operation": "!=",461 "operand2": {462 "json_value": "null"463 }464 },465 {466 "operand1": "ProuterData.connected_agent_list",467 "operation": "size!=",468 "operand2": {469 "json_value": "1"470 }471 }472 ]473 }474 ]475 },476 "alarm_severity": 1,477 "fq_name": [478 "default-global-system-config",479 "system-defined-prouter-connectivity"480 ],481 "id_perms": {482 "description": "Prouter connectivity to controlling tor agent does not exist we look for non-empty value for connected_agent_list"483 },484 "parent_type": "global-system-config",485 "uve_keys": {486 "uve_key": [487 "prouter"488 ]489 }490 },491 {492 "alarm_rules": {493 "or_list": [494 {495 "and_list": [496 {497 "operand1": "ContrailConfig.elements.virtual_router_refs",498 "operation": "!=",499 "operand2": {500 "json_value": "null"501 }502 },503 {504 "operand1": "ProuterData.tsn_agent_list",505 "operation": "size!=",506 "operand2": {507 "json_value": "1"508 }509 },510 {511 "operand1": "ProuterData.gateway_mode",512 "operation": "!=",513 "operand2": {514 "json_value": "\"SERVER\""515 }516 }517 ]518 },519 {520 "and_list": [521 {522 "operand1": "ContrailConfig.elements.virtual_router_refs",523 "operation": "!=",524 "operand2": {525 "json_value": "null"526 }527 },528 {529 "operand1": "ProuterData.tsn_agent_list",530 "operation": "size!=",531 "operand2": {532 "json_value": "0"533 }534 },535 {536 "operand1": "ProuterData.gateway_mode",537 "operation": "==",538 "operand2": {539 "json_value": "\"SERVER\""540 }541 }542 ]543 }544 ]545 },546 "alarm_severity": 1,547 "fq_name": [548 "default-global-system-config",549 "system-defined-prouter-tsn-connectivity"550 ],551 "id_perms": {552 "description": "Prouter connectivity to controlling tsn agent does not exist we look for non-empty value for tsn_agent_list"553 },554 "parent_type": "global-system-config",555 "uve_keys": {556 "uve_key": [557 "prouter"558 ]559 }560 },561 {562 "alarm_rules": {563 "or_list": [564 {565 "and_list": [566 {567 "operand1": "StorageCluster.info_stats.status",568 "operation": "!=",569 "operand2": {570 "json_value": "0"571 },572 "variables":573 ["StorageCluster.info_stats.health_summary"]574 }575 ]576 }577 ]578 },579 "alarm_severity": 1,580 "fq_name": [581 "default-global-system-config",582 "system-defined-storage-cluster-state"583 ],584 "id_perms": {585 "description": "Storage Cluster warning/errors."586 },587 "parent_type": "global-system-config",588 "uve_keys": {589 "uve_key": [590 "storage-cluster"591 ]592 }593 },594 {595 "alarm_rules": {596 "or_list": [597 {598 "and_list": [599 {600 "operand1": "VrouterAgent.down_interface_count",601 "operation": ">=",602 "operand2": {603 "json_value": "1"604 },605 "variables": ["VrouterAgent.error_intf_list",606 "VrouterAgent.no_config_intf_list"]607 }608 ]609 }610 ]611 },612 "alarm_severity": 1,613 "fq_name": [614 "default-global-system-config",615 "system-defined-vrouter-interface"616 ],617 "id_perms": {618 "description": "Vrouter interface(s) down."619 },620 "parent_type": "global-system-config",621 "uve_keys": {622 "uve_key": [623 "vrouter"624 ]625 }626 },627 {628 "alarm_rules": {629 "or_list": [630 {631 "and_list": [632 {633 "operand1": "BgpRouterState.num_up_xmpp_peer",634 "operation": "==",635 "operand2": {636 "json_value": "null"637 }638 }639 ]640 },641 {642 "and_list": [643 {644 "operand1": "BgpRouterState.num_up_xmpp_peer",645 "operation": "!=",646 "operand2": {647 "uve_attribute": "BgpRouterState.num_xmpp_peer"648 }649 }650 ]651 }652 ]653 },654 "alarm_severity": 1,655 "fq_name": [656 "default-global-system-config",657 "system-defined-xmpp-connectivity"658 ],659 "id_perms": {660 "description": "XMPP peer mismatch."661 },662 "parent_type": "global-system-config",663 "uve_keys": {664 "uve_key": [665 "control-node"666 ]667 }668 },669 {670 "alarm_rules": {671 "or_list": [672 {673 "and_list": [674 {675 "operand1": "NodeStatus.all_core_file_list",676 "operand2": {677 "json_value": "null"678 },679 "operation": "!="680 },681 {682 "operand1": "NodeStatus.all_core_file_list",683 "operand2": {684 "json_value": "0"685 },686 "operation": "size!="687 }688 ]689 }690 ]691 },692 "alarm_severity": 0,693 "fq_name": [694 "default-global-system-config",695 "system-defined-core-files"696 ],697 "id_perms": {698 "description": "A core file has been generated on the node."699 },700 "parent_type": "global-system-config",701 "uve_keys": {702 "uve_key": [703 "analytics-node",704 "config-node",705 "control-node",706 "database-node",707 "vrouter"708 ]709 }710 },711 {712 "alarm_rules": {713 "or_list": [714 {715 "and_list": [716 {717 "operand1": "CassandraStatusData.cassandra_compaction_task.pending_compaction_tasks",718 "operand2": {719 "json_value": "300"720 },721 "operation": ">="722 }723 ]724 }725 ]726 },727 "alarm_severity": 1,728 "fq_name": [729 "default-global-system-config",730 "system-defined-pending-cassandra-compaction-tasks"731 ],732 "parent_type": "global-system-config",733 "id_perms": {734 "description": "Pending compaction tasks in cassandra crossed the configured threshold."735 },736 "uve_keys": {737 "uve_key": [738 "database-node"739 ]740 }741 },742 {743 "alarm_rules": {744 "or_list": [745 {746 "and_list": [747 {748 "operand1": "NodeStatus.running_package_version",749 "operation": "!=",750 "operand2": {751 "uve_attribute": "NodeStatus.installed_package_version"752 }753 }754 ]755 }756 ]757 },758 "alarm_severity": 0,759 "fq_name": [760 "default-global-system-config",761 "system-defined-package-version-mismatch"762 ],763 "parent_type": "global-system-config",764 "id_perms": {765 "description": "There is a mismatch between installed and running package version."766 },767 "uve_keys": {768 "uve_key": [769 "analytics-node",770 "config-node",771 "control-node",772 "database-node",773 "vrouter"774 ]775 }776 }777]...

Full Screen

Full Screen

entities.py

Source:entities.py Github

copy

Full Screen

1import json2from json import JSONEncoder3class Record():4 def __init__(self, id=None, repo=None, commit_id=None, commit_message=None, label=None, json_value=None):5 # assert ((json is not None)6 # or (id is not None and commit_id is not None7 # and commit_message is not None)), "invalid Record construction"8 if json_value is not None:9 self.__dict__.update(json.loads(json_value))10 if self.commit is not None:11 self.commit = GithubCommit(json_value=json.dumps(self.commit))12 github_issue_list = []13 if self.github_issue_list is not None and len(self.github_issue_list) > 0:14 for github_issue_dict in self.github_issue_list:15 github_issue_list.append(GithubIssue(json_value=json.dumps(github_issue_dict)))16 self.github_issue_list = github_issue_list17 jira_ticket_list = []18 if self.jira_ticket_list is not None and len(self.jira_ticket_list) > 0:19 for jira_ticket_dict in self.jira_ticket_list:20 jira_ticket_list.append(JiraTicket(json_value=json.dumps(jira_ticket_dict)))21 self.jira_ticket_list = jira_ticket_list22 else:23 self.id = id24 self.repo = repo25 self.commit_id = commit_id26 self.commit_message = commit_message27 self.label = label28 self.jira_ticket_list = []29 self.github_issue_list = []30 self.commit = None31 self.branch = None32 self.issue_info = None33 self.code_terms = []34 self.text_terms_parts = []35 def __repr__(self):36 return "{}/commit/{}".format(self.repo, self.commit_id)37 def add_jira_ticket(self, jira_ticket):38 self.jira_ticket_list.append(jira_ticket)39 def add_github_ticket(self, github_issue):40 self.github_issue_list.append(github_issue)41 def set_commit(self, commit):42 self.commit = commit43class JiraTicket():44 def __init__(self, json_value=None, name=None, summary=None,45 description=None, created_at=None, creator=None, assignee=None,46 fix_versions=None, issue_type=None, priority=None,47 resolution=None, resolution_date=None, status=None, comments=None):48 assert ((json_value is not None) or (name is not None and49 summary is not None and created_at is not None50 and creator is not None)), "Invalid construction for JiraTicket"51 if json_value is not None:52 self.__dict__.update(json.loads(json_value))53 if self.fix_versions is not None:54 self.fix_versions = JiraTicketFixVersion(json_value=json.dumps(self.fix_versions))55 if self.issue_type is not None:56 self.issue_type = JiraTicketIssueType(json_value=json.dumps(self.issue_type))57 if self.priority is not None:58 self.priority = JiraTicketPriority(json_value=json.dumps(self.priority))59 if self.resolution is not None:60 self.resolution = JiraTicketResolution(json_value=json.dumps(self.resolution))61 if self.status is not None:62 self.status = JiraTicketStatus(json_value=json.dumps(self.status))63 comment_dict_list = self.comments64 comments = []65 for comment_dict in comment_dict_list:66 comment = JiraTicketComment(json_value=json.dumps(comment_dict))67 comments.append(comment)68 self.comments = comments69 else:70 # summary is title of jira ticket71 self.name = name72 self.summary = summary73 self.description = description74 self.created_at = created_at75 self.creator = creator76 self.assignee = assignee77 self.fix_versions = fix_versions78 self.issue_type = issue_type79 self.priority = priority80 self.resolution = resolution81 self.resolution_date = resolution_date82 self.status = status83 self.comments = comments84 self.code_terms = []85 self.text_terms_parts = []86 self.id = 087 def __repr__(self):88 return "Jira ticket: {} \n\n" \89 "description: {} \n\n" \90 " created at: {}".format(self.summary, self.description, self.created_at)91class JiraTicketPriority:92 def __init__(self, json_value=None, priority_id=None, priority_name=None):93 assert ((json_value is not None) or (priority_id is not None and priority_name is not None)), \94 "Invalid construction for JiraTicketPriority"95 if json_value is not None:96 self.__dict__.update(json.loads(json_value))97 else:98 self.priority_id = priority_id99 self.priority_name = priority_name100class JiraTicketFixVersion:101 def __init__(self, json_value=None, name=None, release_date=None):102 assert (json_value is not None or name is not None), \103 "Invalid construction for JiraTicketFixVersion"104 if json_value is not None:105 self.__dict__.update(json.loads(json_value))106 else:107 self.name = name108 self.release_date = release_date109class JiraTicketIssueType:110 def __init__(self, json_value=None, name=None, description=None):111 assert ((json_value is not None) or (name is not None and description is not None)), \112 "Invalid consturction for JiraTicketIssueType"113 if json_value is not None:114 self.__dict__.update(json.loads(json_value))115 else:116 self.name = name117 self.description = description118class JiraTicketStatus:119 def __init__(self, json_value=None, name=None, description=None, category=None):120 assert ((json_value is not None) or (name is not None and description is not None and category is not None)), \121 "Invalid construction for JiraTicketStatus"122 if json_value is not None:123 self.__dict__.update(json.loads(json_value))124 else:125 self.name = name126 self.description = description127 self.category = category128class JiraTicketResolution:129 def __init__(self, json_value=None, resolution_id=None, name=None, description=None):130 assert ((json_value is not None)131 or (resolution_id is not None and name is not None and description is not None)), \132 "Invalid construction for JiraTicketResolution"133 if json_value is not None:134 self.__dict__.update(json.loads(json_value))135 else:136 self.resolution_id = resolution_id137 self.name = name138 self.description = description139class JiraTicketComment:140 def __init__(self, json_value=None, created_by=None, body=None, created_at=None, updated_at=None):141 assert ((json_value is not None) or (body is not None and created_at is not None and updated_at is not None)), \142 "Invalid construction for JiraTicketComment"143 if json_value is not None:144 self.__dict__.update(json.loads(json_value))145 else:146 self.created_by = created_by147 self.body = body148 self.created_at = created_at149 self.update_at = updated_at150class GithubIssue():151 def __init__(self, json_value=None, title=None, body=None,152 author_name=None, created_at=None, closed_at=None, closed_by=None,153 last_modified=None, comments=None):154 if json_value is not None:155 self.__dict__.update(json.loads(json_value))156 comment_dict_list = self.comments157 comments = []158 for comment_dict in comment_dict_list:159 comments.append(GithubIssueComment(json_value=json.dumps(comment_dict)))160 self.comments = comments161 else:162 self.title = title163 self.body = body164 self.author_name = author_name165 self.created_at = created_at166 self.closed_at = closed_at167 self.closed_by = closed_by168 self.last_modified = last_modified169 self.comments = comments170 def __repr__(self):171 return "Github issue: " + self.title + ", created at " + self.created_at172class GithubIssueComment():173 def __init__(self, json_value=None, body=None, created_at=None, created_by=None, last_modified=None):174 if json_value is not None:175 self.__dict__.update(json.loads(json_value))176 else:177 self.body = body178 self.created_at = created_at179 self.created_by = created_by180 self.last_modified = last_modified181 def __repr__(self):182 return "Github issue comment at " + self.created_at + " :" + self.body183class GithubCommit:184 def __init__(self, json_value=None, author_name=None, created_date=None, files=None):185 # assert ((json_value is not None)186 # or (author_name is not None and187 # created_date is not None and files is not None)), "Invalid construction for GitHubCommit"188 if json_value is not None:189 self.__dict__.update(json.loads(json_value))190 commit_files = []191 for file in self.files:192 json_value = json.dumps(file)193 commit_file = GithubCommitFile(json_value=json_value)194 commit_files.append(commit_file)195 self.files = commit_files196 else:197 self.author_name = author_name198 self.created_date = created_date199 self.files = files200 def __repr__(self):201 return "Author: " + self.author_name + ", created date: " + self.created_date202# if file is binary, there will be no patch203class GithubCommitFile:204 def __init__(self, json_value=None, file_name=None, patch=None, status=None, additions=None, deletions=None,205 changes=None):206 # assert ((json_value is not None)207 # or (file_name is not None and status is not None208 # and deletions is not None and changes is not None)), "Invalid construction for GithubCommitFile"209 if json_value is not None:210 self.__dict__.update(json.loads(json_value))211 else:212 self.file_name = file_name213 self.patch = patch214 self.status = status215 self.additions = additions216 self.deletions = deletions217 self.changes = changes218 def __repr__(self):219 return "file name: " + self.file_name220class EntityEncoder(JSONEncoder):221 def default(self, o):222 if isinstance(o, Record) \223 or isinstance(o, GithubIssue) \224 or isinstance(o, JiraTicket) \225 or isinstance(o, JiraTicketResolution) \226 or isinstance(o, JiraTicketIssueType) \227 or isinstance(o, JiraTicketPriority) \228 or isinstance(o, JiraTicketFixVersion) \229 or isinstance(o, JiraTicketStatus) \230 or isinstance(o, JiraTicketComment) \231 or isinstance(o, GithubIssueComment) \232 or isinstance(o, GithubCommit) \233 or isinstance(o, GithubCommitFile):234 return o.__dict__235 else:...

Full Screen

Full Screen

facebook_json_creators.py

Source:facebook_json_creators.py Github

copy

Full Screen

1import helper_functions2def create_json(key,value):3 if key == 'list':4 return create_for_list(value)5 if key == 'generic_template':6 return create_for_generic(value)7 if key == 'boarding_pass':8 return create_for_boarding(value)9 if key == 'update':10 return create_for_update(value)11 if key == 'itinerary':12 return create_for_itinerary(value)13 if key == 'check_in':14 return create_for_checkin(value)15 if key == 'receipt':16 return create_for_receipt(value)17 else:18 pass19def create_for_receipt(value):20 json_value = {}21 json_value['message'] = {}22 json_value['message']['attachment'] = {}23 json_value['message']['attachment']['type'] = 'template'24 json_value['message']['attachment']['payload'] = {}25 json_value['message']['attachment']['payload']['template_type'] = 'receipt'26 json_value['message']['attachment']['payload']['summary'] = {}27 for i in ['shipping_cost','subtotal','total_cost','total_tax']:28 if i in value:29 json_value['message']['attachment']['payload']['summary'][i] = value[i]30 value.pop(i)31 for i in value:32 json_value['message']['attachment']['payload'][i] = value[i]33 return json_value34def create_for_checkin(value):35 json_value = {}36 json_value['message'] = {}37 json_value['message']['attachment'] = {}38 json_value['message']['attachment']['type'] = 'template'39 json_value['message']['attachment']['payload'] = {}40 json_value['message']['attachment']['payload']['template_type'] = 'airline_checkin'41 for i in ['locale','intro_message','pnr_number','checkin_url']:42 json_value['message']['attachment']['payload'][i] = value[i]43 json_value['message']['attachment']['payload']['flight_info'] = value['flight_info']44 return json_value45def create_for_itinerary(value):46 json_value = {}47 json_value['message'] = {}48 json_value['message']['attachment'] = {}49 json_value['message']['attachment']['type'] = 'template'50 json_value['message']['attachment']['payload'] = {}51 json_value['message']['attachment']['payload']['template_type'] = 'airline_itinerary'52 for i in ['locale','intro_message','pnr_number']:53 json_value['message']['attachment']['payload'][i] = value[i]54 b = []55 for i in value['passengers']:56 y = {}57 for j in i:58 y[j] = i[j]59 b.append(y)60 json_value['message']['attachment']['payload']['passenger_info'] = b61 return json_value62def create_for_update(value):63 json_value = {}64 json_value['message'] = {}65 json_value['message']['attachment'] = {}66 json_value['message']['attachment']['type'] = 'template'67 json_value['message']['attachment']['payload'] = {}68 json_value['message']['attachment']['payload']['template_type'] = 'airline_update'69 for i in ['locale','intro_message','pnr_number','update_type']:70 json_value['message']['attachment']['payload'][i] = value[i]71 json_value['message']['attachment']['payload']['update_flight_info'] = {}72 for i in ['departure_airport','arrival_airport','flight_number']:73 json_value['message']['attachment']['payload']['update_flight_info'][i] = value[i]74 json_value['message']['attachment']['payload']['update_flight_info']['flight_schedule'] = {}75 for i in ['boarding_time','arrival_time','departure_time']:76 json_value['message']['attachment']['payload']['update_flight_info']['flight_schedule'][i] = value[i]77 return json_value78def create_for_boarding(value):79 json_value = {}80 json_value['message'] = {}81 json_value['message']['attachment'] = {}82 json_value['message']['attachment']['type'] = 'template'83 json_value['message']['attachment']['payload'] = {}84 json_value['message']['attachment']['payload']['template_type'] = 'airline_boardingpass'85 passengers = []86 for i in value['passengers']:87 kk = {}88 kk['arrival_airport'] = {}89 kk['arrival_airport']['city'] = i['arrival_airport']['city']90 kk['arrival_airport']['airport_code'] = i['arrival_airport']['airport_code']91 kk['departure_airport'] = {}92 kk['departure_airport']['city'] = i['departure_airport']['city']93 kk['departure_airport']['airport_code'] = i['departure_airport']['airport_code']94 for ui in i:95 kk[ui] = i[ui]96 if not ('qr_code' in i or 'above_bar_code_image_url' in i):97 return 'check qr_code and barcode'98 passengers.append(kk)99 json_value['message']['attachment']['payload']['passengers'] = passengers100 for i in ['intro_message','locale']:101 json_value['message']['attachment']['payload'][i] = value[i]102 return json_value103def create_for_generic(value):104 json_value = {}105 json_value['message'] = {}106 json_value['message']['attachment'] = {}107 json_value['message']['attachment']['type'] = 'template'108 json_value['message']['attachment']['payload'] = {}109 json_value['message']['attachment']['payload']['template_type'] = 'generic'110 d = []111 for i in value['elements']:112 temp = {}113 if 'image_url' in i:114 temp['image_url'] = i['image_url']115 if 'subtitle' in i:116 temp['subtitle'] = i['subtitle']117 temp['title'] = i['title']118 b = []119 for j in i['button']:120 b.append(create_for_button(j))121 temp['buttons'] = b122 d.append(temp)123 json_value['message']['attachment']['payload']['elements'] = d124 return json_value125def create_for_list(value):126 json_value = {}127 json_value['message'] = {}128 json_value['message']['attachment'] = {}129 json_value['message']['attachment']['type'] = 'template'130 json_value['message']['attachment']['payload'] = {}131 json_value['message']['attachment']['payload']['template_type'] = 'list'132 d = []133 for i in value['elements']:134 temp = {}135 if 'image_url' in i:136 temp['image_url'] = i['image_url']137 if 'subtitle' in i:138 temp['subtitle'] = i['subtitle']139 temp['title'] = i['title']140 temp['buttons'] = [create_for_button(i['button'])]141 d.append(temp)142 json_value['message']['attachment']['payload']['elements'] = d143 json_value['message']['attachment']['payload']['buttons'] = [create_for_button(value['button'])]144 return json_value145def create_for_button(value):146 ret = {}147 if value['type'] == 'web_url':148 ui = ['type','url','subtitle','fallback_url']149 for i in ui:150 if i in value:151 ret[i] = value[i]152 if value['type'] == 'postback':153 ui = ['type','title','payload']154 for i in ui:155 ret[i] = value[i]156 if value['type'] == 'element_share':157 ret['type'] = value['type']...

Full Screen

Full Screen

integration_models.py

Source:integration_models.py Github

copy

Full Screen

...11 template_name = 'coderedcms/formfields/mailchimp/subscriber_integration_widget.html'12 js_template_name = 'coderedcms/formfields/mailchimp/subscriber_integration_js.html'13 def get_context(self, name, value, attrs):14 ctx = super(MailchimpSubscriberIntegrationWidget, self).get_context(name, value, attrs)15 json_value = self.get_json_value(value)16 list_library = self.build_list_library()17 ctx['widget']['value'] = json.dumps(json_value)18 ctx['widget']['extra_js'] = self.render_js(name, list_library, json_value)19 ctx['widget']['selectable_mailchimp_lists'] = self.get_selectable_mailchimp_lists(20 list_library)21 ctx['widget']['stored_mailchimp_list'] = self.get_stored_mailchimp_list(json_value)22 return ctx23 def render_js(self, name, list_library, json_value):24 ctx = {25 'widget_name': name,26 'widget_js_name': name.replace('-', '_'),27 'list_library': list_library,28 'stored_mailchimp_list': self.get_stored_mailchimp_list(json_value),29 'stored_merge_fields': self.get_stored_merge_fields(json_value),30 }31 return render_to_string(self.js_template_name, ctx)32 def get_json_value(self, value):33 if value:34 json_value = json.loads(value)35 else:36 json_value = json.loads('{}')37 if 'list_id' not in json_value:38 json_value['list_id'] = ""39 if 'merge_fields' not in json_value:40 json_value['merge_fields'] = {}41 if 'email_field' not in json_value:42 json_value['email_field'] = ""43 if 'interest_categories' not in json_value:44 json_value['interest_categories'] = {}45 return json_value46 def get_stored_mailchimp_list(self, value):...

Full Screen

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Python 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