How to use undo method in localstack

Best Python code snippet using localstack_python

test_undo.py

Source:test_undo.py Github

copy

Full Screen

1from Domain.carte import creaza_carte, get_id2from Logic.crud import create3from Logic.undo_redo import do_undo, do_redo4def test_undo():5 #1.lista initiala goala6 carti = []7 undo_list = []8 redo_list = []9 #2.adaugam un obiect10 carti = create(carti, 1, 'book1', 'gen1', 90, 'none', undo_list,redo_list)11 #3.adaugam inca un obiect12 carti = create(carti, 2, 'book2', 'gen2', 45.4, 'silver', undo_list, redo_list)13 #4.adaugam inca un obiect14 carti = create(carti, 3, 'book3', 'gen3', 133, 'gold', undo_list, redo_list)15 assert len(carti) ==316 #5.undo scoate ultimul obiect adaugat17 carti = do_undo(undo_list, redo_list, carti)18 gasit = 019 for carte in carti:20 if get_id(carte) == 1:21 gasit = gasit + 122 elif get_id(carte) == 2:23 gasit = gasit + 124 assert gasit == 225 #6. inca un undo scoate penultimul obiect adaugat26 carti = do_undo(undo_list, redo_list, carti)27 assert len(carti) == 128 gasit = 029 for carte in carti:30 if get_id(carte) == 1:31 gasit = 132 assert gasit == 133 #7.inca un undo scoate si primul element adaugat34 carti = do_undo(undo_list, redo_list, carti)35 assert carti ==[]36 #8.inca un undo nu face nimic37 assert do_undo(undo_list, redo_list, carti) is None38 #9.adaugam trei obiecte39 carti = create(carti, 4, 'boo4', 'ge4', 300, 'gold', undo_list, redo_list)40 carti = create(carti, 5, 'boo5', 'ge5', 80, 'none', undo_list, redo_list)41 carti = create(carti, 6, 'booo6', 'ge6', 10.9, 'silver', undo_list, redo_list)42 #10.redo nu face nimic43 carti_noi = do_redo(undo_list, redo_list, carti)44 assert carti_noi is None45 #11.doua undo-uri scot ultimele 2 obiecte46 carti = do_undo(undo_list, redo_list, carti)47 carti = do_undo(undo_list, redo_list, carti)48 assert len(carti) == 149 gasit = 050 for carte in carti:51 if get_id(carte) == 4:52 gasit = 153 assert gasit == 154 # 12.redo anuleaza ultimul undo, daca ultima operatie e undo55 carti = do_redo(undo_list, redo_list, carti)56 assert len(carti) == 257 gasit = 058 for carte in carti:59 if get_id(carte) == 4:60 gasit = gasit + 161 elif get_id(carte) == 5:62 gasit = gasit + 163 assert gasit == 264 #13.redo anuleaza si primul undo65 carti = do_redo(undo_list, redo_list, carti)66 gasit = 067 for carte in carti:68 if get_id(carte) == 4:69 gasit = gasit + 170 elif get_id(carte) == 5:71 gasit = gasit + 172 elif get_id(carte) == 6:73 gasit = gasit + 174 assert gasit == 375 #14.doua undo-uri scot ultimele 2 obiecte76 carti = do_undo(undo_list, redo_list, carti)77 carti = do_undo(undo_list, redo_list, carti)78 assert len(carti) == 179 gasit = 080 for carte in carti:81 if get_id(carte) == 4:82 gasit = gasit + 183 assert gasit == 184 #15.adaugam un obiect85 carti = create(carti, 7, 'booo7', 'gen7', 121.77, 'silver', undo_list, redo_list)86 assert len(carti) == 287 #16.redo nu face nimic, deoarece ultima operatie nu este un undo88 assert do_redo(undo_list, redo_list, carti) == None89 gasit = 090 for carte in carti:91 if get_id(carte) == 4:92 gasit = gasit + 193 elif get_id(carte) == 7:94 gasit = gasit + 195 assert gasit == 296 #17.undo anuleaza adaugarea lui o497 carti = do_undo(undo_list, redo_list, carti)98 assert len(carti) == 199 gasit = 0100 for carte in carti:101 if get_id(carte) == 4:102 gasit = gasit + 1103 assert gasit == 1104 #18.undo anuleaza adaugarea lui o1 - practic se continua sirul de undo de la pct 14105 carti = do_undo(undo_list, redo_list, carti)106 assert len(carti) == 0107 assert carti == []108 #19.se anuleaza ultimele 2 undo-uri109 carti = do_redo(undo_list, redo_list, carti)110 carti = do_redo(undo_list, redo_list, carti)111 gasit = 0112 for carte in carti:113 if get_id(carte) == 4:114 gasit = gasit + 1115 elif get_id(carte) == 7:116 gasit = gasit + 1117 assert gasit == 2118 #20.redo nu face nimic119 assert do_redo(undo_list, redo_list, carti) is None

