Skip to content

More tests to reach 100% coverage + added codespell to pre-commit hooks #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)