def _determine_options(args, repo): # combine all the available configs default_config = abdt_repooptions.make_default_data() args_config = _make_config_from_args(args) repo_config = abdt_repooptions.data_from_repo_or_none(repo) config = abdt_repooptions.merge_data_objects( default_config, args_config, repo_config) abdt_repooptions.validate_data(config) return config
def test_B_Combine(self): # can override one data with another, only applying non-None attributes data1 = abdt_repooptions.Data() data1.description = '1' data1.branch_url_format = 'format' data1.admin_emails = ['data1_admin'] data2 = abdt_repooptions.Data() data2.description = '2' data2.admin_emails = ['data2_admin1', 'data2_admin2'] all_emails_set = set(data1.admin_emails + data2.admin_emails) data1_2 = abdt_repooptions.merge_data_objects(data1, data2) self.assertEqual(data1_2.description, data2.description) self.assertEqual(data1_2.branch_url_format, data1.branch_url_format) self.assertSetEqual(set(data1_2.admin_emails), all_emails_set) data2_1 = abdt_repooptions.merge_data_objects(data2, data1) self.assertEqual(data2_1.description, data1.description) self.assertEqual(data2_1.branch_url_format, data1.branch_url_format) self.assertSetEqual(set(data1_2.admin_emails), all_emails_set)
def _determine_options(args, repo): # combine all the available configs default_config = abdt_repooptions.make_default_data() args_config = _make_config_from_args(args) # listing the refs of each repo is quite expensive at scale, we're not # making use of this feature at present, so disable it until we have # optimised the ref query # # repo_config = abdt_repooptions.data_from_repo_or_none(repo) _ = repo # NOQA repo_config = None config = abdt_repooptions.merge_data_objects( default_config, args_config, repo_config) abdt_repooptions.validate_data(config) return config