How to use test_sdk_version method in Airtest

Best Python code snippet using Airtest

heartbeat.py

Source:heartbeat.py Github

copy

Full Screen

1from lib.platform.dataprocess.spark_compute.test_data import *2from lib.platform.dataprocess.spark_compute.commontool.timestamp_conversion import *3import random4import os5class Heartbeat(object):6 def make_data(self, hour=''):7 data_format = '%s\x1f%s\x1f%s\x1f%s\x1f%s\x1f%s\x1f%s\x1f%s\x1f%s\x1f%s\x1f%s\x1f%s\n'8 with open(os.path.abspath(os.path.dirname(__file__)) + '/heartbeat.txt', 'w') as writer:9 if hour == '':10 for hour in range(24):11 for minute in range(60):12 topic = 'topic=' + 'heartbeat'13 id = "id=" + test_file_id[random.randint(0, len(test_file_id) - 1)] + ":" + str(14 random.randint(1000, 1000000))15 timestamp = 'timestamp=' + str(16 TimestampConversion.get_timestamp(test_day + '%02d' % hour + '%02d' % minute))17 input_time = 'input_time=' + str(long(timestamp.split('=')[1]) + 300)18 output_time = 'output_time=' + str(long(timestamp.split('=')[1]) + 600)19 peer_id = 'peer_id=' + test_peer_id[random.randint(0, len(test_peer_id) - 1)]20 sdk_version = 'sdk_version=' + test_sdk_version[random.randint(0, len(test_sdk_version) - 1)]21 nat_type = 'nat_type=' + str(random.randint(1, 4))22 public_ip = 'public_ip=' + '10.5.100.1'23 public_port = 'public_port=' + '8888'24 private_ip = 'private_ip=' + '192.168.1.110'25 private_port = 'private_port=' + '8080'26 writer.write(data_format % (topic, id, timestamp, input_time, output_time, peer_id, sdk_version,27 nat_type, public_ip, public_port, private_ip, private_port))28 else:29 for minute in range(60):30 topic = 'topic=' + 'heartbeat'31 id = "id=" + test_file_id[random.randint(0, len(test_file_id) - 1)] + ":" + str(32 random.randint(1000, 1000000))33 timestamp = 'timestamp=' + str(34 TimestampConversion.get_timestamp(test_day + '{:0>2}'.format(hour) + '%02d' % minute))35 input_time = 'input_time=' + str(long(timestamp.split('=')[1]) + 300)36 output_time = 'output_time=' + str(long(timestamp.split('=')[1]) + 600)37 peer_id = 'peer_id=' + test_peer_id[random.randint(0, len(test_peer_id) - 1)]38 sdk_version = 'sdk_version=' + test_sdk_version[random.randint(0, len(test_sdk_version) - 1)]39 nat_type = 'nat_type=' + str(random.randint(1, 4))40 public_ip = 'public_ip=' + '123.56.1.110'41 public_port = 'public_port=' + '8888'42 private_ip = 'private_ip=' + '192.168.1.110'43 private_port = 'private_port=' + '8080'44 writer.write(data_format % (topic, id, timestamp, input_time, output_time, peer_id, sdk_version,45 nat_type, public_ip, public_port, private_ip, private_port))46if __name__ == '__main__':47 hb = Heartbeat()...

Full Screen

Full Screen

seed_flow.py

Source:seed_flow.py Github

copy

Full Screen

