-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from matagus/more-tests
Added more tests to take coverage close to 100%
- Loading branch information
Showing
4 changed files
with
63 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
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") | ||
|
||
def test_add_form_without_data(self): | ||
form = AddLinkForm(**self.initial_kwargs) | ||
self.assertFalse(form.is_valid()) | ||
|
||
def test_add_form_with_incomplete_data(self): | ||
form = AddLinkForm(data={"url": "http://www.example.com"}, **self.initial_kwargs) | ||
self.assertFalse(form.is_valid()) | ||
|
||
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()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
""" | ||
test_generic_links | ||
------------ | ||
Tests for `generic_links` models module. | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
from django.contrib.auth.models import User | ||
from django.contrib.contenttypes.models import ContentType | ||
from django.test import TestCase | ||
|
||
from generic_links.models import GenericLink | ||
|
||
|
||
class TestGeneric_links(TestCase): | ||
def setUp(self): | ||
pass | ||
class ModelTest(TestCase): | ||
def test_str(self): | ||
user = User.objects.create(username="Test User") | ||
content_type = ContentType.objects.get_for_model(User) | ||
|
||
def test_something(self): | ||
pass | ||
link = GenericLink.objects.create( | ||
title="Test Title", | ||
url="https://www.test.com", | ||
description="Test Description", | ||
content_type=content_type, | ||
object_id=user.id, | ||
) | ||
|
||
def tearDown(self): | ||
pass | ||
self.assertEqual(str(link), f"{link.title} :: {link.url}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters