How to use test_get_status method in Airtest

Best Python code snippet using Airtest

test.py

Source:test.py Github

copy

Full Screen

...4import os5import sys6import time7clear_enabled=True8def test_get_status(url, expected_status):9 print ("Testing \"%s\"" % (url, ))10 conn = httplib.HTTPConnection("localhost", 8080)11 conn.request("GET", url)12 res = conn.getresponse()13 data = res.read()14 assert res.status == expected_status15def test_get_checksum(url, expected_checksum):16 print ("Testing \"%s\"" % (url, ))17 conn = httplib.HTTPConnection("localhost", 8080)18 conn.request("GET", url)19 res = conn.getresponse()20 m = hashlib.sha1()21 m.update(res.read())22 if m.hexdigest() != expected_checksum:23 print 'test_get_checksum("%s", "%s")' % (url, m.hexdigest())24 assert m.hexdigest() == expected_checksum25def test_get_checksum_range(url, start, end, expected_checksum):26 print ("Testing \"%s\"" % (url, ))27 conn = httplib.HTTPConnection("localhost", 8080)28 r = "bytes=%d-%d" % (start, end)29 conn.request("GET", url, "", {"Range": r})30 res = conn.getresponse()31 m = hashlib.sha1()32 m.update(res.read())33 assert res.status == 20634 if m.hexdigest() != expected_checksum:35 print 'test_get_checksum_range("%s", %d, %d, "%s")' % (url, start, end, m.hexdigest())36 assert m.hexdigest() == expected_checksum37#args = ['../tools/gst-streaming-server']38#pid = os.spawnv(os.P_NOWAIT, "../tools/gst-streaming-server", args)39#print "PID is %d" % (pid,)40#time.sleep(2)41#if pid != 0:42# sys.exit(1)43#sys.exit(0)44test_get_status("/", 200)45test_get_status("/vod", 404)46test_get_status("/vod/", 404)47test_get_status("/vod/", 404)48test_get_status("/vod/moo", 404)49test_get_status("/vod/elephantsdream", 404)50test_get_status("/vod/elephantsdream/", 404)51test_get_status("/vod/elephantsdream/0/pr", 404)52test_get_status("/vod/elephantsdream/0/pr/ism", 404)53test_get_status("/vod/broken/0/pr/ism/Manifest", 404)54test_get_status("/vod/elephantsdream/0/pr/ism/Manifest", 200)55test_get_status("/vod/elephantsdream/broken/pr/ism/Manifest", 404)56test_get_status("/vod/elephantsdream/1/pr/ism/Manifest", 404)57test_get_status("/vod/elephantsdream/0/broken/ism/Manifest", 404)58test_get_status("/vod/elephantsdream/0/pr/broken/Manifest", 404)59test_get_status("/vod/elephantsdream/0/pr/ism/broken", 404)60test_get_status("/vod/broken/0/pr/ism/content", 404)61test_get_checksum("/vod/elephantsdream/0/pr/ism/Manifest", "ae130fc21ed2457226ac0b55af655e7ba907ed9e")62test_get_checksum("/vod/elephantsdream/0/pr/ism/content?stream=video&start_time=0&bitrate=752766", "987544b6952ca7e22a368f3a6b294d44d48b4ef3")63test_get_checksum("/vod/elephantsdream/0/pr/ism/content?stream=video&start_time=0&bitrate=1392712", "0ea4a488cce7c88c37290108bf6f190e1cebf2fc")64test_get_checksum("/vod/elephantsdream/0/pr/ism/content?stream=video&start_time=0&bitrate=2341910", "f8988711cf0ab5bce054c061079674479053aaed")65test_get_checksum("/vod/elephantsdream/0/pr/ism/content?stream=video&start_time=0&bitrate=4771928", "461e0531ece8fd28dca46f9320fed75f7c80a698")66test_get_checksum("/vod/elephantsdream/0/pr/ism/content?stream=audio&start_time=0&bitrate=134578", "495bc12abc62eb80d8c4b4fbf35a748eb749b504")67test_get_checksum("/vod/elephantsdream/0/pr/ism/content?stream=video&start_time=50416000&bitrate=752766", "217e1d7f61a5d2d3592460dfe1263a22e7d1c3a8")68test_get_checksum("/vod/elephantsdream/0/pr/ism/content?stream=video&start_time=50416000&bitrate=1392712", "7b5ff2df1927d83889df7a659b68fdadcdfd6554")69test_get_checksum("/vod/elephantsdream/0/pr/ism/content?stream=video&start_time=50416000&bitrate=2341910", "548291fc7965cb951b4b6734da4500c884a4debc")70test_get_checksum("/vod/elephantsdream/0/pr/ism/content?stream=video&start_time=50416000&bitrate=4771928", "3081b53c8bf237cee968e4f6a45af125ca629810")71test_get_checksum("/vod/elephantsdream/0/pr/ism/content?stream=audio&start_time=50346666&bitrate=134578", "20a61d0c9abde21d19385d2a9230c755ce45c371")72test_get_status("/vod/elephantsdream/0/pr/ism/content?stream=broken&start_time=0&bitrate=752428", 404)73test_get_status("/vod/elephantsdream/0/pr/ism/content?stream=video&start_time=broken&bitrate=752428", 404)74test_get_status("/vod/elephantsdream/0/pr/ism/content?stream=video&start_time=0&bitrate=broken", 404)75test_get_status("/vod/elephantsdream/0/pr/ism/content?stream=video&start_time=10&bitrate=752428", 404)76test_get_status("/vod/elephantsdream/0/pr/ism/content?stream=video&start_time=0&bitrate=10", 404)77test_get_status("/vod/elephantsdream/0/pr/ism/content?start_time=0&bitrate=752428", 404)78test_get_status("/vod/elephantsdream/0/pr/ism/content?stream=video&bitrate=752428", 404)79test_get_status("/vod/elephantsdream/0/pr/ism/content?stream=video&start_time=0", 404)80if clear_enabled:81 test_get_checksum("/vod/elephantsdream/0/clear/ism/Manifest", "c4ae5af94a7a983c3adddd4b1ef0f70802c3baa4")82 test_get_checksum("/vod/elephantsdream/0/clear/ism/content?stream=video&start_time=0&bitrate=749643", "4dee4d4163d874db5566122476b5dea038e0b7df")83 test_get_checksum("/vod/elephantsdream/0/clear/ism/content?stream=video&start_time=0&bitrate=1389589", "b750696e883d9cd064ffb24aa83ced7288f2b796")84 test_get_checksum("/vod/elephantsdream/0/clear/ism/content?stream=video&start_time=0&bitrate=2338787", "4129295af4f9e18d09431d3d257cfd2c4f79ab25")85 test_get_checksum("/vod/elephantsdream/0/clear/ism/content?stream=video&start_time=0&bitrate=4768805", "6419a2adf7cf996c86c883840e29ded0ba0f7492")86 test_get_checksum("/vod/elephantsdream/0/clear/ism/content?stream=audio&start_time=0&bitrate=131527", "cbfe0889f53cd60c9f54dd10656c11cedd331107")87 test_get_checksum("/vod/elephantsdream/0/clear/ism/content?stream=video&start_time=50416000&bitrate=749643", "41a9b14300deb5de5404bcbf19cf5744c6011308")88 test_get_checksum("/vod/elephantsdream/0/clear/ism/content?stream=video&start_time=50416000&bitrate=1389589", "fd66cbfd82d5afce8d0286655e0b100c4e506f93")89 test_get_checksum("/vod/elephantsdream/0/clear/ism/content?stream=video&start_time=50416000&bitrate=2338787", "a17d30e6048393fd600e87ed7ecf3444e5f75d17")90 test_get_checksum("/vod/elephantsdream/0/clear/ism/content?stream=video&start_time=50416000&bitrate=4768805", "99bd9297f76c351bb2cd6da80f0265249735eb82")91 test_get_checksum("/vod/elephantsdream/0/clear/ism/content?stream=audio&start_time=50346666&bitrate=131527", "7a21c50cd4ab497f8b166f3e42a7b41a3d0aeef2")92 test_get_status("/vod/elephantsdream/0/clear/ism/content?stream=broken&start_time=0&bitrate=752428", 404)93 test_get_status("/vod/elephantsdream/0/clear/ism/content?stream=video&start_time=broken&bitrate=752428", 404)94 test_get_status("/vod/elephantsdream/0/clear/ism/content?stream=video&start_time=0&bitrate=broken", 404)95 test_get_status("/vod/elephantsdream/0/clear/ism/content?stream=video&start_time=10&bitrate=752428", 404)96 test_get_status("/vod/elephantsdream/0/clear/ism/content?stream=video&start_time=0&bitrate=10", 404)97 test_get_status("/vod/elephantsdream/0/clear/ism/content?start_time=0&bitrate=752428", 404)98 test_get_status("/vod/elephantsdream/0/clear/ism/content?stream=video&bitrate=752428", 404)99 test_get_status("/vod/elephantsdream/0/clear/ism/content?stream=video&start_time=0", 404)100test_get_checksum("/vod/elephantsdream/0/pr/isoff-ondemand/manifest.mpd", "a00a419a7f89f094200f965a428862cf01288863")101test_get_checksum_range("/vod/elephantsdream/0/pr/isoff-ondemand/content/v0", 0, 655, "3b25c1a6d5d3f8b4e4681f9c6b0a5b2269678144")102test_get_checksum_range("/vod/elephantsdream/0/pr/isoff-ondemand/content/v0", 0, 655, "3b25c1a6d5d3f8b4e4681f9c6b0a5b2269678144")103test_get_checksum_range("/vod/elephantsdream/0/pr/isoff-ondemand/content/v0", 2248, 432537, "9c8764f536d9954bb74147c24dd7dbe0bbf27892")104test_get_checksum_range("/vod/elephantsdream/0/pr/isoff-ondemand/content/a0", 0, 597, "6303d6b686daccc1122e94e236fb7daed50870ab")105test_get_checksum_range("/vod/elephantsdream/0/pr/isoff-ondemand/content/a0", 598, 2189, "70d999e5805cfd51371f735e6030e9ed5c0f8041")106test_get_checksum_range("/vod/elephantsdream/0/pr/isoff-ondemand/content/a0", 2190, 85915, "3abd1261886a65af156e182debeaba91be2eba87")107if clear_enabled:108 test_get_checksum("/vod/elephantsdream/0/clear/isoff-ondemand/manifest.mpd", "5bf139d40c70846930ee2f8b21fea59f6a4381c4")109 test_get_checksum_range("/vod/elephantsdream/0/clear/isoff-ondemand/content/v0", 0, 655, "705d17a7e7f039ab555722bf3a5144be66101baf")110 test_get_checksum_range("/vod/elephantsdream/0/clear/isoff-ondemand/content/v0", 656, 2247, "560ad64ddb05649bf120a7e9b11dc7eeca584b08")111 test_get_checksum_range("/vod/elephantsdream/0/clear/isoff-ondemand/content/v0", 2248, 432537, "d479739ff6808c71d3be8eb7579f3ade5f20d568")112 test_get_checksum_range("/vod/elephantsdream/0/clear/isoff-ondemand/content/a0", 0, 597, "5940fc3bfa99dd4a5f903edc382bc5c42f8e508a")113 test_get_checksum_range("/vod/elephantsdream/0/clear/isoff-ondemand/content/a0", 598, 2189, "0fd77b2f3a0d12a082b781adc76b2af90b452b3c")...

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