def test_form_renders_item_text_input(self):
     form = ItemForm()
Exemple #2
0
 def test_form_save_handles_saving_to_a_list(self):
     form = ItemForm(data={'text': 'do me'})
     new_item = form.save()
 def test_form_validation_for_blank_items(self):
     form = ItemForm(data='')
     self.assertFalse(form.is_valid())
     self.assertEqual(form.errors['text'], [BLANK_ITEM_ERROR])
Exemple #4
0
 def test_fotm_item_input_has_placeholder_and_css_classes(self):
     """тест: поле ввода имеет атрибут placeholder и css слассы"""
     form = ItemForm()
     self.assertIn('placeholder="Enter a to-do item"', form.as_p())
     self.assertIn('class="form-control input-lg"', form.as_p())
Exemple #5
0
 def test_form_renders_item_text_input(self):
     form = ItemForm()
     self.assertIn('placeholder="Enter a to-do item"', form.as_p())
     self.assertIn('class="form-control input-lg"', form.as_p())
Exemple #6
0
 def test_form_renders_item_input_text(self):
     form = ItemForm()
     # self.fail(form.as_p())  # renders the form as HTML.
     self.assertIn('placeholder="Enter a to-do item"', form.as_p())
     self.assertIn('class="form-control input-lg"', form.as_p())
Exemple #7
0
 def test_form_validation_for_blank_items(self):
     form = ItemForm(data={'text': ''})
     form.save()
Exemple #8
0
 def test_form_item_input_has_placeholder_and_css_classes(self):
     form = ItemForm()
     self.assertIn('placeholder="Enter a to-do item"', form.as_p())
     self.assertIn('class="form-control"', form.as_p())
Exemple #9
0
 def test_form_validation_for_duplicate_items(self):
     list_ = List.objects.create()
     Item.objects.create(list=list_, text='no twins!')
     form = ItemForm(for_list=list_, data={'text': 'no twins!'})
     self.assertFalse(form.is_valid())
     self.assertEqual(form.errors['text'], [self.DUPLICATE_ITEM_ERROR])
Exemple #10
0
def home_page(request):
    #if request.method == 'POST':
    #    Item.objects.create(text=request.POST['text'])
    #    return redirect('/lists/the-only-list-in-the-world/')  # always re-direct a POST request, https://en.wikipedia.org/wiki/Post/Redirect/Get
    return render(request, 'home.html', {'form': ItemForm()})
Exemple #11
0
 def test_form_validation_for_blank_items(self):
     list_ = List.objects.create()
     form = ItemForm(for_list=list_, data={'text': ''})
     self.assertFalse(form.is_valid())
     self.assertEqual(form.errors['text'], [self.EMPTY_ITEM_ERROR])
Exemple #12
0
 def test_form_renders_item_text_input(self):
     list_ = List.objects.create()
     form = ItemForm(for_list=list_)
     self.assertIn('placeholder="Enter a to-do item"', form.as_p())
Exemple #13
0
 def test_form_validation_for_blank_items(self):
     form = ItemForm(data={'text': ''})
     self.assertFalse(form.is_valid())
     self.assertEqual(form.errors['text'],
                      list(ItemForm.Meta.error_messages['text'].values()))
Exemple #14
0
    def test_form_renders_item_text_input(self):
        '''тест: тест форма отображается тестовое поле ввода'''

        form = ItemForm()
        self.assertIn('placeholder="Enter a to-do item"', form.as_p())
        self.assertIn('class="form-control input-lg"', form.as_p())
def home_page(request):
    return render(request, "home.html", {"form": ItemForm()})
Exemple #16
0
 def test_form_validation_for_blank_items(self):
     '''тест валидаци формы для пустых элементов'''
     form = ItemForm(data={'text': ''})
     self.assertFalse(form.is_valid())
     self.assertEqual(form.errors['text'], [EMPTY_ITEM_ERROR])
Exemple #17
0
 def test_form_validation_for_blank_items(self):
     form = ItemForm(data={'text': ''})
     self.assertFalse(form.is_valid())
     self.assertEqual(form.errors['text'],
                      ["You can't have an empty list item"])
Exemple #18
0
 def test_form_validation_for_blank_items(self):
     form = ItemForm(data={'text': ''})
     self.assertFalse(form.is_valid())
     self.assertEqual(form.errors['text'], [EMPTY_LIST_ERROR])
Exemple #19
0
def home_page(request):
    """домашняя страница"""
    return render(request, 'home.html', {'form': ItemForm()})
Exemple #20
0
 def test_form_validation_for_blank_items(self):
     form = ItemForm(data={'text': ''})
     self.assertFalse(form.is_valid(
     ))  # checks form validation before we try to save any data
     self.assertEqual(form.errors['text'], [EMPTY_LIST_ERROR])
Exemple #21
0
 def test_form_renders_item_text_input(self):
     form = ItemForm()
     self.fail(form.as_p())
Exemple #22
0
def home_page(request):
    return render(request, 'home.html', {'form': ItemForm()})
Exemple #23
0
 def test_form_item_input_has_placeholder_and_css_classes(self):
     form = ItemForm()
     self.assertIn('placeholder="輸入一個待辦事項"', form.as_p())
     self.assertIn('class="form-control input-lg"', form.as_p())