Best Python code snippet using autotest_python
status.py
Source:status.py
1# coding:utf-82# --author-- lanhua.zhou3from __future__ import print_function4import datetime5from . import _Entity6import zfused_api7def new_project_status(project_id, entity_type, status_id, active = "true"):8 """ create peoject status9 """10 _current_time = "%s+00:00"%datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S")11 # asset is exists12 _status = zfused_api.zFused.get( "project_status", 13 filter = { "ProjectId": project_id, 14 "Object": entity_type,15 "StatusId": status_id })16 if _status:17 return "project status id {} is exists".format(status_id), False18 _create_by_id = zfused_api.zFused.USER_ID19 _value, _status = zfused_api.zFused.post( key = "project_status", 20 data = { "ProjectId": project_id,21 "StatusId": status_id,22 "Object": entity_type,23 "Active": active,24 "CreatedBy": _create_by_id,25 "CreatedTime": _current_time } )26 if _status:27 return _value["Id"], True28 return "project status id create error", False29def active_status():30 """31 è·åæ¿æ´»å¯å¶ä½çä»»å¡32 """33 _active_status = zfused_api.zFused.get("status", filter = {"IsActive":1}, sortby = ["Sort"], order = ["asc"])34 if _active_status:35 return [Status(_status["Id"]) for _status in _active_status]36 return []37def active_status_ids():38 """39 è·åæ¿æ´»å¯å¶ä½çä»»å¡40 """41 _active_status = zfused_api.zFused.get("status", filter = {"IsActive":1}, sortby = ["Sort"], order = ["asc"])42 if _active_status:43 return [_status["Id"] for _status in _active_status]44 return []45def working_status():46 """47 è·åå¶ä½ä¸çç¶ææ ç¾48 """49 _working_status = zfused_api.zFused.get("status", filter = {"IsWorking":1}, sortby = ["Sort"], order = ["asc"])50 if _working_status:51 return [Status(_status["Id"]) for _status in _working_status]52 return []53def working_status_ids():54 """55 è·åå¶ä½ä¸çç¶æid56 """57 _woking_status = zfused_api.zFused.get("status", filter = {"IsWorking":1}, sortby = ["Sort"], order = ["asc"])58 if _woking_status:59 return [_status["Id"] for _status in _woking_status]60 return []61def waiting_status():62 """ è·åçå¾
ä»»å¡63 """64 _waiting_status = zfused_api.zFused.get("status", filter = {"IsWaiting":1}, sortby = ["Sort"], order = ["asc"])65 if _waiting_status:66 return [Status(_status["Id"]) for _status in _waiting_status]67 return []68def waiting_status_ids():69 """ è·åçå¾
ä»»å¡id70 """71 _waiting_status = zfused_api.zFused.get("status", filter = {"IsWaiting":1}, sortby = ["Sort"], order = ["asc"])72 if _waiting_status:73 return [_status["Id"] for _status in _waiting_status]74 return []75def final_status():76 """ è·åå®ç»ç¶æ77 """78 _final_status = zfused_api.zFused.get("status", filter = {"IsFinal":1}, sortby = ["Sort"], order = ["asc"])79 if _final_status:80 return [Status(_status["Id"]) for _status in _final_status]81 return []82def final_status_ids():83 """ è·åå®ç»ç¶æ84 """85 _final_status = zfused_api.zFused.get("status", filter = {"IsFinal":1}, sortby = ["Sort"], order = ["asc"])86 if _final_status:87 return [_status["Id"] for _status in _final_status]88 return []89def done_status_ids():90 """ è·åå®ç»ç¶æ91 """ 92 _final_status = zfused_api.zFused.get("status", filter = {"Category":"done"}, sortby = ["Sort"], order = ["asc"])93 if _final_status:94 return [_status["Id"] for _status in _final_status]95 return []96def review_status():97 """ è·åå®ç»ç¶æ98 """99 _final_status = zfused_api.zFused.get("status", filter = {"IsReview":1}, sortby = ["Sort"], order = ["asc"])100 if _final_status:101 return [Status(_status["Id"]) for _status in _final_status]102 return []103def review_status_ids():104 """ è·åå®ç»ç¶æ105 """106 _final_status = zfused_api.zFused.get("status", filter = {"IsReview":1}, sortby = ["Sort"], order = ["asc"])107 if _final_status:108 return [_status["Id"] for _status in _final_status]109 return []110def approval_status():111 """ è·åå®ç»ç¶æ112 """113 _final_status = zfused_api.zFused.get("status", filter = {"IsApproval":1}, sortby = ["Sort"], order = ["asc"])114 if _final_status:115 return [Status(_status["Id"]) for _status in _final_status]116 return []117def approval_status_ids():118 """ è·åå®ç»ç¶æ119 """120 _final_status = zfused_api.zFused.get("status", filter = {"IsApproval":1}, sortby = ["Sort"], order = ["asc"])121 if _final_status:122 return [_status["Id"] for _status in _final_status]123 return []124def status_ids():125 """126 è·åææç¶æid127 """128 _status = zfused_api.zFused.get("status", sortby = ["Sort"], order = ["asc"])129 if _status:130 return [_statu["Id"] for _statu in _status]131 return []132def cache_from_ids(status_ids = []):133 status_ids = [str(_status_id) for _status_id in status_ids]134 _status = zfused_api.zFused.get("status", filter = {"Id__in": "|".join(status_ids)}, sortby = ["Sort"], order = ["asc"])135 if _status:136 return _status137 return []138class Status(_Entity):139 global_dict = {}140 def __init__(self, entity_id, entity_data = None):141 super(Status, self).__init__("status", entity_id, entity_data)142# class Status(zfused_api.zFused):143# global_dict = {}144# def __init__(self, id, data = None):145# self._id = id146# self._data = data147 if not self.global_dict.__contains__(self._id) or zfused_api.zFused.RESET:148 if self._data:149 self.global_dict[self._id] = self._data150 else:151 _data = self.get_one("status", self._id)152 if not _data:153 logger.error("status id {0} not exists".format(self._id))154 return155 self._data = _data156 self.global_dict[self._id] = _data157 else:158 if self._data:159 self.global_dict[self._id] = self._data160 else:161 self._data = self.global_dict[self._id]162 def full_code(self):163 """164 get full path code165 rtype: str166 """167 return self._data["Code"]168 def full_name(self):169 """170 get full path name171 rtype: str172 """173 return self._data["Name"]174 def full_name_code(self):175 """176 get full path name and code177 rtype: str178 """179 return u"{}({})".format(self.full_name(), self.full_code())180 def color(self):181 """ return project color182 """183 return self._data["Color"]184 def sort(self):185 return self._data["Sort"]186 def category(self):...
LogHelper.py
Source:LogHelper.py
...27 self._logs[stack_index] = {}28 if template_type not in self._logs[stack_index]:29 self._logs[stack_index][template_type] = ""30 self._logs[stack_index][template_type] = ("(" + stack_name + ") - "+log)31 def set_final_status(self, result):32 self._final_status = result33 def print_result(self):34 print("----------------------------------- Completed -----------------------------------")35 stack_indexes = self._logs.keys()36 for index in stack_indexes:37 print(" {} : \n".format(index))38 stack_types = self._logs[index].keys()39 for stack_type in stack_types:40 if stack_type and self._logs[index][stack_type]:41 print(" - ["+stack_type+"]" + self._logs[index][stack_type])42 print(self._final_status)...
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!!