Best Python code snippet using tempest_python
test_allocation.py
Source: test_allocation.py
...35 self.assertRaises(exception.AllocationNotFound,36 dbapi.get_allocation,37 self.context,38 allocation_id)39 def test_list_allocations(self):40 cids = []41 for i in range(1, 6):42 provider = utils.create_test_resource_provider(43 id=i,44 uuid=uuidutils.generate_uuid(),45 context=self.context)46 allocation = utils.create_test_allocation(47 id=i,48 resource_provider_id=provider.id,49 consumer_id=uuidutils.generate_uuid(),50 context=self.context)51 cids.append(allocation['consumer_id'])52 res = dbapi.list_allocations(self.context)53 res_cids = [r.consumer_id for r in res]54 self.assertEqual(sorted(cids), sorted(res_cids))55 def test_list_allocations_sorted(self):56 cids = []57 for i in range(5):58 provider = utils.create_test_resource_provider(59 id=i,60 uuid=uuidutils.generate_uuid(),61 context=self.context)62 allocation = utils.create_test_allocation(63 id=i,64 resource_provider_id=provider.id,65 consumer_id=uuidutils.generate_uuid(),66 context=self.context)67 cids.append(allocation['consumer_id'])68 res = dbapi.list_allocations(self.context,69 sort_key='consumer_id')70 res_cids = [r.consumer_id for r in res]71 self.assertEqual(sorted(cids), res_cids)72 self.assertRaises(exception.InvalidParameterValue,73 dbapi.list_allocations,74 self.context,75 sort_key='foo')76 def test_list_allocations_with_filters(self):77 provider = utils.create_test_resource_provider(78 id=1,79 uuid=uuidutils.generate_uuid(),80 context=self.context)81 allocation1 = utils.create_test_allocation(82 used=0,83 resource_provider_id=provider.id,84 context=self.context)85 allocation2 = utils.create_test_allocation(86 used=1,87 resource_provider_id=provider.id,88 context=self.context)89 res = dbapi.list_allocations(90 self.context, filters={'used': 0})91 self.assertEqual([allocation1.id], [r.id for r in res])92 res = dbapi.list_allocations(93 self.context, filters={'used': 1})94 self.assertEqual([allocation2.id], [r.id for r in res])95 res = dbapi.list_allocations(96 self.context, filters={'used': 11111})97 self.assertEqual([], [r.id for r in res])98 res = dbapi.list_allocations(99 self.context,100 filters={'used': allocation1.used})101 self.assertEqual([allocation1.id], [r.id for r in res])102 def test_destroy_allocation(self):103 allocation = utils.create_test_allocation(context=self.context)104 dbapi.destroy_allocation(self.context, allocation.id)105 self.assertRaises(exception.AllocationNotFound,106 dbapi.get_allocation,107 self.context, allocation.id)108 def test_destroy_allocation_by_id(self):109 allocation = utils.create_test_allocation(context=self.context)110 dbapi.destroy_allocation(self.context, allocation.id)111 self.assertRaises(exception.AllocationNotFound,112 dbapi.get_allocation,...
mainSwapFlats.py
Source: mainSwapFlats.py
1import copy2import sys3import pickle4from os.path import exists5from util.Calculator import calc_happiness, check_unfulfilled_wishes, compare_allocations6from util.Writer import save_data_to_xlsx7from util.helper import swap_flats8from util.Reader import read_source9list_hh_wishes = {} # liste an Haushalten10list_flats = {} # liste der Wohnungen11list_weights = {} # Gewichte je Wunsch. Durch Belegungskommission festgelegt12list_allocations = {} # Format: "Haushalts ID" : "Wohnungs ID"13if __name__ == '__main__':14 path = "D:/HomeOnD/NC/Projekte/gw-wohnvergabe-datasources"15 if len(sys.argv) > 1:16 file = sys.argv[1]17 else:18 file = path + "/2022-08-18_results-survey2704(1)_korrigiert_2022-08-19_14-53-54_654.1313.xlsx"19 file2 = path + "/WgDaten.xlsx"20 read_source(file, file2, list_hh_wishes, list_flats, list_weights, True)21 last = file.rfind("_")22 lastlast = file[0:last].rfind("_")23 x = file[0:lastlast].rfind("_")24 y = file.rfind(".xlsx")25 pickel_file = path + "/allocations_" + file[x+1:y] + ".pkl"26 if exists(pickel_file):27 print("Previous allocation found. Loading existing allocation: " + pickel_file)28 with open(pickel_file, "rb") as inp:29 list_allocations = pickle.load(inp)30 else:31 raise Exception("No previous allocation found.")32 old_allocation = copy.deepcopy(list_allocations)33 # hh1 = 4; hh2 = 65 # Thorsten und Sabine34 # hh1 = 19; hh2 = 1109 # Detlev und freie Wohnung35 # hh1 = 36; hh2 = 63 # Jeanette und Kallmeyer, Ruth36 # hh1 = 36; hh2 = 88 # Jeanette und Tim Többe37 hh1 = 61; hh2 = 94 # Linder, Liane und Penselin, Ulrike38 swap_flats(hh1, hh2, list_allocations, list_flats) #39 max_happiness = calc_happiness(list_hh_wishes, list_flats, list_weights, list_allocations)40 list_allocations = check_unfulfilled_wishes(list_hh_wishes, list_flats, list_weights, list_allocations)41 diff_allocations = compare_allocations(list_allocations, old_allocation)42 save_data_to_xlsx(file, list_hh_wishes, list_flats, list_allocations, list_weights, max_happiness, "tausch_" +43 str(hh1) + "-" + str(hh2) + "_neu")44 save_data_to_xlsx(file, list_hh_wishes, list_flats, diff_allocations, list_weights, max_happiness, "tausch_" +...
main.py
Source: main.py
1import copy2import pickle3from os.path import exists4from datetime import datetime5from util.Calculator import init_distribution, calc_happiness, check_unfulfilled_wishes6from util.Optimizer import optimize_allocations7from util.Reader import read_source8from util.Writer import save_data_to_xlsx, save_allocation9from multiprocessing import Pool10def main_method(id):11 list_hh_wishes = {} # liste an Haushalten12 list_flats = {} # liste der Wohnungen13 list_weights = {} # Gewichte je Wunsch. Durch Belegungskommission festgelegt14 list_allocations = {} # Format: "Haushalts ID" : ["Wohnungs ID", HappyNumbers]15 path = "D:/HomeOnD/NC/Projekte/gw-wohnvergabe-datasources"16 file = path + "/2022-08-18_results-survey2704(1)_korrigiert.xlsx"17 file2 = path + "/WgDaten.xlsx"18 read_source(file, file2, list_hh_wishes, list_flats, list_weights)19 pickel_file = path + "/neu.pkl"20 if exists(pickel_file):21 print("Previous allocation found. Loading existing allocation: " + pickel_file)22 with open(pickel_file, "rb") as inp:23 list_allocations = pickle.load(inp)24 else:25 print("No previous allocation found. Initializing new allocation.")26 init_distribution(list_hh_wishes, list_flats, list_allocations)27 # save_allocation(list_allocations, "init")28 list_allocations = optimize_allocations(list_hh_wishes, list_flats, list_weights, list_allocations)29 max_happiness = calc_happiness(list_hh_wishes, list_flats, list_weights, list_allocations)30 list_allocations = check_unfulfilled_wishes(list_hh_wishes, list_flats, list_weights, list_allocations)31 save_allocation(list_allocations, str(round(max_happiness, 4)))32 save_data_to_xlsx(file, list_hh_wishes, list_flats, list_allocations, list_weights, max_happiness, "")33if __name__ == '__main__':34 full_start = datetime.now()35 print("Start: " + str(full_start))36 # for i in range(20):37 with Pool(10) as p:38 p.map(main_method, range(0, 20))39 print("--------------------------------------")40 print("Ende: " + str(datetime.now()))41 full_diff = datetime.now() - full_start...
Check out the latest blogs from LambdaTest on this topic:
These days, development teams depend heavily on feedback from automated tests to evaluate the quality of the system they are working on.
I think that probably most development teams describe themselves as being “agile” and probably most development teams have standups, and meetings called retrospectives.There is also a lot of discussion about “agile”, much written about “agile”, and there are many presentations about “agile”. A question that is often asked is what comes after “agile”? Many testers work in “agile” teams so this question matters to us.
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.
To understand the agile testing mindset, we first need to determine what makes a team “agile.” To me, an agile team continually focuses on becoming self-organized and cross-functional to be able to complete any challenge they may face during a project.
When working on web automation with Selenium, I encountered scenarios where I needed to refresh pages from time to time. When does this happen? One scenario is that I needed to refresh the page to check that the data I expected to see was still available even after refreshing. Another possibility is to clear form data without going through each input individually.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!