How to use get_services method in Airtest

Best Python code snippet using Airtest

test.py

Source: test.py Github

copy

Full Screen

...35 ssl.__ssl__.SSLContext.wrap_socket = wrap_socket36except AttributeError:37 pass38import postservices39def get_services():40 return postservices.TrackingService.service_classes41if __name__ == '__main__':42 import sys43 import codecs44 import locale45 import logging46 # logging.basicConfig(level=logging.DEBUG, format="%(asctime)s - %(levelname)s - %(message)s")47 # sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout)48 # service = get_services()['RussianpostRuService']('CG077165712US')49 # service = get_services()['CanparComService']('D100301463601')50 # service = get_services()['ThailandPostCoThService']('RR051974496TH')51 # service = get_services()['BelpostByService']('BV021258988BY')52 # service = get_services()['EmspostRuService']('EB006267877IT')53 # service = get_services()['EmsPostService']('EB006267877IT')54 # service = get_services()['PpxTrackComService']('RRD050599000070847')55 # service = get_services()['CorreosCl']('RP316339727SG')56 # service = get_services()['RussianpostRuService']('RM144847659CN')57 # service = get_services()['AsendiaUsaComService']('LM586057034US')58 # service = PostaSiService('RA316816466SI')59 # service = ParcelForceNetService('EK034679967GB')60 # service = PostdanmarkDkService('TS123456789DK')61 # service = SwisspostChService('RU470249572CH')62 # service = UspsComService('420917419405515901033236726959')63 # service = get_services()['UspsComService']('LN800389358US')64 # service = get_services()['UspsComService']('9400110200883101818261')65 # service = get_services()['UspsComService']('9241990101549234628999')66 # service = get_services()['CyprusPostGovCyService']('CP353366219FR')67 # service = get_services()['CorreosDeMexicoGobMxService']('RB918786998CN')68 # service = get_services()['CttPtService']('RE640520385SE')69 # service = get_services()['CttPtService']('RJ216862295CN')70 # service = get_services()['TransgroupComService']('23B514653')71 # service = get_services()['PosteItService']('EB006267877IT')72 # service = get_services()['FedexComService']('718909941913')73 # service = get_services()['UpsComService']('1Z88Y7Y21203375521')74 service = get_services()['UpsComService']('1Z18424E4406080438')75 # service = get_services()['YanwenComCnService']('11901885104')76 # service = get_services()['OnTracComService']('C11229305254319')77 # service = get_services()['JapanpostJp']('EG483450686JP')78 # service = UkrposhtaComService('RB041697087UA')79 # service = get_services()['DhlDeService']('00340433836170068547')80 # service = get_services()['HermesWorldTrackingService']('77305107155045')81 # service = CorreiosComService('RD024810847SE')82 # service = PrivpakSchenkerNuService('4199854203482')83 # service = SchenkerNuService('6273636354')84 # service = DhlmultishippingSeService('6288206664')85 # service = get_services()['DhlComService']('5008590300')86 # service = get_services()['CanadaPostCaService']('305260344086')87 # service = CorreosEsService('RA514556931CN')88 # service = get_services()['SingPostComService']('RF427535022SG')89 # service = get_services()['IParcelComService']('AEIIND10002594777')90 # service = get_services()['IParcelComService']('AEIPHX60004469610')91 print u'\t'.join((u'Operation', 'Datetime', 'Location'))92 for i in service.fetch():...

Full Screen

Full Screen

test_heartbeats.py

Source: test_heartbeats.py Github

copy

Full Screen

