|
1 |
| -from django.contrib.auth.models import User |
2 |
| -from django.test import TestCase |
| 1 | +def test_stripped_description(todolist): |
| 2 | + todolist.description = 'Boost rebuild ' |
| 3 | + desc = todolist.stripped_description |
| 4 | + assert desc.endswith(' ') == False |
3 | 5 |
|
4 | 6 |
|
5 |
| -from main.models import Package |
6 |
| -from todolists.models import Todolist, TodolistPackage |
| 7 | +def test_get_absolute_url(todolist): |
| 8 | + assert '/todo/' in todolist.get_absolute_url() |
7 | 9 |
|
8 | 10 |
|
9 |
| -class TestTodolist(TestCase): |
10 |
| - fixtures = ['main/fixtures/arches.json', 'main/fixtures/repos.json', |
11 |
| - 'main/fixtures/package.json'] |
| 11 | +def test_get_full_url(todolist): |
| 12 | + url = todolist.get_full_url() |
| 13 | + assert 'https://example.com/todo/' in url |
12 | 14 |
|
13 |
| - def setUp(self): |
14 |
| - self.user = User.objects.create(username="joeuser", first_name="Joe", |
15 |
| - last_name="User", email="[email protected]") |
16 |
| - self.todolist = Todolist.objects.create(name='Boost rebuild', |
17 |
| - description='Boost 1.66 rebuid', |
18 |
| - creator=self.user, |
19 |
| - raw='linux') |
20 | 15 |
|
21 |
| - def tearDown(self): |
22 |
| - self.todolist.delete() |
23 |
| - self.user.delete() |
24 |
| - |
25 |
| - def test_stripped_description(self): |
26 |
| - self.todolist.description = 'Boost rebuild ' |
27 |
| - desc = self.todolist.stripped_description |
28 |
| - self.assertFalse(desc.endswith(' ')) |
29 |
| - |
30 |
| - def test_get_absolute_url(self): |
31 |
| - self.assertIn('/todo/', self.todolist.get_absolute_url()) |
32 |
| - |
33 |
| - def test_get_full_url(self): |
34 |
| - url = self.todolist.get_full_url() |
35 |
| - self.assertIn('https://example.com/todo/', url) |
36 |
| - |
37 |
| - def test_packages(self): |
38 |
| - pkg = Package.objects.first() |
39 |
| - todopkg = TodolistPackage.objects.create(pkg=pkg, pkgname=pkg.pkgname, |
40 |
| - pkgbase=pkg.pkgbase, arch=pkg.arch, |
41 |
| - repo=pkg.repo, user=self.user, |
42 |
| - todolist=self.todolist) |
43 |
| - pkgs = self.todolist.packages() |
44 |
| - self.assertEqual(len(pkgs), 1) |
45 |
| - self.assertEqual(pkgs[0], todopkg) |
| 16 | +def test_packages(admin_user, todolist, todolistpackage): |
| 17 | + pkgs = todolist.packages() |
| 18 | + assert len(pkgs) == 1 |
| 19 | + assert pkgs[0] == todolistpackage |
0 commit comments