Skip to content

Commit

Permalink
Merge pull request #33 from matagus/more-tests-100%
Browse files Browse the repository at this point in the history
More tests to reach 100% coverage + added codespell to pre-commit hooks
  • Loading branch information
matagus authored Feb 10, 2024
2 parents f126f78 + 654cd21 commit afc60bb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ repos:
rev: v2.2.6
hooks:
- id: codespell
args:
- "--write-changes"

- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
Expand Down
11 changes: 0 additions & 11 deletions manage.py

This file was deleted.

14 changes: 13 additions & 1 deletion tests/test_forms.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase

from generic_links.forms import AddLinkForm


class AddFormTest(TestCase):
def setUp(self):
self.initial_kwargs = dict(user=None, object_id="1", content_type="1")
content_type = ContentType.objects.get_for_model(User)
self.initial_kwargs = dict(user=None, object_id=1, content_type=content_type)

def test_add_form_without_data(self):
form = AddLinkForm(**self.initial_kwargs)
Expand All @@ -18,3 +21,12 @@ def test_add_form_with_incomplete_data(self):
def test_add_form_with_complete_data(self):
form = AddLinkForm(data={"url": "http://www.example.com", "title": "Example"}, **self.initial_kwargs)
self.assertTrue(form.is_valid())

new_link = form.save()
print(new_link.content_object)
self.assertEqual(new_link.url, "http://www.example.com")
self.assertEqual(new_link.title, "Example")
self.assertEqual(new_link.user, None)
self.assertEqual(new_link.object_id, 1)
self.assertEqual(new_link.content_type_id, self.initial_kwargs["content_type"].id)
self.assertEqual(new_link.is_external, False)

0 comments on commit afc60bb

Please sign in to comment.