Ejemplo n.º 1
0
 def test_partial_form(self):
     form = EntryLinkForm(data={'name': 'blah', 'url': ''},
                          instance=ExternalLink.objects.get())
     
     assert not form.is_blank()
     assert not form.is_valid()
     assert form.errors
Ejemplo n.º 2
0
 def test_blank_new_object(self):
     form = EntryLinkForm(data={})
     assert form.is_blank()
     assert form.is_valid()
     assert not form.errors
     
     form.save()
     assert_equal(ExternalLink.objects.count(), 0)
Ejemplo n.º 3
0
 def test_empty_form(self):
     """Test that an empty form triggers a deletion."""
     form = EntryLinkForm(data={}, instance=ExternalLink.objects.get())
     assert form.is_blank()
     assert form.is_valid()
     assert not form.errors
     
     form.save()
     
     assert_equal(ExternalLink.objects.count(), 0)
Ejemplo n.º 4
0
 def test_new_object(self):
     form = EntryLinkForm(data={'name': 'fish', 'url': 'http://example.com/'})
     assert not form.is_blank()
     assert form.is_valid()
     assert not form.errors
 
     form.save()
     link = ExternalLink.objects.get()
     assert_equal(link.name, 'fish')
     assert_equal(link.url, 'http://example.com/')
Ejemplo n.º 5
0
    def test_partial_form(self):
        form = EntryLinkForm(data={
            'name': 'blah',
            'url': ''
        },
                             instance=ExternalLink.objects.get())

        assert not form.is_blank()
        assert not form.is_valid()
        assert form.errors
Ejemplo n.º 6
0
    def test_blank_new_object(self):
        form = EntryLinkForm(data={})
        assert form.is_blank()
        assert form.is_valid()
        assert not form.errors

        form.save()
        assert_equal(ExternalLink.objects.count(), 0)
Ejemplo n.º 7
0
    def test_empty_form(self):
        """Test that an empty form triggers a deletion."""
        form = EntryLinkForm(data={}, instance=ExternalLink.objects.get())
        assert form.is_blank()
        assert form.is_valid()
        assert not form.errors

        form.save()

        assert_equal(ExternalLink.objects.count(), 0)
Ejemplo n.º 8
0
    def test_new_object(self):
        form = EntryLinkForm(data={
            'name': 'fish',
            'url': 'http://example.com/'
        })
        assert not form.is_blank()
        assert form.is_valid()
        assert not form.errors

        form.save()
        link = ExternalLink.objects.get()
        assert_equal(link.name, 'fish')
        assert_equal(link.url, 'http://example.com/')
Ejemplo n.º 9
0
 def test_partial_new_object(self):
     form = EntryLinkForm(data={'name': 'foo', 'url': ''})
     assert not form.is_blank()
     assert not form.is_valid()
     assert form.errors
Ejemplo n.º 10
0
 def test_partial_new_object(self):
     form = EntryLinkForm(data={'name': 'foo', 'url': ''})
     assert not form.is_blank()
     assert not form.is_valid()
     assert form.errors