1from unittest import TestCase, mock2from collections import namedtuple3import datetime4from gobworkflow.heartbeats import on_heartbeat, check_services5class TestHeartbeats(TestCase):6 @mock.patch('gobworkflow.heartbeats.get_services')7 @mock.patch('gobworkflow.heartbeats.update_service')8 def test_on_heartbeat(self, update_service, get_services):9 service = {10 "name": "AnyService",11 "is_alive": True,12 "host": None,13 "pid": None,14 "timestamp": datetime.datetime.now().isoformat(),15 }16 msg = {17 "threads": [18 {19 "name": "thread1",20 "is_alive": True21 },22 {23 "name": "thread2",24 "is_alive": False25 }26 ]27 }28 msg.update(service)29 on_heartbeat(msg)30 self.assertEqual(update_service.call_count, 1)31 service_parameter, tasks = update_service.call_args[0]32 self.assertEqual(service_parameter, service)33 self.assertEqual(len(tasks), len(msg["threads"]))34 @mock.patch('gobworkflow.heartbeats.update_service')35 @mock.patch('gobworkflow.heartbeats.get_services')36 @mock.patch('gobworkflow.heartbeats.remove_service')37 @mock.patch('gobworkflow.heartbeats.mark_service_dead')38 def test_check_services(self, mark_service_dead, remove_service, get_services, update_service):39 service = {40 "name": "AnyService",41 "is_alive": True,42 "timestamp": (datetime.datetime.now() - datetime.timedelta(hours=1)).isoformat(),43 }44 msg = {45 "threads": [46 {47 "name": "thread1",48 "is_alive": True49 },50 {51 "name": "thread2",52 "is_alive": False53 }54 ]55 }56 msg.update(service)57 get_services.return_value = []58 on_heartbeat(msg)59 # Assure that the service has been marked dead because of a heartbeat timeout60 self.assertEqual(get_services.call_count, 1)61 self.assertEqual(remove_service.call_count, 0)62 self.assertEqual(mark_service_dead.call_count, 0)63 Service = namedtuple('Service', ['timestamp'])64 service = Service(datetime.datetime.utcnow())65 get_services.return_value = [service]66 get_services.reset_mock()67 on_heartbeat(msg)68 # Assure that the service has been marked dead because of a heartbeat timeout69 self.assertEqual(get_services.call_count, 1)70 self.assertEqual(remove_service.call_count, 0)71 self.assertEqual(mark_service_dead.call_count, 0)72 service = Service(datetime.datetime.utcnow() - datetime.timedelta(minutes=15))73 get_services.return_value = [service]74 get_services.reset_mock()75 on_heartbeat(msg)76 # Assure that the service has been marked dead because of a heartbeat timeout77 self.assertEqual(get_services.call_count, 1)78 self.assertEqual(remove_service.call_count, 0)79 self.assertEqual(mark_service_dead.call_count, 1)80 service = Service(datetime.datetime.utcnow() - datetime.timedelta(days=1))81 get_services.return_value = [service]82 get_services.reset_mock()83 mark_service_dead.reset_mock()84 on_heartbeat(msg)85 # Assure that the service has been marked dead because of a heartbeat timeout86 self.assertEqual(get_services.call_count, 1)87 self.assertEqual(remove_service.call_count, 1)...

Full Screen

Full Screen

test_unit.py

Source: test_unit.py Github

copy

Full Screen

...6 service = TimedService('dummy')7 service.start()8 time.sleep(0.009)9 service.end()10 assert get_services() == [service]11 assert service.duration == 912 assert service.name == 'dummy'13def test_timed_context_manager(discard):14 with timed('dummy') as service:15 time.sleep(0.008)16 assert get_services() == [service]17 assert get_services()[0].duration == 818 assert get_services()[0].name == 'dummy'19def test_timed_decorator(discard):20 @timed_wrapper('dummy')21 def sleepy_function():22 time.sleep(0.007)23 sleepy_function()24 assert get_services()[0].duration == 725 assert get_services()[0].name == 'dummy'26def test_discard_all_services(discard):27 service = TimedService('drummy')28 service.start()29 time.sleep(0.009)30 service.end()31 assert get_services() == [service]32 discard_all_services()33 assert get_services() == []34def test_add_service(discard):35 service = TimedService('drummy')36 add_service(service)...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

QA’s and Unit Testing – Can QA Create Effective Unit Tests

Unit testing is typically software testing within the developer domain. As the QA role expands in DevOps, QAOps, DesignOps, or within an Agile team, QA testers often find themselves creating unit tests. QA testers may create unit tests within the code using a specified unit testing tool, or independently using a variety of methods.

LIVE With Automation Testing For OTT Streaming Devices ????

People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.

Why Agile Is Great for Your Business

Agile project management is a great alternative to traditional methods, to address the customer’s needs and the delivery of business value from the beginning of the project. This blog describes the main benefits of Agile for both the customer and the business.

Options for Manual Test Case Development & Management

The purpose of developing test cases is to ensure the application functions as expected for the customer. Test cases provide basic application documentation for every function, feature, and integrated connection. Test case development often detects defects in the design or missing requirements early in the development process. Additionally, well-written test cases provide internal documentation for all application processing. Test case development is an important part of determining software quality and keeping defects away from customers.

Test strategy and how to communicate it

I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.

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