How to use generate_instance method in localstack

Best Python code snippet using localstack_python

test_dependant_methods.py

Source:test_dependant_methods.py Github

copy

Full Screen

...7 seq.append(data)8 return val9class TestDependantMethods(TestCase):10 @staticmethod11 def generate_instance(methods, dependencies):12 class Class(object):13 __metaclass__ = dm.ForcedDepends14 stage_depends = dict(dependencies)15 locals().update(methods.iteritems())16 return Class()17 def test_no_dependant_methods(self):18 self.assertTrue(self.generate_instance({}, {}))19 def test_return_checking(self):20 results = []21 o = self.generate_instance(22 dict((str(x), currying.post_curry(func, results, x))23 for x in range(10)),24 dict((str(x), str(x - 1)) for x in xrange(1, 10)))25 getattr(o, "9")()26 self.assertEqual(results, range(10))27 results = []28 o = self.generate_instance(29 dict((str(x), currying.post_curry(func, results, x, False))30 for x in range(10)),31 dict((str(x), str(x - 1)) for x in xrange(1, 10)))32 getattr(o, "9")()33 self.assertEqual(results, [0])34 getattr(o, "9")()35 self.assertEqual(results, [0, 0])36 def test_stage_awareness(self):37 results = []38 o = self.generate_instance(39 dict((str(x), currying.post_curry(func, results, x))40 for x in range(10)),41 dict((str(x), str(x - 1)) for x in xrange(1, 10)))42 getattr(o, "1")()43 self.assertEqual(results, [0, 1])44 getattr(o, "2")()45 self.assertEqual(results, [0, 1, 2])46 getattr(o, "2")()47 self.assertEqual(results, [0, 1, 2])48 o.__set_stage_state__(["0", "1"])49 l = []50 o.__stage_step_callback__ = l.append51 getattr(o, "2")()52 self.assertEqual(results, [0, 1, 2, 2])53 self.assertEqual(l, ["2"])54 def test_stage_depends(self):55 results = []56 methods = dict((str(x), currying.post_curry(func, results, x))57 for x in range(10))58 deps = dict((str(x), str(x - 1)) for x in xrange(1, 10))59 deps["1"] = ["0", "a"]60 methods["a"] = currying.post_curry(func, results, "a")61 o = self.generate_instance(methods, deps)62 getattr(o, "1")()63 self.assertEqual(results, [0, "a", 1])64 getattr(o, "2")()65 self.assertEqual(results, [0, "a", 1, 2])66 def test_ignore_deps(self):67 results = []68 o = self.generate_instance(69 dict((str(x), currying.post_curry(func, results, x))70 for x in range(10)),71 dict((str(x), str(x - 1)) for x in xrange(1, 10)))72 getattr(o, '2')(ignore_deps=True)73 self.assertEqual([2], results)74 def test_no_deps(self):75 results = []76 o = self.generate_instance(77 dict((str(x), currying.post_curry(func, results, x))78 for x in range(10)),79 {})80 getattr(o, '2')()...

Full Screen

Full Screen

generate_instance.py

Source:generate_instance.py Github

copy

Full Screen

...7sigma = variance to be used in the normal distribution while generating an instance.8The function returns an instance of the airplane refueling problem as a list of 2-tuples.9"""10import numpy as np11def generate_instance(n, sigma, seed):12 np.random.seed(seed)13 p = list(np.random.randint(1,101,n))14 instance = []15 for i in p:16 instance.append((i,2**(np.random.normal(0,sigma))*i)) # consumption rate & volume17 return instance18#S119n_S1 = list(range(14))20S1 = []21for i in range(14):22 n_S1[i] = (n_S1[i]+1)*1023 S1.append([])24sigma_S1 = 0.125for i in range(len(n_S1)):26 for j in range(50):27 instance = generate_instance(n_S1[i],sigma_S1,j*n_S1[i])28 S1[i].append(instance)29print("endS1")30 31#sigma of S2 and S3 32sig = 0.133Sigma = []34while sig <=1:35 Sigma.append(sig)36 sig += 0.00137#S238size = {100,500,1000,2000,3000}39S2_100, S2_500, S2_1000, S2_2000, S2_3000 = [], [], [], [], []40for i in range(len(Sigma)):41 for j in range(1,6):42 instance = generate_instance(100,Sigma[i],int(j*1000*Sigma[i]))43 S2_100.append(instance)44print("end1")45for i in range(len(Sigma)):46 for j in range(1,6):47 instance = generate_instance(500,Sigma[i],int(j*5000*Sigma[i]))48 S2_500.append(instance)49print("end2")50for i in range(len(Sigma)):51 for j in range(1,6):52 instance = generate_instance(1000,Sigma[i],int(j*10000*Sigma[i]))53 S2_1000.append(instance)54print("end3")55 56for i in range(len(Sigma)):57 for j in range(1,6):58 instance = generate_instance(2000,Sigma[i],int(j*20000*Sigma[i]))59 S2_2000.append(instance)60print("end4")61for i in range(len(Sigma)):62 for j in range(1,6):63 instance = generate_instance(3000,Sigma[i],int(j*30000*Sigma[i]))64 S2_3000.append(instance)65print("end5")66 67#S368size_S3 = 50069S3 = [] 70for i in range(len(Sigma)):71 for j in range(1,6):72 instance = generate_instance(500,Sigma[i],int(j*50000*Sigma[i]))73 S3.append(instance)...

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