Ejemplo n.º 1
0
    def test_one_case_selection(self):
        """
        Even there is only one choice, it should be returned always
        """
        field = models.BooleanField(choices=[
            (False, 'This sentence is wrong')])

        result = any_field(field)

        self.assertEqual(bool, type(result))
        self.assertEqual(False, result)
    def test_one_case_selection(self):
        """
        Even there is only one choice, it should be returned always
        """
        field = models.BooleanField(choices=[(False,
                                              'This sentence is wrong')])

        result = any_field(field)

        self.assertEqual(bool, type(result))
        self.assertEqual(False, result)
    def test_choices_named_groups_support(self):
        """
        Group names completely ignored
        """
        MEDIA_CHOICES = (('Audio', (
            ('vinyl', 'Vinyl'),
            ('cd', 'CD'),
        )), ('Video', (
            ('vhs', 'VHS Tape'),
            ('dvd', 'DVD'),
        )), ('unknown', 'Unknown'))
        media = models.CharField(max_length=25, choices=MEDIA_CHOICES)

        result = any_field(media)

        self.assertTrue(result in ['vinyl', 'cd', 'vhs', 'dvd', 'unknown'])
Ejemplo n.º 4
0
    def test_choices_named_groups_support(self):
        """
        Group names completely ignored
        """
        MEDIA_CHOICES = (
            ('Audio', (
                    ('vinyl', 'Vinyl'),
                    ('cd', 'CD'),
                    )),
            ('Video', (
                    ('vhs', 'VHS Tape'),
                    ('dvd', 'DVD'),
                    )),
            ('unknown', 'Unknown'))
        media = models.CharField(max_length=25, choices=MEDIA_CHOICES)

        result = any_field(media)

        self.assertTrue(result in ['vinyl', 'cd', 'vhs', 'dvd', 'unknown'])
Ejemplo n.º 5
0
 def test_deterministic_string(self):
     media = models.CharField(max_length=25)
     result = any_field(media)
     self.assertEqual('SNnz', result)