-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_unit.py
More file actions
34 lines (26 loc) · 1.1 KB
/
test_unit.py
File metadata and controls
34 lines (26 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from django.test import TestCase
from django.contrib.auth.models import User
from django.utils import timezone
from mango.models import Task
from mango.views import get_running_task
class EngineUnit(TestCase):
@classmethod
def setUpTestData(cls):
user = User.objects.create_user(username="cat", password="meow")
user.save()
task = Task.objects.create(user=user,
task_name="do",
task_priority=1,
date_start=timezone.now(),
is_running=True)
another_task = Task.objects.create(user=user,
task_name="something",
task_priority=2)
task.save()
another_task.save()
def test_get_running(self):
self.client.login(username="cat", password="meow")
request = self.client.get("/day/")
request.user = User.objects.get(username="cat")
task = get_running_task(request)
self.assertEquals(task.task_name, "do")