(self)
| 705 | # radio_fields behavior ########################################### |
| 706 | |
| 707 | def test_default_foreign_key_widget(self): |
| 708 | # First, without any radio_fields specified, the widgets for ForeignKey |
| 709 | # and fields with choices specified ought to be a basic Select widget. |
| 710 | # ForeignKey widgets in the admin are wrapped with |
| 711 | # RelatedFieldWidgetWrapper so they need to be handled properly when |
| 712 | # type checking. For Select fields, all of the choices lists have a |
| 713 | # first entry of a translatable blank choice label. |
| 714 | blank_option = ("", get_blank_choice_label()) |
| 715 | cma = ModelAdmin(Concert, self.site) |
| 716 | cmafa = cma.get_form(request) |
| 717 | |
| 718 | self.assertEqual(type(cmafa.base_fields["main_band"].widget.widget), Select) |
| 719 | self.assertEqual( |
| 720 | list(cmafa.base_fields["main_band"].widget.choices), |
| 721 | [blank_option, (self.band.id, "The Doors")], |
| 722 | ) |
| 723 | |
| 724 | self.assertEqual(type(cmafa.base_fields["opening_band"].widget.widget), Select) |
| 725 | self.assertEqual( |
| 726 | list(cmafa.base_fields["opening_band"].widget.choices), |
| 727 | [blank_option, (self.band.id, "The Doors")], |
| 728 | ) |
| 729 | self.assertEqual(type(cmafa.base_fields["day"].widget), Select) |
| 730 | self.assertEqual( |
| 731 | list(cmafa.base_fields["day"].widget.choices), |
| 732 | [blank_option, (1, "Fri"), (2, "Sat")], |
| 733 | ) |
| 734 | self.assertEqual(type(cmafa.base_fields["transport"].widget), Select) |
| 735 | self.assertEqual( |
| 736 | list(cmafa.base_fields["transport"].widget.choices), |
| 737 | [blank_option, (1, "Plane"), (2, "Train"), (3, "Bus")], |
| 738 | ) |
| 739 | |
| 740 | def test_foreign_key_as_radio_field(self): |
| 741 | # Now specify all the fields as radio_fields. Widgets should now be |
nothing calls this directly
no test coverage detected