# Path: test_projects/django18/forthewing/models.py
# class ChickenWings(models.Model):
#     """ChickenWings demonstrates optgroup usage and max_choices"""
# 
#     SUICIDE = 's'
#     HOT = 'h'
#     MEDIUM = 'm'
#     MILD = 'M'
#     CAJUN = 'c'
#     JERK = 'j'
#     HONEY_GARLIC = 'g'
#     HONEY_BBQ = 'H'
#     THAI = 't'
#     BACON = 'b'
#     BOURBON = 'B'
#     FLAVOUR_CHOICES = (
#         (_('Hot & Spicy'), (
#             (SUICIDE, _('Suicide hot')),
#             (HOT, _('Hot hot sauce')),
#             (MEDIUM, _('Medium hot sauce')),
#             (MILD, _('Mild hot sauce')),
#             (CAJUN, _('Cajun sauce')),
#             (JERK, _('Jerk sauce')))),
#         (_('Sweets'), (
#             (HONEY_GARLIC, _('Honey garlic')),
#             (HONEY_BBQ, _('Honey barbeque')),
#             (THAI, _('Thai sweet sauce')),
#             (BACON, _('Messy bacon sauce')),
#             (BOURBON, _('Bourbon whiskey barbeque')))),
#     )
#     flavour = SelectMultipleField(
#         blank=True,
#         include_blank=False,
#         max_length=5,
#         max_choices=2,
#         choices=FLAVOUR_CHOICES
#     )
# 
#     def __str__(self):
#         return "pk=%s" % force_text(self.pk)
# 
#     def get_absolute_url(self):
#         return reverse('ftw:detail', args=[self.pk])
# 
# def show_flavour(flavour):
#     """
#     Decode flavour to full name
# 
#     This supports both plain choices and optgroup choices
#     """
#     decoder = dict()
#     for c in ChickenWings.FLAVOUR_CHOICES:
#         if isinstance(c[1], (tuple, list)):
#             for k, v in c[1]:
#                 decoder[k] = v
#         else:
#             decoder[c[0]] = c[1]
# 
#     if flavour in decoder:
#         return force_text(decoder[flavour])
#     else:
#         return force_text('')


from django.core.urlresolvers import reverse
from django.test import SimpleTestCase, TestCase
from django.utils.datastructures import MultiValueDict
from django.utils.http import urlencode
from .models import ChickenWings, show_flavour
            response,
            'http://testserver' + reverse('ftw:updated'))
        p = ChickenWings.objects.all()[0]
        self.assertTrue(ChickenWings.MEDIUM in p.flavour)
        self.assertFalse(ChickenWings.THAI in p.flavour)
        self.assertTrue(ChickenWings.BACON in p.flavour)


class ChickenWingsDeleteViewTestCase(TestCase):

    def setUp(self):
        self.chickenwings = ChickenWings(flavour=[ChickenWings.HONEY_GARLIC])
        self.chickenwings.save()

    def test_delete_chickenwings(self):
        response = self.client.post(
            reverse('ftw:delete', args=[self.chickenwings.id]))
        self.assertRedirects(
            response,
            'http://testserver' + reverse('ftw:deleted'))
        pl = ChickenWings.objects.all()
        self.assertEqual(len(pl), 0)


class ChickenWingsModelTestCase(SimpleTestCase):

    def test_show_flavour(self):
        for k, v in ChickenWings.FLAVOUR_CHOICES:
            if isinstance(v, (list, tuple)):
                for ko, vo in v:

# Path: test_projects/django18/forthewing/models.py
# class ChickenWings(models.Model):
#     """ChickenWings demonstrates optgroup usage and max_choices"""
# 
#     SUICIDE = 's'
#     HOT = 'h'
#     MEDIUM = 'm'
#     MILD = 'M'
#     CAJUN = 'c'
#     JERK = 'j'
#     HONEY_GARLIC = 'g'
#     HONEY_BBQ = 'H'
#     THAI = 't'
#     BACON = 'b'
#     BOURBON = 'B'
#     FLAVOUR_CHOICES = (
#         (_('Hot & Spicy'), (
#             (SUICIDE, _('Suicide hot')),
#             (HOT, _('Hot hot sauce')),
#             (MEDIUM, _('Medium hot sauce')),
#             (MILD, _('Mild hot sauce')),
#             (CAJUN, _('Cajun sauce')),
#             (JERK, _('Jerk sauce')))),
#         (_('Sweets'), (
#             (HONEY_GARLIC, _('Honey garlic')),
#             (HONEY_BBQ, _('Honey barbeque')),
#             (THAI, _('Thai sweet sauce')),
#             (BACON, _('Messy bacon sauce')),
#             (BOURBON, _('Bourbon whiskey barbeque')))),
#     )
#     flavour = SelectMultipleField(
#         blank=True,
#         include_blank=False,
#         max_length=5,
#         max_choices=2,
#         choices=FLAVOUR_CHOICES
#     )
# 
#     def __str__(self):
#         return "pk=%s" % force_text(self.pk)
# 
#     def get_absolute_url(self):
#         return reverse('ftw:detail', args=[self.pk])
# 
# def show_flavour(flavour):
#     """
#     Decode flavour to full name
# 
#     This supports both plain choices and optgroup choices
#     """
#     decoder = dict()
#     for c in ChickenWings.FLAVOUR_CHOICES:
#         if isinstance(c[1], (tuple, list)):
#             for k, v in c[1]:
#                 decoder[k] = v
#         else:
#             decoder[c[0]] = c[1]
# 
#     if flavour in decoder:
#         return force_text(decoder[flavour])
#     else:
#         return force_text('')


# Path: test_projects/django18/forthewing/tests.py
from django.core.urlresolvers import reverse
from django.test import SimpleTestCase, TestCase
from django.utils.datastructures import MultiValueDict
from django.utils.http import urlencode
from .models import ChickenWings, show_flavour

            response,
            'http://testserver' + reverse('ftw:updated'))
        p = ChickenWings.objects.all()[0]
        self.assertTrue(ChickenWings.MEDIUM in p.flavour)
        self.assertFalse(ChickenWings.THAI in p.flavour)
        self.assertTrue(ChickenWings.BACON in p.flavour)


class ChickenWingsDeleteViewTestCase(TestCase):

    def setUp(self):
        self.chickenwings = ChickenWings(flavour=[ChickenWings.HONEY_GARLIC])
        self.chickenwings.save()

    def test_delete_chickenwings(self):
        response = self.client.post(
            reverse('ftw:delete', args=[self.chickenwings.id]))
        self.assertRedirects(
            response,
            'http://testserver' + reverse('ftw:deleted'))
        pl = ChickenWings.objects.all()
        self.assertEqual(len(pl), 0)


class ChickenWingsModelTestCase(SimpleTestCase):

    def test_show_flavour(self):
        for k, v in ChickenWings.FLAVOUR_CHOICES:
            if isinstance(v, (list, tuple)):
                for ko, vo in v:

                    flavour_name = show_flavour(ko)