def test_list_osystem_choices_doesnt_duplicate(self): self.assertEqual( [('custom', 'Custom')], list_osystem_choices( [ {'name': 'custom', 'title': 'Custom'}, {'name': 'custom', 'title': 'Custom'}, ], include_default=False))
def test_list_osystem_choices_doesnt_duplicate(self): self.assertEqual( [("custom", "Custom")], list_osystem_choices( [ {"name": "custom", "title": "Custom"}, {"name": "custom", "title": "Custom"}, ], include_default=False, ), )
def osinfo(self, params): """Return all available operating systems and releases information.""" releases = list_all_usable_releases() osystems = list_all_usable_osystems(releases) kernels = list_all_usable_hwe_kernels(releases) return { "osystems": list_osystem_choices(osystems, include_default=False), "releases": list_release_choices(releases, include_default=False), "kernels": kernels, "default_osystem": Config.objects.get_config("default_osystem"), "default_release": Config.objects.get_config("default_distro_series"), }
def make_default_osystem_field(*args, **kwargs): """Build and return the default_osystem field.""" usable_oses = list_all_usable_osystems() os_choices = list_osystem_choices(usable_oses, include_default=False) if len(os_choices) == 0: os_choices = [("---", "--- No Usable Operating System ---")] field = forms.ChoiceField( initial=Config.objects.get_config("default_osystem"), choices=os_choices, validators=[validate_missing_boot_images], error_messages={ "invalid_choice": compose_invalid_choice_text("osystem", os_choices) }, **kwargs) return field
def test_list_osystem_choices_uses_name_and_title(self): osystem = make_rpc_osystem() self.assertEqual( [(osystem["name"], osystem["title"])], list_osystem_choices([osystem], include_default=False), )
def test_list_osystem_choices_doesnt_include_default(self): self.assertEqual([], list_osystem_choices([], include_default=False))
def test_list_osystem_choices_includes_default(self): self.assertEqual( [("", "Default OS")], list_osystem_choices([], include_default=True), )