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",