How to use add_join method in autotest

Best Python code snippet using autotest_python

test_osv.py

Source:test_osv.py Github

copy

Full Screen

...6 def test_basic_query(self):7 query = Query()8 query.tables.extend(['"product_product"', '"product_template"'])9 query.where_clause.append("product_product.template_id = product_template.id")10 query.add_join(("product_template", "product_category", "categ_id", "id", "categ_id"), implicit=False, outer=False) # add normal join11 query.add_join(("product_product", "res_user", "user_id", "id", "user_id"), implicit=False, outer=True) # outer join12 self.assertEquals(query.get_sql()[0].strip(),13 """"product_product" LEFT JOIN "res_user" as "product_product__user_id" ON ("product_product"."user_id" = "product_product__user_id"."id"),"product_template" JOIN "product_category" as "product_template__categ_id" ON ("product_template"."categ_id" = "product_template__categ_id"."id") """.strip())14 self.assertEquals(query.get_sql()[1].strip(), """product_product.template_id = product_template.id""".strip())15 def test_query_chained_explicit_joins(self):16 query = Query()17 query.tables.extend(['"product_product"', '"product_template"'])18 query.where_clause.append("product_product.template_id = product_template.id")19 query.add_join(("product_template", "product_category", "categ_id", "id", "categ_id"), implicit=False, outer=False) # add normal join20 query.add_join(("product_template__categ_id", "res_user", "user_id", "id", "user_id"), implicit=False, outer=True) # CHAINED outer join21 self.assertEquals(query.get_sql()[0].strip(),22 """"product_product","product_template" JOIN "product_category" as "product_template__categ_id" ON ("product_template"."categ_id" = "product_template__categ_id"."id") LEFT JOIN "res_user" as "product_template__categ_id__user_id" ON ("product_template__categ_id"."user_id" = "product_template__categ_id__user_id"."id")""".strip())23 self.assertEquals(query.get_sql()[1].strip(), """product_product.template_id = product_template.id""".strip())24 def test_mixed_query_chained_explicit_implicit_joins(self):25 query = Query()26 query.tables.extend(['"product_product"', '"product_template"'])27 query.where_clause.append("product_product.template_id = product_template.id")28 query.add_join(("product_template", "product_category", "categ_id", "id", "categ_id"), implicit=False, outer=False) # add normal join29 query.add_join(("product_template__categ_id", "res_user", "user_id", "id", "user_id"), implicit=False, outer=True) # CHAINED outer join30 query.tables.append('"account.account"')31 query.where_clause.append("product_category.expense_account_id = account_account.id") # additional implicit join32 self.assertEquals(query.get_sql()[0].strip(),33 """"product_product","product_template" JOIN "product_category" as "product_template__categ_id" ON ("product_template"."categ_id" = "product_template__categ_id"."id") LEFT JOIN "res_user" as "product_template__categ_id__user_id" ON ("product_template__categ_id"."user_id" = "product_template__categ_id__user_id"."id"),"account.account" """.strip())34 self.assertEquals(query.get_sql()[1].strip(), """product_product.template_id = product_template.id AND product_category.expense_account_id = account_account.id""".strip())35 def test_raise_missing_lhs(self):36 query = Query()37 query.tables.append('"product_product"')...

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:

YouTube

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?

Helpful

NotHelpful