How to use _add_label_pivot_table_join method in autotest

Best Python code snippet using autotest_python Github


Full Screen

...247 return self.add_join(query_set, 'tko_test_attributes',248 join_key='test_idx',249 join_condition=join_condition,250 suffix=suffix, exclude=exclude)251 def _add_label_pivot_table_join(self, query_set, suffix, join_condition='',252 exclude=False, force_left_join=False):253 return self.add_join(query_set, 'tko_test_labels_tests',254 join_key='test_id',255 join_condition=join_condition,256 suffix=suffix, exclude=exclude,257 force_left_join=force_left_join)258 def _add_label_joins(self, query_set, suffix=''):259 query_set = self._add_label_pivot_table_join(260 query_set, suffix=suffix, force_left_join=True)261 # since we're not joining from the original table, we can't use262 # self.add_join() again263 second_join_alias = 'tko_test_labels' + suffix264 second_join_condition = (' = %s.testlabel_id' %265 (second_join_alias,266 'tko_test_labels_tests' + suffix))267 query_set.query.add_custom_join('tko_test_labels',268 second_join_condition,269 query_set.query.LOUTER,270 alias=second_join_alias)271 return query_set272 def _get_label_ids_from_names(self, label_names):273 label_ids = list( # listifying avoids a double query below274 TestLabel.objects.filter(name__in=label_names)275 .values_list('name', 'id'))276 if len(label_ids) < len(set(label_names)):277 raise ValueError('Not all labels found: %s' %278 ', '.join(label_names))279 return dict(name_and_id for name_and_id in label_ids)280 def _include_or_exclude_labels(self, query_set, label_names, exclude=False):281 label_ids = self._get_label_ids_from_names(label_names).itervalues()282 suffix = self._get_include_exclude_suffix(exclude)283 condition = ('tko_test_labels_tests%s.testlabel_id IN (%s)' %284 (suffix,285 ','.join(str(label_id) for label_id in label_ids)))286 return self._add_label_pivot_table_join(query_set,287 join_condition=condition,288 suffix=suffix,289 exclude=exclude)290 def _add_custom_select(self, query_set, select_name, select_sql):291 return query_set.extra(select={select_name: select_sql})292 def _add_select_value(self, query_set, alias):293 return self._add_custom_select(query_set, alias,294 _quote_name(alias) + '.value')295 def _add_select_ifnull(self, query_set, alias, non_null_value):296 select_sql = "IF( IS NOT NULL, '%s', NULL)" % (_quote_name(alias),297 non_null_value)298 return self._add_custom_select(query_set, alias, select_sql)299 def _join_test_label_column(self, query_set, label_name, label_id):300 alias = 'test_label_' + label_name...

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?