def test_callback_form_with_no_name_and_phone(self):
     form = CallbackForm({})
     self.assertFalse(form.is_valid())
     self.assertEqual(
         form.errors, {
             'name': ['Это поле обязательно.'],
             'phone': ['Это поле обязательно.'],
         })
 def test_callback_form_phone_title(self):
     form = CallbackForm()
     self.assertEqual(form.fields['phone'].widget.attrs['title'],
                      'Пример: 80XXYYYYYYY')
 def test_callback_form_phone_class(self):
     form = CallbackForm()
     self.assertEqual(form.fields['phone'].widget.attrs['class'],
                      'form-control')
 def test_callback_form_phone_required(self):
     form = CallbackForm()
     self.assertEqual(form.fields['phone'].widget.attrs['required'], 'True')
 def test_callback_form_phone_placeholder(self):
     form = CallbackForm()
     self.assertEqual(form.fields['phone'].widget.attrs['placeholder'],
                      'Телефон')
 def test_callback_form_phone_field_label(self):
     form = CallbackForm()
     self.assertTrue(form.fields['phone'].label, 'Номер телефона')
 def test_callback_form_name_title(self):
     form = CallbackForm()
     self.assertEqual(form.fields['name'].widget.attrs['title'], 'Ваше имя')
 def test_callback_form_name_placeholder(self):
     form = CallbackForm()
     self.assertEqual(form.fields['name'].widget.attrs['placeholder'],
                      'Имя')
 def test_callback_form_name_field_label_length(self):
     form = CallbackForm()
     self.assertTrue(form.fields['name'].max_length, 50)
 def test_callback_form_name_field_label(self):
     form = CallbackForm()
     self.assertTrue(form.fields['name'].label, 'Имя')
 def test_callback_form_with_name_and_phone(self):
     form = CallbackForm({
         'name': "Leela",
         'phone': "+380123456789",
     })
     self.assertTrue(form.is_valid())
 def test_cart_form_with_normal_quantity(self):
     form = CallbackForm({
         'quantity': "1",
     })
     self.assertFalse(form.is_valid())
 def test_cart_form_with_excess_of_quantity(self):
     form = CallbackForm({
         'quantity': "21",
     })
     self.assertFalse(form.is_valid())