Best Python code snippet using autotest_python
db_utils_unittest.py
Source:db_utils_unittest.py
...18 def test_check_exists(self):19 views = ('view1', 'view2')20 def _call_check_exists():21 db_utils.check_exists(self.manager, views, db_utils.VIEW_TYPE)22 self._setup_exists_expects(views, 'VIEWS')23 _call_check_exists()24 self.god.check_playback()25 self._setup_exists_expects(('view1',), 'VIEWS')26 self.assertRaises(Exception, _call_check_exists)27 self.god.check_playback()28 def test_drop_views(self):29 views = ('view1', 'view2')30 self._setup_exists_expects(views, 'VIEWS')31 for view in views:32 self.manager.execute.expect_call('DROP VIEW `%s`' % view)33 db_utils.drop_views(self.manager, views)34 self.god.check_playback()35 def test_rename(self):36 mapping = {37 'table1' : 'new_table1',38 'table2' : 'new_table2',39 }40 self._setup_exists_expects((name for name, _ in mapping.iteritems()),41 'TABLES')42 for name, new_name in mapping.iteritems():43 self.manager.execute.expect_call(44 'RENAME TABLE `%s` TO `%s`' % (name, new_name))45 db_utils.rename(self.manager, mapping)46 self.god.check_playback()47 def _setup_exists_expects(self, names, table):48 self.manager.get_db_name.expect_call().and_return(self.DB_NAME)49 self.manager.execute.expect_call(50 self.EXISTS_QUERY_BASE % table, self.DB_NAME).and_return(51 self._create_exists_query_result(names))52 def _create_exists_query_result(self, names):53 return ((name, None) for name in names)54if __name__ == '__main__':...
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!!