1import os2import random3from lib.platform.dataprocess.spark_compute.commontool.timestamp_conversion import TimestampConversion4from lib.platform.dataprocess.spark_compute.test_data import *5class SeedFlow(object):6 def make_data(self, hour=''):7 data_format = '%s\x1f%s\x1f%s\x1f%s\x1f%s\x1f%s\x1f%s\x1f%s\x1f%s\x1f%s\x1f%s\n'8 with open(os.path.abspath(os.path.dirname(__file__)) + '/seed_flow.txt', 'w') as writer:9 if hour == '':10 for hour in range(24):11 for minute in range(60):12 topic = "topic=" + "seed_flow"13 public_ip = 'public_ip=' + '10.5.100.1'14 sdk_agent_name = 'sdk_agent_name=' + 'YunshangSDK'15 sdk_agent_version = 'sdk_agent_version=' + test_sdk_version[random.randint(0, len(test_sdk_version) - 1)]16 timestamp = 'timestamp=' + str(17 TimestampConversion.get_timestamp(test_day + '{:0>2}'.format(hour) + '%02d' % minute))18 id = "id=" + test_file_id[random.randint(0, len(test_file_id) - 1)] + ":" + str(19 random.randint(1000, 1000000))20 peer_id = 'peer_id=' + test_peer_id[random.randint(0, len(test_peer_id) - 1)]21 file_id = 'file_id=' + test_file_id[random.randint(0, len(test_file_id) - 1)]22 file_type = 'file_type=' + 'live'23 upload = 'upload=' + str(random.randint(100000, 900000))24 download = 'download=' + str(random.randint(500000, 1000000))25 writer.write(data_format % (topic, public_ip, sdk_agent_name, sdk_agent_version, timestamp, id,26 peer_id, file_id, file_type, upload, download))27 else:28 for minute in range(60):29 topic = "topic=" + "seed_flow"30 public_ip = 'public_ip=' + '10.5.100.1'31 sdk_agent_name = 'sdk_agent_name=' + 'YunshangSDK'32 sdk_agent_version = 'sdk_agent_version=' + test_sdk_version[33 random.randint(0, len(test_sdk_version) - 1)]34 timestamp = 'timestamp=' + str(35 TimestampConversion.get_timestamp(test_day + '{:0>2}'.format(hour) + '%02d' % minute))36 id = "id=" + test_file_id[random.randint(0, len(test_file_id) - 1)] + ":" + str(37 random.randint(1000, 1000000))38 peer_id = 'peer_id=' + test_peer_id[random.randint(0, len(test_peer_id) - 1)]39 file_id = 'file_id=' + test_file_id[random.randint(0, len(test_file_id) - 1)]40 file_type = 'file_type=' + 'live'41 upload = 'upload=' + str(random.randint(100000, 900000))42 download = 'download=' + str(random.randint(500000, 1000000))43 writer.write(data_format % (topic, public_ip, sdk_agent_name, sdk_agent_version, timestamp, id,44 peer_id, file_id, file_type, upload, download))45if __name__ == '__main__':46 eg = SeedFlow()...

Full Screen

Full Screen

test_api.py

Source:test_api.py Github

copy

Full Screen

1from fastapi.testclient import TestClient2from main import app3from const import ParamAlias, FilterType4TEST_SDK_VERSION = 'TEST SDK VERSION'5TEST_USERNAME = 'TEST USERNAME'6TEST_SDK_USERNAME_PARAMS_SET = [7 {ParamAlias.SDK_VERSION: TEST_SDK_VERSION, ParamAlias.USERNAME: TEST_USERNAME},8]9TEST_STATS_PARAMS_SET = [10 {ParamAlias.FILTER_TYPE: FilterType.SDK_VERSION},11 {ParamAlias.FILTER_TYPE: FilterType.USERNAME},12]13INVALID_SDK_USERNAMES_PARAMS_SET = [14 {},15 {ParamAlias.SDK_VERSION: TEST_SDK_VERSION},16 {ParamAlias.USERNAME: TEST_USERNAME},17 {'Test': 'test'},18 {ParamAlias.SDK_VERSION: ''},19 {ParamAlias.USERNAME: ''},20 {ParamAlias.SDK_VERSION: '', ParamAlias.USERNAME: TEST_USERNAME},21 {ParamAlias.SDK_VERSION: TEST_SDK_VERSION, ParamAlias.USERNAME: ''},22 {ParamAlias.SDK_VERSION: None},23 {ParamAlias.USERNAME: None},24 {ParamAlias.SDK_VERSION: None, ParamAlias.USERNAME: TEST_USERNAME},25 {ParamAlias.SDK_VERSION: TEST_SDK_VERSION, ParamAlias.USERNAME: None},26]27INVALID_STATS_PARAMS_SET = [28 {},29 {'Test': 'test'},30 {ParamAlias.FILTER_TYPE: ''},31 {ParamAlias.FILTER_TYPE: None},32 {ParamAlias.FILTER_TYPE: 'Test'}33]34def test_get_ad():35 with TestClient(app) as client:36 for params in TEST_SDK_USERNAME_PARAMS_SET:37 response = client.get('/api/ad/', params=params)38 assert response.status_code == 20039def test_get_ad_invalid_params():40 with TestClient(app) as client:41 for params in INVALID_SDK_USERNAMES_PARAMS_SET:42 response = client.get('/api/ad/', params=params)43 assert response.status_code == 42244def test_impression():45 with TestClient(app) as client:46 for params in TEST_SDK_USERNAME_PARAMS_SET:47 response = client.post('/api/impression/', json=params)48 assert response.status_code == 20049def test_impression_invalid_params():50 with TestClient(app) as client:51 for params in INVALID_SDK_USERNAMES_PARAMS_SET:52 response = client.post('/api/impression/', json=params)53 assert response.status_code == 42254def test_get_stats():55 with TestClient(app) as client:56 for params in TEST_STATS_PARAMS_SET:57 response = client.get('/api/stats/', params=params)58 assert response.status_code == 20059 assert response.json().keys() == {'requests', 'impressions', 'fill_rate'}60def test_get_stats_invalid_params():61 with TestClient(app) as client:62 for params in INVALID_STATS_PARAMS_SET:63 response = client.post('/api/impression/', json=params)...

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