summaryrefslogtreecommitdiffstats
path: root/todolists
diff options
context:
space:
mode:
authorjelle van der Waa <jelle@vdwaa.nl>2018-01-29 20:10:10 +0100
committerAngel Velásquez <angvp@archlinux.org>2018-01-29 14:10:10 -0500
commit148692cd8fc79b3e43ef0f2c40a2da9d87c9da9e (patch)
treed34782a388091c4f14b24b9d0878f4a8265beef2 /todolists
parent2ff2b26aa92c8efd21090562091361924a3a9428 (diff)
downloadarchweb-148692cd8fc79b3e43ef0f2c40a2da9d87c9da9e.tar.gz
archweb-148692cd8fc79b3e43ef0f2c40a2da9d87c9da9e.zip
More code refactoring / tests (#79)
* main: move tests to main/tests Move the templatetags tests to main/tests/test_templatetags. * main: Add test for templatetags country Create a test for the templatetag country_flag. * main: remove duplicate floatvalue floatvalue is only used in the mirrors templates and the same exact function exists in the mirror_status templatetags. * main: Remove duplicate hours filter The hours filter is also defined in the mirror_status and only used in mirrors. * main: move percentage filter to mirrors Move the percentage filter to the only user of it and add a test for basic use cases. * main: remove duplicate duration implementation The duration templatetag filter is also defined in mirror_status.py * templates: remove unrequired import flags * main: Add missing testcase for country_flag Add the None test case, so that the function is fully covered. * todolists: create tests for Todolist model Add basic tests for the Todolist model
Diffstat (limited to 'todolists')
-rw-r--r--todolists/tests/test_models.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/todolists/tests/test_models.py b/todolists/tests/test_models.py
new file mode 100644
index 00000000..4e629f37
--- /dev/null
+++ b/todolists/tests/test_models.py
@@ -0,0 +1,45 @@
+from django.contrib.auth.models import User
+from django.test import TestCase
+
+
+from main.models import Package
+from todolists.models import Todolist, TodolistPackage
+
+
+class TestTodolist(TestCase):
+ fixtures = ['main/fixtures/arches.json', 'main/fixtures/repos.json',
+ 'main/fixtures/package.json']
+
+ def setUp(self):
+ self.user = User.objects.create(username="joeuser", first_name="Joe",
+ last_name="User", email="user1@example.com")
+ self.todolist = Todolist.objects.create(name='Boost rebuild',
+ description='Boost 1.66 rebuid',
+ creator=self.user,
+ raw='linux')
+
+ def tearDown(self):
+ self.todolist.delete()
+ self.user.delete()
+
+ def test_stripped_description(self):
+ self.todolist.description = 'Boost rebuild '
+ desc = self.todolist.stripped_description
+ self.assertFalse(desc.endswith(' '))
+
+ def test_get_absolute_url(self):
+ self.assertIn('/todo/', self.todolist.get_absolute_url())
+
+ def test_get_full_url(self):
+ url = self.todolist.get_full_url()
+ self.assertIn('https://example.com/todo/', url)
+
+ def test_packages(self):
+ pkg = Package.objects.first()
+ todopkg = TodolistPackage.objects.create(pkg=pkg, pkgname=pkg.pkgname,
+ pkgbase=pkg.pkgbase, arch=pkg.arch,
+ repo=pkg.repo, user=self.user,
+ todolist=self.todolist)
+ pkgs = self.todolist.packages()
+ self.assertEqual(len(pkgs), 1)
+ self.assertEqual(pkgs[0], todopkg)