How to use delete_token method in tempest

Best Python code snippet using tempest_python

run_total_process_data.py

Source:run_total_process_data.py Github

copy

Full Screen

1import subprocess2import pickle3import math4import json5import time6import os7from tqdm import tqdm 8def process():9 difftokens = json.load(open('../DataSet/difftoken.json'))10 diffmarks = json.load(open('../DataSet/diffmark.json'))11 processed_tokens = []12 processed_types = []13 for i, tokens in enumerate(tqdm(difftokens)):14 15 marks = diffmarks[i]16 state = '<start>'17 18 processed_token = []19 processed_type = []20 delete_token = []21 add_token = []22 normal_token = []23 j = 024 while j < len(tokens):25 token = tokens[j]26 mark = marks[j]27 28 if token == '<nb>':29 if state == 0:30 assert normal_token31 processed_token.append(normal_token)32 processed_type.append(0)33 elif state == -1:34 assert delete_token35 processed_token.append(delete_token)36 processed_type.append(-1)37 elif state == 1:38 assert add_token39 if delete_token == []:40 processed_token.append(add_token)41 processed_type.append(1)42 else:43 processed_token.append([delete_token, add_token])44 processed_type.append(100)45 assert mark == 246 47 end_nb = tokens[j:].index('<nl>') + j48 for jj in range(j, end_nb + 1):49 assert marks[jj] == 250 processed_token.append(tokens[j:end_nb + 1])51 processed_type.append(0)52 53 state = '<start>'54 delete_token = []55 add_token = []56 normal_token = []57 j = end_nb + 158 continue59 if state == '<start>':60 if mark == 1:61 delete_token.append(token)62 state = -163 elif mark == 3:64 add_token.append(token)65 state = 166 elif mark == 2:67 normal_token.append(token)68 state = 069 elif state == 0:70 if mark == 1:71 processed_token.append(normal_token)72 processed_type.append(0)73 normal_token = []74 delete_token.append(token)75 state = -176 elif mark == 3:77 processed_token.append(normal_token)78 processed_type.append(0)79 normal_token = []80 add_token.append(token)81 state = 182 elif mark == 2:83 normal_token.append(token)84 state = 085 elif state == -1:86 if mark == 1:87 delete_token.append(token)88 state = -189 elif mark == 3:90 add_token.append(token)91 state = 192 elif mark == 2:93 processed_token.append(delete_token)94 processed_type.append(-1)95 delete_token = []96 normal_token.append(token)97 state = 098 elif state == 1:99 if mark == 1:100 if delete_token == []:101 processed_token.append(add_token)102 processed_type.append(1)103 add_token = []104 delete_token.append(token)105 state = -1106 else:107 processed_token.append([delete_token, add_token])108 processed_type.append(100)109 delete_token = []110 add_token = []111 delete_token.append(token)112 state = -1113 elif mark == 3:114 add_token.append(token)115 state = 1116 elif mark == 2:117 if delete_token == []:118 processed_token.append(add_token)119 processed_type.append(1)120 add_token = []121 normal_token.append(token)122 state = 0123 else:124 processed_token.append([delete_token, add_token])125 processed_type.append(100)126 delete_token = []127 add_token = []128 normal_token.append(token)129 state = 0130 j += 1131 if state == 0:132 assert normal_token133 processed_token.append(normal_token)134 processed_type.append(0)135 elif state == -1:136 assert delete_token137 processed_token.append(delete_token)138 processed_type.append(-1)139 elif state == 1:140 assert add_token141 if delete_token == []:142 processed_token.append(add_token)143 processed_type.append(1)144 else:145 processed_token.append([delete_token, add_token])146 processed_type.append(100)147 processed_tokens.append(processed_token)148 processed_types.append(processed_type)149 150 pickle.dump(processed_tokens, open('processed_tokens.pkl', 'wb'))151 pickle.dump(processed_types, open('processed_types.pkl', 'wb'))152if __name__ == '__main__':153 if not os.path.exists('processed_tokens.pkl'):154 process()155 all_num = len(pickle.load(open('processed_tokens.pkl', 'rb')))156 jobs = []157 max_num = 100158 each_num = 100159 for i in range(math.ceil(all_num / each_num)):160 while True:161 run_num = 0 162 for x in jobs:163 if x.poll() is None:164 run_num += 1165 if run_num < max_num:166 break167 time.sleep(1)168 start = i * each_num169 end = min((i + 1) * each_num, all_num)170 p = subprocess.Popen("python process_data_ast_parallel.py %d %d"%(start, end), shell=True)171 jobs.append(p)172 time.sleep(1)173 for job in jobs:...

Full Screen

Full Screen

api_token.py

Source:api_token.py Github

copy

Full Screen

1"""Module for Binary api_token websocket channel."""2from binaryapi.ws.chanels.base import Base3from typing import Any, List, Optional4# https://developers.binary.com/api/#api_token5class ApiToken(Base):6 """Class for Binary api_token websocket channel."""7 name = "api_token"8 def __call__(9 self, 10 delete_token: Optional[str] = None, 11 new_token: Optional[str] = None, 12 new_token_scopes: Optional[List] = None, 13 valid_for_current_ip_only: Optional[int] = None, 14 passthrough: Optional[Any] = None, 15 req_id: Optional[int] = None16 ) -> int:17 """Method to send message to api_token websocket channel.18 API Token (request)19 This call manages API tokens20 :param delete_token: [Optional] The token to remove.21 :type delete_token: Optional[str]22 :param new_token: [Optional] The name of the created token.23 :type new_token: Optional[str]24 :param new_token_scopes: [Optional] List of permission scopes to provide with the token.25 :type new_token_scopes: Optional[List]26 :param valid_for_current_ip_only: [Optional] If you set this parameter during token creation, then the token created will only work for the IP address that was used to create the token27 :type valid_for_current_ip_only: Optional[int]28 :param passthrough: [Optional] Used to pass data through the websocket, which may be retrieved via the `echo_req` output field.29 :type passthrough: Optional[Any]30 :param req_id: [Optional] Used to map request to response.31 :type req_id: Optional[int]32 :returns: req_id33 :rtype: int34 """35 data = {36 "api_token": int(1)37 }38 if delete_token:39 data['delete_token'] = str(delete_token)40 if new_token:41 data['new_token'] = str(new_token)42 if new_token_scopes:43 data['new_token_scopes'] = new_token_scopes44 if valid_for_current_ip_only:45 data['valid_for_current_ip_only'] = int(valid_for_current_ip_only)...

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