Esempio n. 1
0
 def test_menu_form_no_exp_date_set(self):
     """Form with no expiration date set."""
     form_data = ({
         'season': 'Spring/Summer',
         'items': [1, 3],
         'expiration_date': ''
     })
     form = MenuForm(data=form_data, choices=ALL_ITEMS)
     self.assertFalse(form.is_valid())
Esempio n. 2
0
 def test_menu_form_exp_date_in_past(self):
     """Form with  expiration date set in the past."""
     form_data = ({
         'season': 'Spring/Summer',
         'items': [1, 3],
         'expiration_date': MINUS_TWO_WEEKS
     })
     form = MenuForm(data=form_data, choices=ALL_ITEMS)
     self.assertFalse(form.is_valid())
Esempio n. 3
0
 def test_menu_form_invalid_no_items(self):
     """Form with no items selcetd."""
     form_data = ({
         'season': 'Spring/Summer',
         'items': [],
         'expiration_date': PLUS_TWO_WEEKS
     })
     form = MenuForm(data=form_data, choices=ALL_ITEMS)
     self.assertFalse(form.is_valid())
Esempio n. 4
0
 def test_menu_form_invalid_season_contains_brandname(self):
     """Form with no season > chars."""
     form_data = ({
         'season': 'Spring with Coca-Cola',
         'items': [1, 3],
         'expiration_date': PLUS_TWO_WEEKS
     })
     form = MenuForm(data=form_data, choices=ALL_ITEMS)
     self.assertFalse(form.is_valid())
Esempio n. 5
0
 def test_menu_form_invalid_season_missing(self):
     """Form with no season input"""
     form_data = ({
         'season': '',
         'items': [1, 3],
         'expiration_date': PLUS_TWO_WEEKS
     })
     form = MenuForm(data=form_data, choices=ALL_ITEMS)
     self.assertFalse(form.is_valid())
Esempio n. 6
0
 def test_menu_form_valid(self):
     """Form with valid data input"""
     form_data = ({
         'season': 'Spring/Summer',
         'items': [1, 3],
         'expiration_date': PLUS_TWO_WEEKS
     })
     form = MenuForm(data=form_data, choices=ALL_ITEMS)
     self.assertTrue(form.is_valid())
Esempio n. 7
0
    def test_menu_form_invalid_items(self):

        form = MenuForm(
            data={
                'season': self.menu.season,
                'items': ['1'],
                'expiration_date': self.menu.expiration_date
            })

        self.assertFalse(form.is_valid())
Esempio n. 8
0
    def test_menu_form_valid_data(self):

        form = MenuForm(
            data={
                'season': self.menu.season,
                'items': ['1', '2'],
                'expiration_date': self.menu.expiration_date
            })

        self.assertTrue(form.is_valid())
Esempio n. 9
0
 def test_menu_form_invalid_season_too_long(self):
     """Form with no season > chars."""
     form_data = ({
         'season':
         'Spring/Summer Spring/Summer Spring/Summer Spring/Summer Spring/Summer',
         'items': [1, 3],
         'expiration_date': PLUS_TWO_WEEKS
     })
     form = MenuForm(data=form_data, choices=ALL_ITEMS)
     self.assertFalse(form.is_valid())
Esempio n. 10
0
    def test_menu_form_no_data(self):
        form = MenuForm(data={})

        self.assertFalse(form.is_valid())
        self.assertEquals(len(form.errors), 3)