Added unittest for edit_task
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
# -*- encoding: utf-8 -*-
|
||||||
|
|
||||||
import responses
|
import responses
|
||||||
from bson import ObjectId
|
from bson import ObjectId
|
||||||
|
|
||||||
@@ -18,18 +20,49 @@ class TaskWorkflowTest(AbstractAttractTest):
|
|||||||
|
|
||||||
self.sdk_project = pillarsdk.Project(pillar.tests.mongo_to_sdk(self.project))
|
self.sdk_project = pillarsdk.Project(pillar.tests.mongo_to_sdk(self.project))
|
||||||
|
|
||||||
@responses.activate
|
def create_task(self):
|
||||||
def test_create_task(self):
|
|
||||||
with self.app.test_request_context():
|
with self.app.test_request_context():
|
||||||
# Log in as project admin user
|
# Log in as project admin user
|
||||||
pillar.auth.login_user(ctd.EXAMPLE_PROJECT_OWNER_ID)
|
pillar.auth.login_user(ctd.EXAMPLE_PROJECT_OWNER_ID)
|
||||||
|
|
||||||
self.mock_blenderid_validate_happy()
|
self.mock_blenderid_validate_happy()
|
||||||
task = self.mngr.create_task(self.sdk_project)
|
task = self.mngr.create_task(self.sdk_project)
|
||||||
self.assertIsNotNone(task)
|
|
||||||
|
self.assertIsInstance(task, pillarsdk.Node)
|
||||||
|
return task
|
||||||
|
|
||||||
|
@responses.activate
|
||||||
|
def test_create_task(self):
|
||||||
|
task = self.create_task()
|
||||||
|
self.assertIsNotNone(task)
|
||||||
|
|
||||||
# Test directly with MongoDB
|
# Test directly with MongoDB
|
||||||
with self.app.test_request_context():
|
with self.app.test_request_context():
|
||||||
nodes_coll = self.app.data.driver.db['nodes']
|
nodes_coll = self.app.data.driver.db['nodes']
|
||||||
found = nodes_coll.find_one(ObjectId(task['_id']))
|
found = nodes_coll.find_one(ObjectId(task['_id']))
|
||||||
self.assertIsNotNone(found)
|
self.assertIsNotNone(found)
|
||||||
|
|
||||||
|
@responses.activate
|
||||||
|
def test_edit_task(self):
|
||||||
|
task = self.create_task()
|
||||||
|
|
||||||
|
with self.app.test_request_context():
|
||||||
|
# Log in as project admin user
|
||||||
|
pillar.auth.login_user(ctd.EXAMPLE_PROJECT_OWNER_ID)
|
||||||
|
|
||||||
|
self.mock_blenderid_validate_happy()
|
||||||
|
self.mngr.edit_task(task._id,
|
||||||
|
task_type=u'je møder',
|
||||||
|
name=u'nööw name',
|
||||||
|
description=u'€ ≠ ¥',
|
||||||
|
status='todo')
|
||||||
|
self.assertIsNotNone(task)
|
||||||
|
|
||||||
|
# Test directly with MongoDB
|
||||||
|
with self.app.test_request_context():
|
||||||
|
nodes_coll = self.app.data.driver.db['nodes']
|
||||||
|
found = nodes_coll.find_one(ObjectId(task['_id']))
|
||||||
|
self.assertEqual(u'je møder', found['properties']['task_type'])
|
||||||
|
self.assertEqual(u'todo', found['properties']['status'])
|
||||||
|
self.assertEqual(u'nööw name', found['name'])
|
||||||
|
self.assertEqual(u'€ ≠ ¥', found['description'])
|
||||||
|
Reference in New Issue
Block a user