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