Best Python code snippet using molecule_python
tests.py
Source:tests.py
...15 self.create_campaign_patch = self.create_campaign_patcher.start()16 def tearDown(self):17 self.create_list_patcher.stop()18 self.create_campaign_patcher.stop()19 def test_create_sequence(self):20 now = datetime.datetime.utcnow().date()21 start_date = now + datetime.timedelta(weeks=8)22 signup_close_date = now + datetime.timedelta(weeks=7)23 sequence = sequence_model.create_sequence(24 start_date, signup_close_date25 )26 self.assertIn('global_list', sequence)27 self.assertIn('campaign_id', sequence)28 self.assertEquals(sequence['start_date'], start_date)29 self.assertEquals(sequence['signup_close_date'], signup_close_date)30 self.assertTrue(self.create_list_patch.called)31 self.assertTrue(self.create_campaign_patch.called)32 def test_get_current_sequence(self):33 current_sequence = sequence_model.get_current_sequence()34 self.assertEquals(current_sequence, None)35 now = datetime.datetime.utcnow().date()36 start_date = now + datetime.timedelta(weeks=8)37 signup_close_date = now + datetime.timedelta(weeks=7)38 sequence = sequence_model.create_sequence(39 start_date, signup_close_date40 )41 current_sequence = sequence_model.get_current_sequence()42 self.assertEqual(sequence, current_sequence)43 def test_multiple_sequences(self):44 now = datetime.datetime.utcnow().date()45 start_date = now - datetime.timedelta(days=1)46 signup_close_date = now - datetime.timedelta(days=1)47 sequence_model.create_sequence(48 start_date, signup_close_date49 )50 start_date = now51 signup_close_date = now52 sequence = sequence_model.create_sequence(53 start_date, signup_close_date54 )55 start_date = now + datetime.timedelta(days=1)56 signup_close_date = now + datetime.timedelta(days=1)57 sequence_model.create_sequence(58 start_date, signup_close_date59 )60 current_sequence = sequence_model.get_current_sequence()61 self.assertEqual(sequence, current_sequence)62 def test_get_all_sequences(self):63 now = datetime.datetime.utcnow().date()64 start_date = now - datetime.timedelta(weeks=16)65 signup_close_date = now - datetime.timedelta(weeks=17)66 sequence_model.create_sequence(67 start_date, signup_close_date68 )69 start_date = now + datetime.timedelta(weeks=8)70 signup_close_date = now + datetime.timedelta(weeks=7)71 sequence = sequence_model.create_sequence(72 start_date, signup_close_date73 )74 start_date = now + datetime.timedelta(weeks=16)75 signup_close_date = now + datetime.timedelta(weeks=15)76 sequence_model.create_sequence(77 start_date, signup_close_date78 )79 all_sequences = sequence_model.get_all_sequences()80 self.assertEqual(len(all_sequences), 3)81 self.assertEqual(sequence, all_sequences[1])82 def test_get_current_sequence_number(self):83 cs = sequence_model.get_current_sequence()84 csn = sequence_model.get_current_sequence_number()85 self.assertIsNone(cs)86 self.assertIsNone(csn)87 # test sequence in the past88 now = datetime.datetime.utcnow().date()89 start_date = now - datetime.timedelta(weeks=16)90 signup_close_date = now - datetime.timedelta(weeks=17)91 sequence_model.create_sequence(92 start_date, signup_close_date93 )94 cs = sequence_model.get_current_sequence()95 csn = sequence_model.get_current_sequence_number()96 self.assertIsNone(cs)97 self.assertIsNone(csn)98 start_date = now + datetime.timedelta(weeks=16)99 signup_close_date = now + datetime.timedelta(weeks=17)100 sequence_model.create_sequence(101 start_date, signup_close_date102 )103 cs = sequence_model.get_current_sequence()104 csn = sequence_model.get_current_sequence_number()...
test_data_sending_functions.py
Source:test_data_sending_functions.py
...16 self.dbconn.commit()17 self.dbconn.close()18 self.dbconn = psycopg2.connect("host=localhost dbname=testing_grounds user=postgres password=1234 port=5432")19 self.cursor = self.dbconn.cursor()20 self.cursor.execute(create_sequence("option_types") + create_sequence("option_value_variants") +21 create_sequence("option_values") + create_sequence("product_categories") +22 create_sequence("product_files") + create_sequence("product_option_types") +23 create_sequence("products") + create_sequence("stores") +24 create_sequence("variant_files") + create_sequence("variant_stores") +25 create_sequence("variants"))26 self.cursor.execute(create_option_types + create_option_value_variants +27 create_option_values + create_product_categories +28 create_product_files + create_product_option_types +29 create_products + create_stores + create_variant_files +30 create_variant_stores + create_variants)31 self.dbconn.commit()32 def tearDown(self):33 self.dbconn.close()34 def test_store_insert(self):35 expected = "butterix"36 data_sending.insert_store(cursor, "butterix", ["bananabox", "lololGames", "TeeTees.com"], [True]*3)37 self.cursor.execute("select name from stores desc limit 1")38 actual_value = self.cursor.fetchone()[0]39 self.assertEqual(expected, actual_value)...
test_data_retrieval_functions.py
Source:test_data_retrieval_functions.py
...15 self.dbconn.commit()16 self.dbconn.close()17 self.dbconn = psycopg2.connect("host=localhost dbname=testing_grounds user=postgres password=1234 port=5432")18 self.cursor = self.dbconn.cursor()19 self.cursor.execute(create_sequence("option_types") + create_sequence("option_value_variants") +20 create_sequence("option_values") + create_sequence("product_categories") +21 create_sequence("product_files") + create_sequence("product_option_types") +22 create_sequence("products") + create_sequence("stores") +23 create_sequence("variant_files") + create_sequence("variant_stores") +24 create_sequence("variants"))25 self.cursor.execute(create_option_types + create_option_value_variants +26 create_option_values + create_product_categories +27 create_product_files + create_product_option_types +28 create_products + create_stores + create_variant_files +29 create_variant_stores + create_variants)30 self.dbconn.commit()31 def tearDown(self):...
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!!