Best Python code snippet using hypothesis
test_database.py
Source:test_database.py
...48 'phone_number': '206-614-6372',49 'email_address': 'sysult@aol.com',50 'active_status': False,51 'credit_limit': 50.00}52def clear_database():53 '''54 Testing clearing the DB55 '''56 cs.database.drop_tables([57 cs.Customer58 ])59 cs.database.close()60def create_empty_database():61 '''62 Testing DB initializtion63 '''64 clear_database()65 cc.main()66def test_add_customers():67 create_empty_database()68 bops.add_customer(**customer1)69 bops.add_customer(**customer2)70 test_customer1 = cs.Customer.get(cs.Customer.customer_id == '1')71 assert test_customer1.first_name == customer1['first_name']72 assert test_customer1.last_name == customer1['last_name']73 test_customer2 = cs.Customer.get(cs.Customer.customer_id == '2')74 assert test_customer2.first_name == customer2['first_name']75 assert test_customer2.last_name == customer2['last_name']76 clear_database()77def test_add_customers_duplicate():78 create_empty_database()79 bops.add_customer(**customer1)80 with pytest.raises(peewee.IntegrityError):81 bops.add_customer(**customer1)82 clear_database()83def create_sample_database():84 clear_database()85 cs.database.create_tables([86 cs.Customer87 ])88 bops.add_customer(**customer1)89 bops.add_customer(**customer2)90 bops.add_customer(**customer3)91 bops.add_customer(**customer4)92 cs.database.close()93def test_customer_search():94 create_sample_database()95 test_customer = bops.search_customer('3')96 assert test_customer['email_address'] == customer3['email_address']97 clear_database()98def test_search_customer_missing():99 create_sample_database()100 assert bops.search_customer('8') == dict()101 clear_database()102def test_update_credit():103 create_sample_database()104 bops.update_customer_credit('1', 25500)105 cust_update = cs.Customer.get(cs.Customer.customer_id == 1)106 assert cust_update.credit_limit == 25500107 clear_database()108def test_update_credit_none():109 create_sample_database()110 with pytest.raises(peewee.DoesNotExist):111 bops.update_customer_credit('44', 5000)112 clear_database()113def test_list_customers():114 create_sample_database()115 assert bops.list_active_customers() == 2116 clear_database()117def test_list_customers_none():118 create_empty_database()119 assert bops.list_active_customers() == 0120 clear_database()121def test_all():122 '''123 Okay, this one I'm commenting. I will be populating a DB and testing all124 the functions against an integrated system. Wish me luck125 '''126 create_empty_database()127 bops.add_customer(**customer1)128 bops.add_customer(**customer2)129 bops.add_customer(**customer3)130 bops.add_customer(**customer4)131 '''132 Here, we will delete Kim Deal. Which is a shame, I loved The Breeders when133 I was a kid134 '''...
app.py
Source:app.py
...16 return query_text.query_text(flask.request)17@app.route('/clear_database', methods=['GET', 'POST'])18def clearDatabase():19 print(flask.request)20 return clear_database.clear_database(flask.request)...
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!!