Best Python code snippet using autotest_python
prepared_networks.py
Source:prepared_networks.py
...22 D.add_student(G)23 H.add_student(J)24 I.add_student(J)25 net = VisualNetwork()26 net.add_user(A)27 net.add_user(B)28 net.add_user(C)29 net.add_user(D)30 net.add_user(E)31 net.add_user(F)32 net.add_user(G)33 net.add_user(H)34 net.add_user(I)35 net.add_user(J)36 return net37# Medium Network38def network_2():39 A = VisualUser("A", DEFAULT_NODE_COLOR)40 B = VisualUser("B", DEFAULT_NODE_COLOR)41 C = VisualUser("C", DEFAULT_NODE_COLOR)42 D = VisualUser("D", DEFAULT_NODE_COLOR)43 E = VisualUser("E", DEFAULT_NODE_COLOR)44 F = VisualUser("F", DEFAULT_NODE_COLOR)45 G = VisualUser("G", DEFAULT_NODE_COLOR)46 H = VisualUser("H", DEFAULT_NODE_COLOR)47 I = VisualUser("I", DEFAULT_NODE_COLOR)48 J = VisualUser("J", DEFAULT_NODE_COLOR)49 K = VisualUser("K", DEFAULT_NODE_COLOR)50 L = VisualUser("L", DEFAULT_NODE_COLOR)51 M = VisualUser("M", DEFAULT_NODE_COLOR)52 N = VisualUser("N", DEFAULT_NODE_COLOR)53 O = VisualUser("O", DEFAULT_NODE_COLOR)54 P = VisualUser("P", DEFAULT_NODE_COLOR)55 Q = VisualUser("Q", DEFAULT_NODE_COLOR)56 R = VisualUser("R", DEFAULT_NODE_COLOR)57 S = VisualUser("S", DEFAULT_NODE_COLOR)58 T = VisualUser("T", DEFAULT_NODE_COLOR)59 U = VisualUser("U", DEFAULT_NODE_COLOR)60 V = VisualUser("V", DEFAULT_NODE_COLOR)61 W = VisualUser("W", DEFAULT_NODE_COLOR)62 X = VisualUser("X", DEFAULT_NODE_COLOR)63 Y = VisualUser("Y", DEFAULT_NODE_COLOR)64 Z = VisualUser("Z", DEFAULT_NODE_COLOR)65 # Group 166 A.add_student(B)67 A.add_student(C)68 A.add_student(D)69 B.add_student(E)70 B.add_student(F)71 C.add_student(F)72 D.add_student(G)73 F.add_student(C)74 E.add_student(A)75 # Group 276 H.add_student(J)77 I.add_student(J)78 J.add_student(X)79 Y.add_student(H)80 # Group 381 K.add_student(L)82 K.add_student(M)83 K.add_student(N)84 K.add_student(O)85 L.add_student(P)86 N.add_student(Q)87 N.add_student(R)88 N.add_student(S)89 N.add_student(V)90 S.add_student(T)91 T.add_student(U)92 V.add_student(W)93 S.add_student(W)94 O.add_student(Z)95 net = VisualNetwork()96 net.add_user(A)97 net.add_user(B)98 net.add_user(C)99 net.add_user(D)100 net.add_user(E)101 net.add_user(F)102 net.add_user(G)103 net.add_user(H)104 net.add_user(I)105 net.add_user(J)106 net.add_user(K)107 net.add_user(L)108 net.add_user(M)109 net.add_user(N)110 net.add_user(O)111 net.add_user(P)112 net.add_user(Q)113 net.add_user(R)114 net.add_user(S)115 net.add_user(T)116 net.add_user(U)117 net.add_user(V)118 net.add_user(W)119 net.add_user(X)120 net.add_user(Y)121 net.add_user(Z)122 return net123# Large Network124def network_3():125 A = VisualUser("A", DEFAULT_NODE_COLOR)126 B = VisualUser("B", DEFAULT_NODE_COLOR)127 C = VisualUser("C", DEFAULT_NODE_COLOR)128 D = VisualUser("D", DEFAULT_NODE_COLOR)129 E = VisualUser("E", DEFAULT_NODE_COLOR)130 F = VisualUser("F", DEFAULT_NODE_COLOR)131 G = VisualUser("G", DEFAULT_NODE_COLOR)132 H = VisualUser("H", DEFAULT_NODE_COLOR)133 I = VisualUser("I", DEFAULT_NODE_COLOR)134 J = VisualUser("J", DEFAULT_NODE_COLOR)135 K = VisualUser("K", DEFAULT_NODE_COLOR)136 L = VisualUser("L", DEFAULT_NODE_COLOR)137 M = VisualUser("M", DEFAULT_NODE_COLOR)138 N = VisualUser("N", DEFAULT_NODE_COLOR)139 O = VisualUser("O", DEFAULT_NODE_COLOR)140 P = VisualUser("P", DEFAULT_NODE_COLOR)141 Q = VisualUser("Q", DEFAULT_NODE_COLOR)142 R = VisualUser("R", DEFAULT_NODE_COLOR)143 S = VisualUser("S", DEFAULT_NODE_COLOR)144 T = VisualUser("T", DEFAULT_NODE_COLOR)145 U = VisualUser("U", DEFAULT_NODE_COLOR)146 V = VisualUser("V", DEFAULT_NODE_COLOR)147 W = VisualUser("W", DEFAULT_NODE_COLOR)148 X = VisualUser("X", DEFAULT_NODE_COLOR)149 Y = VisualUser("Y", DEFAULT_NODE_COLOR)150 Z = VisualUser("Z", DEFAULT_NODE_COLOR)151 AA = VisualUser("AA", DEFAULT_NODE_COLOR)152 AB = VisualUser("AB", DEFAULT_NODE_COLOR)153 AC = VisualUser("AC", DEFAULT_NODE_COLOR)154 AD = VisualUser("AD", DEFAULT_NODE_COLOR)155 AE = VisualUser("AE", DEFAULT_NODE_COLOR)156 AF = VisualUser("AF", DEFAULT_NODE_COLOR)157 AG = VisualUser("AG", DEFAULT_NODE_COLOR)158 AH = VisualUser("AH", DEFAULT_NODE_COLOR)159 AI = VisualUser("AI", DEFAULT_NODE_COLOR)160 AJ = VisualUser("AJ", DEFAULT_NODE_COLOR)161 AK = VisualUser("AK", DEFAULT_NODE_COLOR)162 AL = VisualUser("AL", DEFAULT_NODE_COLOR)163 AM = VisualUser("AM", DEFAULT_NODE_COLOR)164 AN = VisualUser("AN", DEFAULT_NODE_COLOR)165 AO = VisualUser("AO", DEFAULT_NODE_COLOR)166 AP = VisualUser("AP", DEFAULT_NODE_COLOR)167 # Group 1168 A.add_student(B)169 A.add_student(C)170 A.add_student(D)171 B.add_student(E)172 B.add_student(F)173 C.add_student(F)174 D.add_student(G)175 F.add_student(C)176 E.add_student(A)177 R.add_student(Y)178 H.add_student(J)179 I.add_student(J)180 J.add_student(X)181 Y.add_student(H)182 M.add_student(B)183 K.add_student(L)184 K.add_student(M)185 K.add_student(N)186 K.add_student(O)187 L.add_student(P)188 N.add_student(Q)189 N.add_student(R)190 N.add_student(S)191 N.add_student(V)192 S.add_student(T)193 T.add_student(U)194 V.add_student(W)195 S.add_student(W)196 O.add_student(Z)197 Y.add_student(AA)198 Y.add_student(AB)199 Y.add_student(AC)200 H.add_student(AD)201 X.add_student(AE)202 O.add_student(AF)203 M.add_student(AG)204 K.add_student(AH)205 K.add_student(AI)206 AA.add_student(AJ)207 AA.add_student(AK)208 AA.add_student(AL)209 AC.add_student(AM)210 AC.add_student(AN)211 AC.add_student(AO)212 AC.add_student(AP)213 net = VisualNetwork()214 net.add_user(A)215 net.add_user(B)216 net.add_user(C)217 net.add_user(D)218 net.add_user(E)219 net.add_user(F)220 net.add_user(G)221 net.add_user(H)222 net.add_user(I)223 net.add_user(J)224 net.add_user(K)225 net.add_user(L)226 net.add_user(M)227 net.add_user(N)228 net.add_user(O)229 net.add_user(P)230 net.add_user(Q)231 net.add_user(R)232 net.add_user(S)233 net.add_user(T)234 net.add_user(U)235 net.add_user(V)236 net.add_user(W)237 net.add_user(X)238 net.add_user(Y)239 net.add_user(Z)240 net.add_user(AA)241 net.add_user(AB)242 net.add_user(AC)243 net.add_user(AD)244 net.add_user(AE)245 net.add_user(AF)246 net.add_user(AG)247 net.add_user(AH)248 net.add_user(AI)249 net.add_user(AJ)250 net.add_user(AK)251 net.add_user(AL)252 net.add_user(AM)253 net.add_user(AN)254 net.add_user(AO)255 net.add_user(AP)256 return net257# Circular Network258def network_4():259 A = VisualUser("A", DEFAULT_NODE_COLOR)260 B = VisualUser("B", DEFAULT_NODE_COLOR)261 C = VisualUser("C", DEFAULT_NODE_COLOR)262 D = VisualUser("D", DEFAULT_NODE_COLOR)263 E = VisualUser("E", DEFAULT_NODE_COLOR)264 F = VisualUser("F", DEFAULT_NODE_COLOR)265 G = VisualUser("G", DEFAULT_NODE_COLOR)266 A.add_student(B)267 B.add_student(C)268 C.add_student(D)269 D.add_student(E)270 E.add_student(F)271 F.add_student(G)272 G.add_student(A)273 net = VisualNetwork()274 net.add_user(A)275 net.add_user(B)276 net.add_user(C)277 net.add_user(D)278 net.add_user(E)279 net.add_user(F)280 net.add_user(G)281 return net282############################################################283small_network = network_1()284medium_network = network_2()285large_network = network_3()...
service.py
Source:service.py
1import mysql.connector2from datetime import date , timedelta34def addUserdetails(Ee, Pp, Nn):5 cnx = mysql.connector.connect(user='root', password='root',host='127.0.0.1',database='hello_fresh')6 cursor = cnx.cursor()7 add_user = ("INSERT INTO user_details (email_id, user_name, password) VALUES (%s, %s, %s)")8 data_user = (Ee, Nn, Pp)9 cursor.execute(add_user,data_user)10 print(cursor._executed)11 cnx.commit()12 cnx.close()1314def checkUserdetails(Ee, Pp):15 cnx = mysql.connector.connect(user='root', password='root',host='127.0.0.1',database='hello_fresh')16 cursor = cnx.cursor()17 add_user = ("Select password from user_details where email_id = '{}'".format(Ee))18 cursor.execute(add_user)19 myresult = cursor.fetchone()20 print(cursor._executed)21 cnx.close()22 if myresult[0] == Pp :23 return True24 else :25 return False2627def getProducts() :28 cnx = mysql.connector.connect(user='root', password='root',host='127.0.0.1',database='hello_fresh')29 cursor = cnx.cursor()30 add_user = ("Select * from product")31 cursor.execute(add_user)32 myresult = cursor.fetchall()33 print(cursor._executed)34 for result in myresult :35 print(result)36 cnx.close()37 return myresult3839def getProductsforCart(productName) :40 cnx = mysql.connector.connect(user='root', password='root',host='127.0.0.1',database='salon_service')41 cursor = cnx.cursor()42 add_user = ("Select * from product where name = '{}'".format(productName))43 cursor.execute(add_user)44 myresult = cursor.fetchone()45 print(cursor._executed)46 cnx.close()47 return myresult484950def addBillingInfo(form,emailid):51 cnx = mysql.connector.connect(user='root', password='root',host='127.0.0.1',database='salon_service')52 cursor = cnx.cursor()53 add_user = ("INSERT INTO billinginfo (EmailId, Address,City,State,Zip,FullName) VALUES (%s, %s,%s, %s,%s, %s)")54 data_user = (emailid, form["address"],form["city"],form["state"],form["zip"],form["firstname"])55 cursor.execute(add_user,data_user)56 print(cursor._executed)57 cnx.commit()58 cnx.close()5960def addPaymentInfo(form,emailid):61 cnx = mysql.connector.connect(user='root', password='root',host='127.0.0.1',database='salon_service')62 cursor = cnx.cursor()63 add_user = ("INSERT INTO payment_info (EmailId, NameOnCard,CreditCardNumber,ExpMonth,ExpYear) VALUES (%s, %s,%s, %s,%s)")64 data_user = (emailid, form["cardname"],form["cardnumber"],form["expmonth"],form["expyear"])65 cursor.execute(add_user,data_user)66 print(cursor._executed)67 cnx.commit()68 cnx.close()6970def addBookingInfo(form,emailid,bookingNumber):71 cnx = mysql.connector.connect(user='root', password='root',host='127.0.0.1',database='salon_service')72 cursor = cnx.cursor()73 add_user = ("INSERT INTO bookingdetails (EmailId, ServiceType,AppointmentDate,AppointmentTime) VALUES (%s, %s,%s, %s)")74 data_user = (emailid,form["service"],form["bookingDate"],form["appt"])75 cursor.execute(add_user,data_user)76 print(cursor._executed)77 cnx.commit()78 cnx.close()7980def addQueryInfo(form,emailid):81 cnx = mysql.connector.connect(user='root', password='root',host='127.0.0.1',database='salon_service')82 cursor = cnx.cursor()83 add_user = ("INSERT INTO query_details (EmailId, ServiceType,Query) VALUES (%s, %s,%s)")84 data_user = (emailid,form["service"],form["query"])85 cursor.execute(add_user,data_user)86 print(cursor._executed)87 cnx.commit()88 cnx.close()8990def addOrderInfo(form,session,OrderNumber):91 today = date.today().strftime('%A %d %B %Y')92 cnx = mysql.connector.connect(user='root', password='root',host='127.0.0.1',database='salon_service')93 cursor = cnx.cursor()94 add_user = ("INSERT INTO order_details (EmailId,OrderNumber,TotalAmount,OrderDate,ShippingDate) VALUES (%s, %s,%s, %s,%s)")95 data_user = (session["emailId"],OrderNumber,session["total_cart_amt"],today,session["shippingDate"])96 cursor.execute(add_user,data_user)97 print(cursor._executed)98 cnx.commit()99 cnx.close()
...
assert_users.py
Source:assert_users.py
1import unittest2class UserStoreAsserts(unittest.TestCase):3 def assert_user_storage(self, store):4 store.empty()5 store.add_user('1', "console")6 store.add_user('1', "facebook")7 store.add_user('2', "console")8 store.add_user('3', "twitter")9 store.add_user('4', "facebook")10 store.add_user('5', "console")11 store.commit()12 self.assertTrue(store.exists('1', "console"))13 self.assertFalse(store.exists('2', "facebook"))14 links = store.get_links('1')15 self.assertEqual(['console', "facebook"], links)16 links = store.get_links('999')17 self.assertEqual([], links)18 self.assertTrue(store.remove_user('1', "console"))19 self.assertFalse(store.exists('1', "console"))20 store.add_user('1', "console")21 self.assertTrue(store.exists('1', "console"))22 self.assertTrue(store.exists('1', "facebook"))23 self.assertTrue(store.remove_user_from_all_clients('1'))24 self.assertFalse(store.exists('1', "console"))25 self.assertFalse(store.exists('1', "facebook"))26 def assert_remove_user_exception(self, store):27 store.empty()28 store.add_user('1', "console")29 store.add_user('1', "facebook")30 store.add_user('2', "console")31 store.add_user('3', "twitter")32 store.add_user('4', "facebook")33 store.add_user('5', "console")34 store.commit()35 self.assertTrue(store.exists('1', "console"))36 self.assertFalse(store.exists('2', "facebook"))37 links = store.get_links('1')38 self.assertEqual(['console', "facebook"], links)39 links = store.get_links('999')40 self.assertEqual([], links)41 self.assertFalse(store.remove_user('1', "console"))42 def assert_remove_user_from_all_clients_exception(self, store):43 store.empty()44 store.add_user('1', "console")45 store.add_user('1', "facebook")46 store.add_user('2', "console")47 store.add_user('3', "twitter")48 store.add_user('4', "facebook")49 store.add_user('5', "console")50 store.commit()51 self.assertTrue(store.exists('1', "console"))52 self.assertFalse(store.exists('2', "facebook"))53 links = store.get_links('1')54 self.assertEqual(['console', "facebook"], links)55 links = store.get_links('999')56 self.assertEqual([], links)57 self.assertTrue(store.remove_user('1', "console"))58 self.assertFalse(store.exists('1', "console"))59 store.add_user('1', "console")60 self.assertTrue(store.exists('1', "console"))61 self.assertTrue(store.exists('1', "facebook"))...
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!!