How to use basic_index_name method in autotest

Best Python code snippet using autotest_python Github


Full Screen

...29 print ('Deleted %s invalid foreign key references from %s (%s)' %30 (deleted_count, pivot_table, foreign_key_field))31def unique_index_name(table):32 return table + '_both_ids'33def basic_index_name(table, field):34 if field == 'aclgroup_id':35 field = 'acl_group_id'36 return table + '_' + field37def create_unique_index(manager, pivot_table, first_field, second_field):38 index_name = unique_index_name(pivot_table)39 manager.execute('CREATE UNIQUE INDEX %s ON %s (%s, %s)' %40 (index_name, pivot_table, first_field, second_field))41 # these indices are in the migrations but may not exist for historical42 # reasons43 old_index_name = basic_index_name(pivot_table, first_field)44 execute_safely(manager, 'DROP INDEX %s ON %s' %45 (old_index_name, pivot_table))46def drop_unique_index(manager, pivot_table, first_field):47 index_name = unique_index_name(pivot_table)48 manager.execute('DROP INDEX %s ON %s' % (index_name, pivot_table))49 old_index_name = basic_index_name(pivot_table, first_field)50 manager.execute('CREATE INDEX %s ON %s (%s)' %51 (old_index_name, pivot_table, first_field))52def foreign_key_name(table, field):53 return '_'.join([table, field, 'fk'])54def create_foreign_key_constraint(manager, table, field, destination_table):55 key_name = foreign_key_name(table, field)56 manager.execute('ALTER TABLE %s ADD CONSTRAINT %s FOREIGN KEY (%s) '57 'REFERENCES %s (id) ON DELETE NO ACTION' %58 (table, key_name, field, destination_table))59def drop_foreign_key_constraint(manager, table, field):60 key_name = foreign_key_name(table, field)61 manager.execute('ALTER TABLE %s DROP FOREIGN KEY %s' % (table, key_name))62def cleanup_m2m_pivot(manager, pivot_table, first_field, first_table,63 second_field, second_table, create_unique):...

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:


You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest 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?