How to use str_vol method in tempest

Best Python code snippet using tempest_python

test_volumes_list.py

Source:test_volumes_list.py Github

copy

Full Screen

...31 def assertVolumesIn(self, fetched_list, expected_list):32 missing_vols = [v for v in expected_list if v not in fetched_list]33 if len(missing_vols) == 0:34 return35 def str_vol(vol):36 return "%s:%s" % (vol['id'], vol['display_name'])37 raw_msg = "Could not find volumes %s in expected list %s; fetched %s"38 self.fail(raw_msg % ([str_vol(v) for v in missing_vols],39 [str_vol(v) for v in expected_list],40 [str_vol(v) for v in fetched_list]))41 @classmethod42 def setUpClass(cls):43 super(VolumesListTest, cls).setUpClass()44 cls.client = cls.volumes_client45 # Create 3 test volumes46 cls.volume_list = []47 cls.volume_id_list = []48 for i in range(3):49 v_name = data_utils.rand_name('volume')50 metadata = {'Type': 'work'}51 try:52 resp, volume = cls.client.create_volume(size=1,53 display_name=v_name,54 metadata=metadata)...

Full Screen

Full Screen

volume.py

Source:volume.py Github

copy

Full Screen

1import pymysql2import datetime3import random4import time5from requests import get6import json7import pandas as pd8import sqlalchemy9import threading10# import matplotlib.pyplot as plt11class volume:12 def __init__(self):13 print('init_volume')14 # self.makedata_dfcf()15 self.t = threading.Thread(target=self.loop)16 self.t.setDaemon(True)17 self.t.start()18 def loop(self):19 while True:20 self.makedata_dfcf()21 time.sleep(15)22 def makedata(self):23 # http://quote.eastmoney.com/stock_list.html24 # http://img1.money.126.net/data/hs/kline/day/history/2020/0600795.json25 url = "http://img1.money.126.net/data/hs/time/4days/0000016.json"26 pf_volume = pd.DataFrame()27 try:28 data = get(url).json()['data']29 for i in range(4):30 oneday = data[i]['data']31 list_day =[]32 for k in range(len(oneday)):33 onemin = oneday[k][3] 34 list_day.append(onemin)35 pf_volume[i] = list_day36 #print(pf_volume)37 except:38 pass 39 pf_volume['Col_sum'] = pf_volume.apply(lambda x: x.sum()/4, axis=1)40 pf_volume['sum'] = pf_volume['Col_sum'].cumsum()41 42 43 url = 'http://img1.money.126.net/data/hs/time/today/0000016.json'44 pf_today = pd.DataFrame()45 try:46 data = get(url).json()['data']47 list_day =[]48 for k in range(len(data)):49 onemin = data[k][3] 50 list_day.append(onemin)51 except:52 print('erorr')53 pass 54 55 df_today = pd.DataFrame(list_day, columns=['today'])56 df_today = df_today.cumsum()57 58 df_all = pd.concat([pf_volume,df_today],axis =1)59 df_all['chu']= df_all['today']/df_all['sum']60 df_sql = pd.DataFrame()61 df_sql['id'] = df_all.index62 df_sql['volume'] = df_all['chu']63 print(df_sql)64 print('---------------------------------')65 engine = sqlalchemy.create_engine('mysql+pymysql://root:root@localhost/option_data?charset=utf8')66 df_sql.to_sql('volume', engine, index=False, if_exists='replace')67 def makedata_dfcf(self):68 pf_volume = pd.DataFrame()69 url = 'http://push2his.eastmoney.com/api/qt/stock/trends2/get?secid=1.000016&fields1=f1%2Cf2%2Cf3%2Cf4%2Cf5%2Cf6%2Cf7%2Cf8%2Cf9%2Cf10%2Cf11&fields2=f51%2Cf53%2Cf56%2Cf58&iscr=0&ndays=5'70 data =[]71 try:72 data = get(url).json()['data']['trends']73 print(len(data))74 except:75 pass76 lengh = len(data)77 arr = []78 for i in range(241):79 arr.append(0) 80 for i in range(4): 81 list_day =[]82 for j in range(0,241):83 #print(data[241*i+j].split(' ')[1].split(',')[2])84 str_vol = data[241*i+j].split(' ')[1].split(',')[2]85 int_vol = int(str_vol)86 arr[j] = arr[j]+int_vol87 list_day.append(int_vol)88 # print(int_vol)89 pf_volume[i] = list_day 90 # print(arr)91 92 pf_volume['Col_sum'] = pf_volume.apply(lambda x: x.sum()/4, axis=1)93 today_list = []94 for i in range(241*4,241*5):95 int_vol= 096 if(i<lengh):97 str_vol = data[i].split(' ')[1].split(',')[2]98 int_vol = int(str_vol)99 today_list.append(int_vol)100 print(today_list)101 pf_volume['today'] = today_list102 pf_volume= pf_volume.cumsum()103 print(pf_volume)104 pf_volume['res'] = pf_volume['today'] / pf_volume['Col_sum']105 # pf_volume['res'].plot()106 # print(pf_volume)107 # plt.show()108 df_sql = pd.DataFrame()109 df_sql['id'] = pf_volume.index110 df_sql['volume'] = pf_volume['res']111 112 # print(df_sql)113 engine = sqlalchemy.create_engine('mysql+pymysql://root:root@localhost/option_data?charset=utf8')114 df_sql.to_sql('volume', engine, index=False, if_exists='replace')115 #http://push2.eastmoney.com/api/qt/stock/trends2/get?secid=1.000016&fields1=f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13&fields2=f51,f52,f53,f54,f55,f56,f57,f58&ut=fa5fd1943c7b386f172d6893dbfba10b116if __name__ == '__main__':117 volume()...

Full Screen

Full Screen

zy.py

Source:zy.py Github

copy

Full Screen

1def split_value(day_rang, idx):2 arr = [x for x in day_rang.split(" - ")]3 return arr[idx]4def replace_vol(str_vol):5 arr = str_vol.split(".")6 digits = len(arr[1])7 if 'M' in arr[1]:8 if digits == 4:9 return float(str_vol.replace('.', '').replace('M', '000'))10 if digits == 3:11 return float(str_vol.replace('.', '').replace('M', '0000'))12 if digits == 2:13 return float(str_vol.replace('.', '').replace('M', '00000'))14 elif 'K' in arr[1]:15 if digits == 3:16 return float(str_vol.replace('.', '').replace('K', '0'))17 if digits == 2:18 return float(str_vol.replace('.', '').replace('K', '00'))19 else:20 if digits == 2:21 return float(str_vol.replace('.', '') + '0')22 if digits == 1:23 return float(str_vol.replace('.', '') + '00')24vol_m = '28.03M' # 28 030 10925vol_k = '675.08K' # 675 08026vol_k1 = '25.7K' # 25 70027vol_1 = '675.08' # 675 08028vol_2 = '25.7' # 25 700...

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