How to use get_by_state method in locust

Best Python code snippet using locust

test_alarm.py

Source:test_alarm.py Github

copy

Full Screen

...106a1.trigger(trigger1,time.time(),'1-3')107a1.trigger(trigger1,time.time(),'1-4')108a1.trigger(trigger1,time.time(),'1-5')109ef = a1.event_factory110inactive = ef.get_by_state(['inactive'])111raised = ef.get_by_state(['raised'])112assert inactive != raised, 'Wrong event lists.'113assert (inactive + raised) == ef.get_by_state(['inactive','raised'])114cleared = ef.get_by_state(['cleared'])115not_cleared = ef.get_by_state([], ['cleared'])116assert (inactive + raised) == not_cleared117assert len(ef.get_by_state()) == 11118assert len(ef.get_by_state([],['inactive'])) == 10119for event in a1.get_events():120 assert AlarmEvent.get_event(event.id) is event, 'Lookup failed'121ec = cleared[-1]122ec.notify('acknowledge',trigger1,time.time(),'Testing close.')123a2.trigger(trigger2,time.time(),{'a2':'too high!'})124assert AlarmEvent.get_event(callbacks[2].event.id) is callbacks[2].event, (125 'ID lookup failed')126a3.trigger(trigger3,time.time(),{'a3':'too high!'})127assert AlarmEvent.get_event(callbacks[3].event.id) is callbacks[3].event, (128 'ID lookup failed')129a4.trigger(trigger4,time.time(),{'a4':'too high!'})130assert AlarmEvent.get_event(callbacks[4].event.id) is callbacks[4].event, (131 'ID lookup failed')132a5.trigger(trigger5,time.time(),{'a5':'too high!'})...

Full Screen

Full Screen

query.py

Source:query.py Github

copy

Full Screen

...6 # TODO: refactor here some GASMemberManager objects7 pass8class OrderQuerySet(QuerySet):9 10 def get_by_state(self, name):11 """12 Return a QuerySet containing all ``GASSupplierOrder``s whose current state is named as ``name``.13 14 Note that is not the same as retrieving every ``GASSupplierOrder`` having a given state,15 since different model instances may be associated to different workflows, and states belonging to 16 different workflows are different even if they are named the same way. 17 """18 order_ct = ContentType.objects.get_for_model(self.model)19 sors = StateObjectRelation.objects.filter(content_type=order_ct, state__name=name)20 orders = self.filter(pk__in=[sor.content_id for sor in sors])21 return orders22 23 def prepared(self):24 return self.get_by_state('Prepared')25 def open(self):26 return self.get_by_state('Open')27 def closed(self):28 return self.get_by_state('Closed')29 30 def on_completion(self):31 return self.get_by_state('On completion')32 33 def finalized(self):34 return self.get_by_state('Finalized')35 36 def unpaid(self):37 return self.get_by_state('Unpaid')38 39 def delivered(self):40 return self.get_by_state('Delivered')41 42 def archived(self):43 return self.get_by_state('Archived')44 45 def canceled(self):46 return self.get_by_state('Canceled')47 48#-------------------------------------------------------------------------------49class AppointmentQuerySet(QuerySet):50 def future(self):51 """52 Return a QuerySet containing all appointments scheduled for today or for a future date.53 """54 return self.filter(date__gte=date.today())55 def past(self):56 """57 Return a QuerySet containing all past appointments.58 """...

Full Screen

Full Screen

test.py

Source:test.py Github

copy

Full Screen

...16 self.master_bind_host = master_bind_host17 self.master_bind_port = master_bind_port18 #嵌套类,这个类可以被作为一个方法被父类调用19 class WorkerNodesDict(dict):20 def get_by_state(self, state):21 return [c for c in self.values() if c.state == state]22 @property23 def all(self):24 return self.values()25 @property26 def ready(self):27 return self.get_by_state(STATE_INIT)28 @property29 def spawning(self):30 return self.get_by_state(STATE_SPAWNING)31 @property32 def running(self):33 return self.get_by_state(STATE_RUNNING)34 @property35 def missing(self):36 return self.get_by_state(STATE_MISSING)37 self.clients = WorkerNodesDict()38 print(dir(self.clients))39if __name__ == '__main__':40 e = []41 runner = MasterBOOMER(e,'127.0.0.1','8989')42 ...

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