def main(): # Start the thread, this is responsible for getting data and posting to db stop_event = threading.Event() thread = threading.Thread(target=pull_data, args=(stop_event, )) thread.daemon = True # Daemonize thread thread.start() # Start the execution db_read = MySQLConnector() days_data = CommonClass() field = "high,timestamp".split(",") data_list = db_read.readFromDB(table="btceur", fieldList=field) # Set the days to 7 days = 7 # The zip() function returns an iterator of tuples based on the iterable object. returned_data = days_data.length_of_data(data_list, days) if returned_data is None: print("We do not have 7 days worth of data!") else: btceur_high, btceur_timestamp = zip(*returned_data) #btceur_high, btceur_timestamp = zip(*days_data.seven_days(data_list, days)) plotter = Graph() plotter.firstPlot(btceur_high, btceur_timestamp)
def setUpClass(self): self.tchmd5psw = CommonClass()._md5('123456') # 管理员账号密码 self.tchname = '27717' self.token = CommonClass().getpadtoken(self.tchname, self.tchmd5psw) # self.token = '6cb42a26500049bc98d28689d5fc0137' self.headers = { 'token': self.token, 'userid': self.tchname, 'User-Agent': 'okhttp/3.6.0'}
def setUpClass(self): self.admd5psw = CommonClass()._md5('slothtekadmin') # 管理员账号密码 self.adname = '19221' self.token = CommonClass().getwebtoken(self.adname, self.admd5psw)[0] self.adheaders = { 'Content-Type': 'application/json;charset=UTF-8', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36', 'Cookie': 'userId=%s;token=%s' % (self.adname, self.token) }
def setUpClass(self): self.stumd5psw = CommonClass()._md5('111111') # 账号密码 self.tchname = '27819' self.token = CommonClass().getpadtoken(self.tchname, self.stumd5psw) # self.token = '6cb42a26500049bc98d28689d5fc0137' self.headers = { 'token': self.token, 'userid': self.tchname, 'Content-Type': 'application/json;charset=UTF-8', 'User-Agent': 'okhttp/3.6.0' }
def test_11(self): # v1/user/info 学生 ''' v1/user/info 学生''' token = CommonClass().getpadtoken(self.stuname, self.stumd5psw) url = 'http://bip.slothtek.com/api/v1/user/info' headers = {'userid': self.stuname, 'token': token, 'User-Agent': 'okhttp/3.6.0'} result = requests.session().get(url=url, headers=headers) print(result.text) print(url) self.assertEqual(result.json()['code'], 200)
def suite(): start_dir = os.getcwd() print(start_dir) suite = unittest.defaultTestLoader.discover(start_dir=start_dir, pattern='*test.py', top_level_dir=None) return suite if __name__ == '__main__': localtime = time.localtime(time.time()) now = str(localtime.tm_year) + '.' + str(localtime.tm_mon) + '.' + str( localtime.tm_mday) + '.' + str(localtime.tm_hour) + '.' + str( localtime.tm_min) reportpath = os.path.join(os.getcwd(), r"report") reportname = os.path.join(reportpath, now + "Regression-test-report.html") fp = open(reportname, 'wb') fpp = open(reportname, 'rb').read() runner = HTMLTestRunnerCN.HTMLTestReportCN( stream=fp, title='{ SL_Test_Report }', # description='', description="wq") suite = suite() runner.run(suite) fp.close() time.sleep(1) CommonClass().sendemail(reportname)