From 2269a94b65a46c37126a1dd93f41719dbe0f7648 Mon Sep 17 00:00:00 2001 From: Jannik Weyrich Date: Wed, 2 Nov 2016 17:55:15 +1000 Subject: [PATCH] Made changes requested in pull request #48 - issue #28 --- README.rst | 3 +- .../links/{tests/tests_models.py => tests.py} | 39 ++++++++++++++++++- drum/links/tests/__init__.py | 0 drum/links/tests/tests_forms.py | 38 ------------------ requirements.txt | 1 - setup.py | 1 + 6 files changed, 40 insertions(+), 42 deletions(-) rename drum/links/{tests/tests_models.py => tests.py} (56%) delete mode 100644 drum/links/tests/__init__.py delete mode 100644 drum/links/tests/tests_forms.py delete mode 100644 requirements.txt diff --git a/README.rst b/README.rst index ea217bc..277bf1a 100644 --- a/README.rst +++ b/README.rst @@ -146,8 +146,7 @@ Running the tests ================= Install the dependencies specified in requirements.txt and run:: - python runtests.py - + python setup.py test Donating diff --git a/drum/links/tests/tests_models.py b/drum/links/tests.py similarity index 56% rename from drum/links/tests/tests_models.py rename to drum/links/tests.py index 742ea63..5469162 100644 --- a/drum/links/tests/tests_models.py +++ b/drum/links/tests.py @@ -1,10 +1,46 @@ from unittest import TestCase - +from drum.links.forms import LinkForm from django.contrib.auth.models import User from drum.links.models import Link, Profile +class LinkFormsTests(TestCase): + + def test_valid_data(self): + form = LinkForm({ + "title": "Test title", + "link": "http://test.com/", + "description": "Test Desc", + }) + self.assertTrue(form.is_valid()) + + def test_title_may_not_be_empty(self): + form = LinkForm({ + "title": "", + "link": "http://test.com/", + "description": "Test Desc", + }) + self.assertFalse(form.is_valid()) + + def test_link_may_be_empty(self): + form = LinkForm({ + "title": "Test title", + "link": "", + "description": "Test Desc", + }) + self.assertTrue(form.is_valid()) + + def test_description_may_be_empty(self): + form = LinkForm({ + "title": "Test title", + "link": "http://test.com/", + "description": "", + }) + self.assertTrue(form.is_valid()) + + class LinkModelsTests(TestCase): + def test_has_link_field(self): l = Link() self.assertTrue(hasattr(l, 'link')) @@ -19,6 +55,7 @@ def test_has_comments_field(self): class ProfileModelsTests(TestCase): + def setUp(self): self.user = User.objects.create(username='user', password="notsosecure") self.user.profile.website = "http://test.com/" diff --git a/drum/links/tests/__init__.py b/drum/links/tests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/drum/links/tests/tests_forms.py b/drum/links/tests/tests_forms.py deleted file mode 100644 index ca94f32..0000000 --- a/drum/links/tests/tests_forms.py +++ /dev/null @@ -1,38 +0,0 @@ -from unittest import TestCase - -from drum.links.forms import LinkForm - - -class LinkFormsTests(TestCase): - - def test_valid_data(self): - form = LinkForm({ - "title": "Test title", - "link": "http://test.com/", - "description": "Test Desc", - }) - self.assertTrue(form.is_valid()) - - def test_title_may_not_be_empty(self): - form = LinkForm({ - "title": "", - "link": "http://test.com/", - "description": "Test Desc", - }) - self.assertFalse(form.is_valid()) - - def test_link_may_be_empty(self): - form = LinkForm({ - "title": "Test title", - "link": "", - "description": "Test Desc", - }) - self.assertTrue(form.is_valid()) - - def test_description_may_be_empty(self): - form = LinkForm({ - "title": "Test title", - "link": "http://test.com/", - "description": "", - }) - self.assertTrue(form.is_valid()) diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 1ce3d38..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -mezzanine >= 4.2.0 diff --git a/setup.py b/setup.py index 56c49e2..7388ac8 100644 --- a/setup.py +++ b/setup.py @@ -49,6 +49,7 @@ zip_safe=False, include_package_data=True, packages=find_packages(), + test_suite="runtests.main", install_requires=[ "mezzanine >= 4.2.0",