Full Screen

Full Screen

undo.py

Source:undo.py Github

copy

Full Screen

...14 self.redoList = []15 self.undoIdx = 016 self.checkIdx = 017 self.save(**kwargs)18 def undo(self):19 """20 Restore from undoList21 """22 # Index valid from 0 upto length-123 i = max(0, self.undoIdx - 1)24 u = self.undoList[i]25 print("Undo %s # %d index %d length %d" % (26 u[0].__name__, u[2], i, len(self.undoList)))27 assert len(self.undoList) == len(self.redoList)28 # Keep the entries at index 0 created during init29 if self.undoIdx > 2:30 self.undoIdx -= 131 return u32 def redo(self):...

Full Screen

Full Screen

test_operatii_undo_redo.py

Source:test_operatii_undo_redo.py Github

copy

Full Screen

...12 carti = create(carti, 3, 'mouse', 'densene', 99, 'gold', undo_list, redo_list)13 c_updated = creaza_carte(1, 'cartenou', 'gen33', 34.33, 'gold')14 updated = update(carti, c_updated, undo_list, redo_list)15 if len(undo_list) > 0:16 updated = do_undo(undo_list, redo_list, updated)17 assert c_updated not in updated18 if len(redo_list) > 0:19 updated = do_redo(undo_list, redo_list, updated)20 assert c_updated in updated21def test_undo_redo_delete():22 carti = []23 undo_list = []24 redo_list = []25 carti = create(carti, 1, 'ana', 'legenda', 34.5, 'none', undo_list, redo_list)26 carti = create(carti, 2, 'oocaa', 'romantic', 90, 'silver', undo_list, redo_list)27 carti = create(carti, 3, 'mouse', 'densene', 99, 'gold', undo_list, redo_list)28 delete_carti = 329 c_deleted = read(carti, delete_carti)30 deleted = delete(carti, delete_carti, undo_list, redo_list)31 if len(undo_list) > 0:32 deleted = do_undo(undo_list, redo_list, deleted)33 assert c_deleted in deleted34 if len(redo_list) > 0:35 deleted = do_redo(undo_list, redo_list, deleted)36 assert c_deleted not in deleted37def test_undo_redo_discount():38 carti = []39 undo_list = []40 redo_list = []41 carti = create(carti, 1, 'ana', 'legenda', 34.5, 'none', undo_list, redo_list)42 carti = create(carti, 2, 'oocaa', 'romantic', 90, 'silver', undo_list, redo_list)43 carti = create(carti, 3, 'mouse', 'densene', 99, 'gold', undo_list, redo_list)44 carti = discount_function(carti, undo_list, redo_list)45 if len(undo_list) > 0:46 carti = do_undo(undo_list, redo_list, carti)47 assert get_pret_carte(carti[0]) == 34.548 assert get_pret_carte(carti[1]) == 9049 assert get_pret_carte(carti[2]) == 9950 if len(redo_list) > 0:51 carti = do_redo(undo_list, redo_list, carti)52 assert get_pret_carte(carti[0]) == 34.553 assert get_pret_carte(carti[1]) == 85.554 assert get_pret_carte(carti[2]) == 89.155def test_undo_redo_modifygen():56 carti = []57 undo_list = []58 redo_list = []59 carti = create(carti, 1, 'ana', 'legenda', 34.5, 'none', undo_list, redo_list)60 carti = create(carti, 2, 'oocaa', 'romantic', 90, 'silver', undo_list, redo_list)61 carti = create(carti, 3, 'mouse', 'densene', 99, 'gold', undo_list, redo_list)62 carti = modify_gen(carti, 'ana', 'iubire', undo_list, redo_list)63 if len(undo_list) > 0:64 carti = do_undo(undo_list, redo_list, carti)65 assert get_gen_carte(carti[0]) == 'legenda'66 if len(redo_list) > 0:67 carti = do_redo(undo_list, redo_list, carti)...

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