Python 3.6 compatibility: Applied 2to3
This commit is contained in:
@@ -15,7 +15,7 @@ import attract.shots_and_assets
|
|||||||
EXTENSION_NAME = 'attract'
|
EXTENSION_NAME = 'attract'
|
||||||
|
|
||||||
# Roles required to view task or shot details.
|
# Roles required to view task or shot details.
|
||||||
ROLES_REQUIRED_TO_VIEW_ITEMS = {u'demo', u'subscriber', u'admin'}
|
ROLES_REQUIRED_TO_VIEW_ITEMS = {'demo', 'subscriber', 'admin'}
|
||||||
|
|
||||||
|
|
||||||
class AttractExtension(PillarExtension):
|
class AttractExtension(PillarExtension):
|
||||||
|
@@ -46,7 +46,7 @@ def create_svner_account(email, project_url):
|
|||||||
log.error('Unable to find project url=%s', project_url)
|
log.error('Unable to find project url=%s', project_url)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
account, token = create_service_account(email, [u'svner'], {'svner': {'project': proj['_id']}})
|
account, token = create_service_account(email, ['svner'], {'svner': {'project': proj['_id']}})
|
||||||
return account, token
|
return account, token
|
||||||
|
|
||||||
manager.add_command("attract", manager_attract)
|
manager.add_command("attract", manager_attract)
|
||||||
|
@@ -16,7 +16,7 @@ def find_for_shot(project, node):
|
|||||||
@register_node_finder(node_type_task['name'])
|
@register_node_finder(node_type_task['name'])
|
||||||
def find_for_task(project, node):
|
def find_for_task(project, node):
|
||||||
|
|
||||||
parent = node.get(u'parent') if isinstance(node, dict) else node.parent
|
parent = node.get('parent') if isinstance(node, dict) else node.parent
|
||||||
if parent:
|
if parent:
|
||||||
endpoint = 'attract.shots.perproject.with_task'
|
endpoint = 'attract.shots.perproject.with_task'
|
||||||
else:
|
else:
|
||||||
|
@@ -4,8 +4,6 @@ This is intended to be used by the CLI and unittests only, not tested
|
|||||||
for live/production situations.
|
for live/production situations.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import print_function, division
|
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@@ -21,25 +21,25 @@ from attract.node_types import node_type_shot, node_type_task, node_type_asset
|
|||||||
|
|
||||||
# From patch operation name to fields that operation may edit.
|
# From patch operation name to fields that operation may edit.
|
||||||
VALID_SHOT_PATCH_FIELDS = {
|
VALID_SHOT_PATCH_FIELDS = {
|
||||||
u'from-blender': {
|
'from-blender': {
|
||||||
u'name',
|
'name',
|
||||||
u'picture',
|
'picture',
|
||||||
u'properties.trim_start_in_frames',
|
'properties.trim_start_in_frames',
|
||||||
u'properties.trim_end_in_frames',
|
'properties.trim_end_in_frames',
|
||||||
u'properties.duration_in_edit_in_frames',
|
'properties.duration_in_edit_in_frames',
|
||||||
u'properties.cut_in_timeline_in_frames',
|
'properties.cut_in_timeline_in_frames',
|
||||||
u'properties.status',
|
'properties.status',
|
||||||
u'properties.used_in_edit',
|
'properties.used_in_edit',
|
||||||
},
|
},
|
||||||
u'from-web': {
|
'from-web': {
|
||||||
u'properties.status',
|
'properties.status',
|
||||||
u'properties.notes',
|
'properties.notes',
|
||||||
u'description',
|
'description',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
VALID_SHOT_PATCH_OPERATIONS = {
|
VALID_SHOT_PATCH_OPERATIONS = {
|
||||||
u'from-blender', u'from-web', u'unlink', u'relink',
|
'from-blender', 'from-web', 'unlink', 'relink',
|
||||||
}
|
}
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@@ -282,15 +282,15 @@ def patch_shot(node_id, patch):
|
|||||||
node_setattr(node, key, value)
|
node_setattr(node, key, value)
|
||||||
else:
|
else:
|
||||||
# Remaining operations are for marking as 'in use' or 'not in use'.
|
# Remaining operations are for marking as 'in use' or 'not in use'.
|
||||||
if node.get('_deleted', False) and op == u'unlink':
|
if node.get('_deleted', False) and op == 'unlink':
|
||||||
# We won't undelete a node in response to an unlink request.
|
# We won't undelete a node in response to an unlink request.
|
||||||
return pillar.api.utils.jsonify({'_deleted': True,
|
return pillar.api.utils.jsonify({'_deleted': True,
|
||||||
'_etag': node['_etag'],
|
'_etag': node['_etag'],
|
||||||
'_id': node['_id']})
|
'_id': node['_id']})
|
||||||
|
|
||||||
used_in_edit = {
|
used_in_edit = {
|
||||||
u'unlink': False,
|
'unlink': False,
|
||||||
u'relink': True,
|
'relink': True,
|
||||||
}[op]
|
}[op]
|
||||||
node['properties']['used_in_edit'] = used_in_edit
|
node['properties']['used_in_edit'] = used_in_edit
|
||||||
|
|
||||||
@@ -308,8 +308,8 @@ def assert_is_valid_patch(patch):
|
|||||||
raise wz_exceptions.BadRequest("PATCH should have a key 'op' indicating the operation.")
|
raise wz_exceptions.BadRequest("PATCH should have a key 'op' indicating the operation.")
|
||||||
|
|
||||||
if op not in VALID_SHOT_PATCH_OPERATIONS:
|
if op not in VALID_SHOT_PATCH_OPERATIONS:
|
||||||
valid_ops = u', '.join(sorted(VALID_SHOT_PATCH_OPERATIONS))
|
valid_ops = ', '.join(sorted(VALID_SHOT_PATCH_OPERATIONS))
|
||||||
raise wz_exceptions.BadRequest(u'Operation should be one of %s' % valid_ops)
|
raise wz_exceptions.BadRequest('Operation should be one of %s' % valid_ops)
|
||||||
|
|
||||||
if op not in VALID_SHOT_PATCH_FIELDS:
|
if op not in VALID_SHOT_PATCH_FIELDS:
|
||||||
# Valid operation, and we don't have to check the fields.
|
# Valid operation, and we don't have to check the fields.
|
||||||
@@ -324,7 +324,7 @@ def assert_is_valid_patch(patch):
|
|||||||
|
|
||||||
disallowed_fields = fields - allowed_fields
|
disallowed_fields = fields - allowed_fields
|
||||||
if disallowed_fields:
|
if disallowed_fields:
|
||||||
raise wz_exceptions.BadRequest(u"Operation '%s' does not allow you to set fields %s" % (
|
raise wz_exceptions.BadRequest("Operation '%s' does not allow you to set fields %s" % (
|
||||||
op, disallowed_fields
|
op, disallowed_fields
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@@ -72,8 +72,8 @@ def activity_after_replacing_shot_asset(shot_or_asset, original):
|
|||||||
descr = 'changed the thumbnail of %s "%s"' % (typename, shot_or_asset['name'])
|
descr = 'changed the thumbnail of %s "%s"' % (typename, shot_or_asset['name'])
|
||||||
elif key == 'properties.status':
|
elif key == 'properties.status':
|
||||||
val_shot = pillar.web.jinja.format_undertitle(val_shot)
|
val_shot = pillar.web.jinja.format_undertitle(val_shot)
|
||||||
elif isinstance(val_shot, basestring) and len(val_shot) > 80:
|
elif isinstance(val_shot, str) and len(val_shot) > 80:
|
||||||
val_shot = val_shot[:80] + u'…'
|
val_shot = val_shot[:80] + '…'
|
||||||
|
|
||||||
if descr is None:
|
if descr is None:
|
||||||
# A name change activity contains both the old and the new name.
|
# A name change activity contains both the old and the new name.
|
||||||
|
@@ -1,7 +1,5 @@
|
|||||||
"""Subversion interface."""
|
"""Subversion interface."""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
import dateutil.parser
|
import dateutil.parser
|
||||||
import re
|
import re
|
||||||
|
@@ -36,7 +36,7 @@ def subversion_kick(project, attract_props):
|
|||||||
|
|
||||||
|
|
||||||
@api_blueprint.route('/<project_url>/subversion/log', methods=['POST'])
|
@api_blueprint.route('/<project_url>/subversion/log', methods=['POST'])
|
||||||
@authorization.require_login(require_roles={u'service', u'svner'}, require_all=True)
|
@authorization.require_login(require_roles={'service', 'svner'}, require_all=True)
|
||||||
def subversion_log(project_url):
|
def subversion_log(project_url):
|
||||||
if request.mimetype != 'application/json':
|
if request.mimetype != 'application/json':
|
||||||
log.warning('Received %s instead of application/json', request.mimetype)
|
log.warning('Received %s instead of application/json', request.mimetype)
|
||||||
|
@@ -66,7 +66,7 @@ class TaskManager(object):
|
|||||||
task.description = fields.pop('description')
|
task.description = fields.pop('description')
|
||||||
task.properties.status = fields.pop('status')
|
task.properties.status = fields.pop('status')
|
||||||
task.properties.task_type = fields.pop('task_type', None)
|
task.properties.task_type = fields.pop('task_type', None)
|
||||||
if isinstance(task.properties.task_type, basestring):
|
if isinstance(task.properties.task_type, str):
|
||||||
task.properties.task_type = task.properties.task_type.strip() or None
|
task.properties.task_type = task.properties.task_type.strip() or None
|
||||||
|
|
||||||
due_date = fields.pop('due_date', None)
|
due_date = fields.pop('due_date', None)
|
||||||
@@ -150,13 +150,13 @@ class TaskManager(object):
|
|||||||
:type log_entry: attract.subversion.LogEntry
|
:type log_entry: attract.subversion.LogEntry
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self._log.info(u"Task '%s' logged in SVN by %s: %s...",
|
self._log.info("Task '%s' logged in SVN by %s: %s...",
|
||||||
shortcode, log_entry.author, log_entry.msg[:30].replace('\n', ' // '))
|
shortcode, log_entry.author, log_entry.msg[:30].replace('\n', ' // '))
|
||||||
|
|
||||||
# Find the task
|
# Find the task
|
||||||
task = self.api_task_for_shortcode(shortcode)
|
task = self.api_task_for_shortcode(shortcode)
|
||||||
if not task:
|
if not task:
|
||||||
self._log.warning(u'Task %s not found, ignoring SVN commit.', shortcode)
|
self._log.warning('Task %s not found, ignoring SVN commit.', shortcode)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Find the author
|
# Find the author
|
||||||
@@ -164,7 +164,7 @@ class TaskManager(object):
|
|||||||
proj = db['projects'].find_one({'_id': task['project']},
|
proj = db['projects'].find_one({'_id': task['project']},
|
||||||
projection={'extension_props.attract': 1})
|
projection={'extension_props.attract': 1})
|
||||||
if not proj:
|
if not proj:
|
||||||
self._log.warning(u'Project %s for task %s not found, ignoring SVN commit.',
|
self._log.warning('Project %s for task %s not found, ignoring SVN commit.',
|
||||||
task['project'], task['_id'])
|
task['project'], task['_id'])
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -175,7 +175,7 @@ class TaskManager(object):
|
|||||||
if user_id:
|
if user_id:
|
||||||
msg = 'committed SVN revision %s: %s' % (log_entry.revision, log_entry.msg)
|
msg = 'committed SVN revision %s: %s' % (log_entry.revision, log_entry.msg)
|
||||||
else:
|
else:
|
||||||
self._log.warning(u'No Pillar user mapped for SVN user %s, using SVNer account.',
|
self._log.warning('No Pillar user mapped for SVN user %s, using SVNer account.',
|
||||||
log_entry.author)
|
log_entry.author)
|
||||||
user_id = authentication.current_user_id()
|
user_id = authentication.current_user_id()
|
||||||
msg = 'committed SVN revision %s authored by SVN user %s: %s' % (
|
msg = 'committed SVN revision %s authored by SVN user %s: %s' % (
|
||||||
|
@@ -112,7 +112,7 @@ def register_task_activity(task, descr):
|
|||||||
|
|
||||||
def get_user_list(user_list):
|
def get_user_list(user_list):
|
||||||
if not user_list:
|
if not user_list:
|
||||||
return u'-nobody-'
|
return '-nobody-'
|
||||||
|
|
||||||
user_coll = current_app.db()['users']
|
user_coll = current_app.db()['users']
|
||||||
users = user_coll.find(
|
users = user_coll.find(
|
||||||
@@ -123,7 +123,7 @@ def get_user_list(user_list):
|
|||||||
)
|
)
|
||||||
|
|
||||||
names = [user['full_name'] for user in users]
|
names = [user['full_name'] for user in users]
|
||||||
return u', '.join(names)
|
return ', '.join(names)
|
||||||
|
|
||||||
|
|
||||||
@only_for_task
|
@only_for_task
|
||||||
@@ -150,8 +150,8 @@ def activity_after_replacing_task(task, original):
|
|||||||
human_key = 'assigned users'
|
human_key = 'assigned users'
|
||||||
val_task = get_user_list(val_task)
|
val_task = get_user_list(val_task)
|
||||||
descr = 'assigned task "%s" to %s' % (task['name'], val_task)
|
descr = 'assigned task "%s" to %s' % (task['name'], val_task)
|
||||||
elif isinstance(val_task, basestring) and len(val_task) > 80:
|
elif isinstance(val_task, str) and len(val_task) > 80:
|
||||||
val_task = val_task[:80] + u'…'
|
val_task = val_task[:80] + '…'
|
||||||
|
|
||||||
if descr is None:
|
if descr is None:
|
||||||
# A name change activity contains both the old and the new name.
|
# A name change activity contains both the old and the new name.
|
||||||
@@ -181,13 +181,13 @@ def activity_after_deleting_task(task):
|
|||||||
def set_defaults(task):
|
def set_defaults(task):
|
||||||
from attract import shortcodes
|
from attract import shortcodes
|
||||||
|
|
||||||
shortcode = shortcodes.generate_shortcode(task['project'], task['node_type'], u'T')
|
shortcode = shortcodes.generate_shortcode(task['project'], task['node_type'], 'T')
|
||||||
task_properties = task.setdefault('properties', {})
|
task_properties = task.setdefault('properties', {})
|
||||||
task_properties['shortcode'] = shortcode
|
task_properties['shortcode'] = shortcode
|
||||||
|
|
||||||
# When the task is assigned to a user, this prevents a change of 'assigned_to' to a dict.
|
# When the task is assigned to a user, this prevents a change of 'assigned_to' to a dict.
|
||||||
# Instead, the activity will be registered on 'assigned_to.users', which is nicer.
|
# Instead, the activity will be registered on 'assigned_to.users', which is nicer.
|
||||||
task_properties.setdefault('assigned_to', {u'users': []})
|
task_properties.setdefault('assigned_to', {'users': []})
|
||||||
|
|
||||||
|
|
||||||
def nodes_set_defaults(nodes):
|
def nodes_set_defaults(nodes):
|
||||||
|
@@ -1,8 +1,5 @@
|
|||||||
# -*- coding=utf-8 -*-
|
# -*- coding=utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
import datetime
|
import datetime
|
||||||
import logging.config
|
import logging.config
|
||||||
@@ -33,9 +30,9 @@ class ShortcodeTest(AbstractAttractTest):
|
|||||||
from attract import shortcodes
|
from attract import shortcodes
|
||||||
|
|
||||||
with self.app.test_request_context():
|
with self.app.test_request_context():
|
||||||
code = shortcodes.generate_shortcode(self.proj_id, u'jemoeder', u'ø')
|
code = shortcodes.generate_shortcode(self.proj_id, 'jemoeder', 'ø')
|
||||||
self.assertEqual(u'ø1', code)
|
self.assertEqual('ø1', code)
|
||||||
|
|
||||||
with self.app.test_request_context():
|
with self.app.test_request_context():
|
||||||
code = shortcodes.generate_shortcode(self.proj_id, u'jemoeder', u'č')
|
code = shortcodes.generate_shortcode(self.proj_id, 'jemoeder', 'č')
|
||||||
self.assertEqual(u'č2', code)
|
self.assertEqual('č2', code)
|
||||||
|
@@ -57,13 +57,13 @@ class ShotManagerTest(AbstractShotTest):
|
|||||||
shot1_id = shot1['_id']
|
shot1_id = shot1['_id']
|
||||||
shot2_id = shot2['_id']
|
shot2_id = shot2['_id']
|
||||||
|
|
||||||
task1 = self.create_task(shot1_id, u'fx')
|
task1 = self.create_task(shot1_id, 'fx')
|
||||||
task2 = self.create_task(shot1_id, u'fx')
|
task2 = self.create_task(shot1_id, 'fx')
|
||||||
task3 = self.create_task(shot1_id, u'høken')
|
task3 = self.create_task(shot1_id, 'høken')
|
||||||
|
|
||||||
task4 = self.create_task(shot2_id, u'effects')
|
task4 = self.create_task(shot2_id, 'effects')
|
||||||
task5 = self.create_task(shot2_id, u'effects')
|
task5 = self.create_task(shot2_id, 'effects')
|
||||||
task6 = self.create_task(shot2_id, u'ïnžane')
|
task6 = self.create_task(shot2_id, 'ïnžane')
|
||||||
|
|
||||||
with self.app.test_request_context():
|
with self.app.test_request_context():
|
||||||
# Log in as project admin user
|
# Log in as project admin user
|
||||||
@@ -71,7 +71,7 @@ class ShotManagerTest(AbstractShotTest):
|
|||||||
|
|
||||||
self.mock_blenderid_validate_happy()
|
self.mock_blenderid_validate_happy()
|
||||||
shot_id_to_task = self.smngr.tasks_for_nodes([shot1, shot2],
|
shot_id_to_task = self.smngr.tasks_for_nodes([shot1, shot2],
|
||||||
[u'fx', u'høken', u'effects'])
|
['fx', 'høken', 'effects'])
|
||||||
|
|
||||||
# Just test based on task IDs, as strings are turned into datetimes etc. by the API,
|
# Just test based on task IDs, as strings are turned into datetimes etc. by the API,
|
||||||
# so we can't test equality.
|
# so we can't test equality.
|
||||||
@@ -80,12 +80,12 @@ class ShotManagerTest(AbstractShotTest):
|
|||||||
all_tasks[task_type] = {task['_id'] for task in tasks}
|
all_tasks[task_type] = {task['_id'] for task in tasks}
|
||||||
|
|
||||||
self.assertEqual({
|
self.assertEqual({
|
||||||
u'fx': {task1['_id'], task2['_id']},
|
'fx': {task1['_id'], task2['_id']},
|
||||||
u'høken': {task3['_id']},
|
'høken': {task3['_id']},
|
||||||
}, shot_id_to_task[shot1_id])
|
}, shot_id_to_task[shot1_id])
|
||||||
|
|
||||||
self.assertEqual({
|
self.assertEqual({
|
||||||
u'effects': {task4['_id'], task5['_id']},
|
'effects': {task4['_id'], task5['_id']},
|
||||||
None: {task6['_id']},
|
None: {task6['_id']},
|
||||||
}, shot_id_to_task[shot2_id])
|
}, shot_id_to_task[shot2_id])
|
||||||
|
|
||||||
@@ -110,8 +110,8 @@ class ShotManagerTest(AbstractShotTest):
|
|||||||
# _etag='jemoeder')
|
# _etag='jemoeder')
|
||||||
|
|
||||||
self.smngr.edit_shot(shot_id=shot['_id'],
|
self.smngr.edit_shot(shot_id=shot['_id'],
|
||||||
name=u'ผัดไทย',
|
name='ผัดไทย',
|
||||||
description=u'Shoot the Pad Thai',
|
description='Shoot the Pad Thai',
|
||||||
status='todo',
|
status='todo',
|
||||||
notes=None,
|
notes=None,
|
||||||
_etag=shot._etag)
|
_etag=shot._etag)
|
||||||
@@ -121,9 +121,9 @@ class ShotManagerTest(AbstractShotTest):
|
|||||||
nodes_coll = self.app.data.driver.db['nodes']
|
nodes_coll = self.app.data.driver.db['nodes']
|
||||||
found = nodes_coll.find_one(ObjectId(shot['_id']))
|
found = nodes_coll.find_one(ObjectId(shot['_id']))
|
||||||
self.assertEqual(pre_edit_shot['name'], found['name']) # shouldn't be edited.
|
self.assertEqual(pre_edit_shot['name'], found['name']) # shouldn't be edited.
|
||||||
self.assertEqual(u'todo', found['properties']['status'])
|
self.assertEqual('todo', found['properties']['status'])
|
||||||
self.assertEqual(u'Shoot the Pad Thai', found['description'])
|
self.assertEqual('Shoot the Pad Thai', found['description'])
|
||||||
self.assertNotIn(u'notes', found['properties'])
|
self.assertNotIn('notes', found['properties'])
|
||||||
|
|
||||||
@responses.activate
|
@responses.activate
|
||||||
def test_shot_summary(self):
|
def test_shot_summary(self):
|
||||||
@@ -156,21 +156,21 @@ class PatchShotTest(AbstractShotTest):
|
|||||||
patch = {
|
patch = {
|
||||||
'op': 'from-blender',
|
'op': 'from-blender',
|
||||||
'$set': {
|
'$set': {
|
||||||
'name': u'"shot" is "geschoten" in Dutch',
|
'name': '"shot" is "geschoten" in Dutch',
|
||||||
'properties.trim_start_in_frames': 123,
|
'properties.trim_start_in_frames': 123,
|
||||||
'properties.trim_end_in_frames': 0,
|
'properties.trim_end_in_frames': 0,
|
||||||
'properties.duration_in_edit_in_frames': 4215,
|
'properties.duration_in_edit_in_frames': 4215,
|
||||||
'properties.cut_in_timeline_in_frames': 1245,
|
'properties.cut_in_timeline_in_frames': 1245,
|
||||||
'properties.status': u'on_hold',
|
'properties.status': 'on_hold',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.patch(url, json=patch, auth_token='token')
|
self.patch(url, json=patch, auth_token='token')
|
||||||
|
|
||||||
dbnode = self.get(url, auth_token='token').json()
|
dbnode = self.get(url, auth_token='token').json()
|
||||||
self.assertEqual(u'"shot" is "geschoten" in Dutch', dbnode['name'])
|
self.assertEqual('"shot" is "geschoten" in Dutch', dbnode['name'])
|
||||||
self.assertEqual(123, dbnode['properties']['trim_start_in_frames'])
|
self.assertEqual(123, dbnode['properties']['trim_start_in_frames'])
|
||||||
self.assertEqual(0, dbnode['properties']['trim_end_in_frames'])
|
self.assertEqual(0, dbnode['properties']['trim_end_in_frames'])
|
||||||
self.assertEqual(u'on_hold', dbnode['properties']['status'])
|
self.assertEqual('on_hold', dbnode['properties']['status'])
|
||||||
|
|
||||||
@responses.activate
|
@responses.activate
|
||||||
def test_patch_activity(self):
|
def test_patch_activity(self):
|
||||||
@@ -182,7 +182,7 @@ class PatchShotTest(AbstractShotTest):
|
|||||||
|
|
||||||
# Only change the name -- the activity should contain both the old and the new name.
|
# Only change the name -- the activity should contain both the old and the new name.
|
||||||
old_name = shot['name']
|
old_name = shot['name']
|
||||||
new_name = u'"shot" is "geschoten" in Dutch'
|
new_name = '"shot" is "geschoten" in Dutch'
|
||||||
patch = {
|
patch = {
|
||||||
'op': 'from-blender',
|
'op': 'from-blender',
|
||||||
'$set': {
|
'$set': {
|
||||||
@@ -209,20 +209,20 @@ class PatchShotTest(AbstractShotTest):
|
|||||||
patch = {
|
patch = {
|
||||||
'op': 'from-web',
|
'op': 'from-web',
|
||||||
'$set': {
|
'$set': {
|
||||||
'description': u'Таким образом, этот человек заходит в бар, и говорит…',
|
'description': 'Таким образом, этот человек заходит в бар, и говорит…',
|
||||||
'properties.notes': u'Два бокала вашей лучшей водки, пожалуйста.',
|
'properties.notes': 'Два бокала вашей лучшей водки, пожалуйста.',
|
||||||
'properties.status': u'final',
|
'properties.status': 'final',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.patch(url, json=patch, auth_token='token')
|
self.patch(url, json=patch, auth_token='token')
|
||||||
|
|
||||||
dbnode = self.get(url, auth_token='token').json()
|
dbnode = self.get(url, auth_token='token').json()
|
||||||
self.assertEqual(u'Таким образом, этот человек заходит в бар, и говорит…',
|
self.assertEqual('Таким образом, этот человек заходит в бар, и говорит…',
|
||||||
dbnode['description'])
|
dbnode['description'])
|
||||||
self.assertEqual(u'Два бокала вашей лучшей водки, пожалуйста.',
|
self.assertEqual('Два бокала вашей лучшей водки, пожалуйста.',
|
||||||
dbnode['properties']['notes'])
|
dbnode['properties']['notes'])
|
||||||
self.assertEqual(u'final', dbnode['properties']['status'])
|
self.assertEqual('final', dbnode['properties']['status'])
|
||||||
self.assertEqual(u'New shot', dbnode['name'])
|
self.assertEqual('New shot', dbnode['name'])
|
||||||
|
|
||||||
@responses.activate
|
@responses.activate
|
||||||
def test_patch_from_web_happy_nones(self):
|
def test_patch_from_web_happy_nones(self):
|
||||||
@@ -235,7 +235,7 @@ class PatchShotTest(AbstractShotTest):
|
|||||||
'$set': {
|
'$set': {
|
||||||
'description': None,
|
'description': None,
|
||||||
'properties.notes': None,
|
'properties.notes': None,
|
||||||
'properties.status': u'final',
|
'properties.status': 'final',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.patch(url, json=patch, auth_token='token')
|
self.patch(url, json=patch, auth_token='token')
|
||||||
@@ -243,8 +243,8 @@ class PatchShotTest(AbstractShotTest):
|
|||||||
dbnode = self.get(url, auth_token='token').json()
|
dbnode = self.get(url, auth_token='token').json()
|
||||||
self.assertNotIn('description', dbnode)
|
self.assertNotIn('description', dbnode)
|
||||||
self.assertNotIn('notes', dbnode['properties'])
|
self.assertNotIn('notes', dbnode['properties'])
|
||||||
self.assertEqual(u'final', dbnode['properties']['status'])
|
self.assertEqual('final', dbnode['properties']['status'])
|
||||||
self.assertEqual(u'New shot', dbnode['name'])
|
self.assertEqual('New shot', dbnode['name'])
|
||||||
|
|
||||||
@responses.activate
|
@responses.activate
|
||||||
def test_patch_bad_op(self):
|
def test_patch_bad_op(self):
|
||||||
@@ -409,15 +409,15 @@ class RequiredAfterCreationTest(AbstractShotTest):
|
|||||||
|
|
||||||
node_type_name = node_type_shot['name']
|
node_type_name = node_type_shot['name']
|
||||||
|
|
||||||
shot = {'name': u'test shot',
|
shot = {'name': 'test shot',
|
||||||
'description': u'',
|
'description': '',
|
||||||
'properties': {u'trim_start_in_frames': 0,
|
'properties': {'trim_start_in_frames': 0,
|
||||||
u'trim_end_in_frames': 0,
|
'trim_end_in_frames': 0,
|
||||||
u'duration_in_edit_in_frames': 1,
|
'duration_in_edit_in_frames': 1,
|
||||||
u'cut_in_timeline_in_frames': 0},
|
'cut_in_timeline_in_frames': 0},
|
||||||
'node_type': node_type_name,
|
'node_type': node_type_name,
|
||||||
'project': unicode(self.proj_id),
|
'project': str(self.proj_id),
|
||||||
'user': unicode(self.user_id)}
|
'user': str(self.user_id)}
|
||||||
|
|
||||||
resp = self.post('/api/nodes', json=shot,
|
resp = self.post('/api/nodes', json=shot,
|
||||||
auth_token='token', expected_status=201)
|
auth_token='token', expected_status=201)
|
||||||
@@ -441,27 +441,27 @@ class ProjectSummaryTest(unittest.TestCase):
|
|||||||
from attract.shots_and_assets import ProjectSummary
|
from attract.shots_and_assets import ProjectSummary
|
||||||
|
|
||||||
self.summ = ProjectSummary()
|
self.summ = ProjectSummary()
|
||||||
self.summ.count(u'todo')
|
self.summ.count('todo')
|
||||||
self.summ.count(u'todo')
|
self.summ.count('todo')
|
||||||
self.summ.count(u'in-progress')
|
self.summ.count('in-progress')
|
||||||
self.summ.count(u'überhard')
|
self.summ.count('überhard')
|
||||||
self.summ.count(u'Æon Flux')
|
self.summ.count('Æon Flux')
|
||||||
self.summ.count(u'Æon Flux')
|
self.summ.count('Æon Flux')
|
||||||
self.summ.count(u'in-progress')
|
self.summ.count('in-progress')
|
||||||
self.summ.count(u'todo')
|
self.summ.count('todo')
|
||||||
|
|
||||||
def test_counting(self):
|
def test_counting(self):
|
||||||
self.assertEqual(8, self.summ._total)
|
self.assertEqual(8, self.summ._total)
|
||||||
self.assertEqual(3, self.summ._counts[u'todo'])
|
self.assertEqual(3, self.summ._counts['todo'])
|
||||||
self.assertEqual(2, self.summ._counts[u'Æon Flux'])
|
self.assertEqual(2, self.summ._counts['Æon Flux'])
|
||||||
|
|
||||||
def test_percentages(self):
|
def test_percentages(self):
|
||||||
percs = list(self.summ.percentages())
|
percs = list(self.summ.percentages())
|
||||||
|
|
||||||
self.assertEqual((u'in-progress', 25), percs[0])
|
self.assertEqual(('in-progress', 25), percs[0])
|
||||||
self.assertEqual((u'todo', 38), percs[1])
|
self.assertEqual(('todo', 38), percs[1])
|
||||||
self.assertEqual((u'Æon Flux', 25), percs[2])
|
self.assertEqual(('Æon Flux', 25), percs[2])
|
||||||
|
|
||||||
# This should be rounded down, not rounded up, to ensure the sum of
|
# This should be rounded down, not rounded up, to ensure the sum of
|
||||||
# percentages is 100.
|
# percentages is 100.
|
||||||
self.assertEqual((u'überhard', 12), percs[3])
|
self.assertEqual(('überhard', 12), percs[3])
|
||||||
|
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
"""Unit test for SVN interface."""
|
"""Unit test for SVN interface."""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
import datetime
|
import datetime
|
||||||
import logging.config
|
import logging.config
|
||||||
@@ -158,48 +156,48 @@ class TestCommitLogObserver(unittest.TestCase):
|
|||||||
def test_create_log_entry(self):
|
def test_create_log_entry(self):
|
||||||
from attract import subversion
|
from attract import subversion
|
||||||
|
|
||||||
entry = subversion.create_log_entry(date_text=u'2016-10-21 17:40:17 +0200',
|
entry = subversion.create_log_entry(date_text='2016-10-21 17:40:17 +0200',
|
||||||
msg=u'Ünicøde is good',
|
msg='Ünicøde is good',
|
||||||
revision='123',
|
revision='123',
|
||||||
author=u'børk',
|
author='børk',
|
||||||
changelist='nothing')
|
changelist='nothing')
|
||||||
self.assertEqual(tuple(entry), (
|
self.assertEqual(tuple(entry), (
|
||||||
datetime.datetime(2016, 10, 21, 15, 40, 17, 0, tzinfo=tzutc()),
|
datetime.datetime(2016, 10, 21, 15, 40, 17, 0, tzinfo=tzutc()),
|
||||||
u'Ünicøde is good',
|
'Ünicøde is good',
|
||||||
'123',
|
'123',
|
||||||
u'børk',
|
'børk',
|
||||||
'nothing'
|
'nothing'
|
||||||
))
|
))
|
||||||
|
|
||||||
self.assertRaises(ValueError, subversion.create_log_entry,
|
self.assertRaises(ValueError, subversion.create_log_entry,
|
||||||
date_text='Unparseable date',
|
date_text='Unparseable date',
|
||||||
msg=u'Ünicøde is good',
|
msg='Ünicøde is good',
|
||||||
revision='123',
|
revision='123',
|
||||||
author=u'børk',
|
author='børk',
|
||||||
changelist='nothing')
|
changelist='nothing')
|
||||||
|
|
||||||
entry = subversion.create_log_entry(date_text=u'2016-10-21 17:40:17 +0200',
|
entry = subversion.create_log_entry(date_text='2016-10-21 17:40:17 +0200',
|
||||||
msg=u'Ünicøde is good',
|
msg='Ünicøde is good',
|
||||||
revision='123',
|
revision='123',
|
||||||
author=u'børk')
|
author='børk')
|
||||||
self.assertEqual(tuple(entry), (
|
self.assertEqual(tuple(entry), (
|
||||||
datetime.datetime(2016, 10, 21, 15, 40, 17, 0, tzinfo=tzutc()),
|
datetime.datetime(2016, 10, 21, 15, 40, 17, 0, tzinfo=tzutc()),
|
||||||
u'Ünicøde is good',
|
'Ünicøde is good',
|
||||||
'123',
|
'123',
|
||||||
u'børk',
|
'børk',
|
||||||
None
|
None
|
||||||
))
|
))
|
||||||
|
|
||||||
entry = subversion.create_log_entry(
|
entry = subversion.create_log_entry(
|
||||||
date=datetime.datetime(2016, 10, 21, 15, 40, 17, 0, tzinfo=tzutc()),
|
date=datetime.datetime(2016, 10, 21, 15, 40, 17, 0, tzinfo=tzutc()),
|
||||||
msg=u'Ünicøde is good',
|
msg='Ünicøde is good',
|
||||||
revision='123',
|
revision='123',
|
||||||
author=u'børk')
|
author='børk')
|
||||||
self.assertEqual(tuple(entry), (
|
self.assertEqual(tuple(entry), (
|
||||||
datetime.datetime(2016, 10, 21, 15, 40, 17, 0, tzinfo=tzutc()),
|
datetime.datetime(2016, 10, 21, 15, 40, 17, 0, tzinfo=tzutc()),
|
||||||
u'Ünicøde is good',
|
'Ünicøde is good',
|
||||||
'123',
|
'123',
|
||||||
u'børk',
|
'børk',
|
||||||
None
|
None
|
||||||
))
|
))
|
||||||
|
|
||||||
@@ -225,9 +223,9 @@ class PushCommitTest(AbstractAttractTest):
|
|||||||
subversion.task_logged.connect(record_blink)
|
subversion.task_logged.connect(record_blink)
|
||||||
|
|
||||||
push_data = {
|
push_data = {
|
||||||
'repo': u'strange-repo™',
|
'repo': 'strange-repo™',
|
||||||
'revision': '4',
|
'revision': '4',
|
||||||
'msg': u'မြန်မာဘာသာ is beautiful.\n\nThis solves task [T431134]',
|
'msg': 'မြန်မာဘာသာ is beautiful.\n\nThis solves task [T431134]',
|
||||||
'author': 'Haha',
|
'author': 'Haha',
|
||||||
'date': '2016-10-21 17:40:17 +0200',
|
'date': '2016-10-21 17:40:17 +0200',
|
||||||
}
|
}
|
||||||
@@ -237,8 +235,8 @@ class PushCommitTest(AbstractAttractTest):
|
|||||||
auth_token=token['token'])
|
auth_token=token['token'])
|
||||||
|
|
||||||
self.assertEqual(1, len(blinks))
|
self.assertEqual(1, len(blinks))
|
||||||
self.assertEqual(u'T431134', blinks[0]['shortcode'])
|
self.assertEqual('T431134', blinks[0]['shortcode'])
|
||||||
self.assertEqual(u'မြန်မာဘာသာ is beautiful.\n\nThis solves task [T431134]',
|
self.assertEqual('မြန်မာဘာသာ is beautiful.\n\nThis solves task [T431134]',
|
||||||
blinks[0]['log_entry'].msg)
|
blinks[0]['log_entry'].msg)
|
||||||
self.assertEqual(datetime.datetime(2016, 10, 21, 15, 40, 17, 0, tzinfo=tzutc()),
|
self.assertEqual(datetime.datetime(2016, 10, 21, 15, 40, 17, 0, tzinfo=tzutc()),
|
||||||
blinks[0]['log_entry'].date)
|
blinks[0]['log_entry'].date)
|
||||||
@@ -283,7 +281,7 @@ class SvnTaskLoggedTest(AbstractAttractTest):
|
|||||||
_, token = cli.create_svner_account('svner@example.com', self.project['url'])
|
_, token = cli.create_svner_account('svner@example.com', self.project['url'])
|
||||||
|
|
||||||
# Do the push
|
# Do the push
|
||||||
msg = u'¡is a tie! commit to task [%s]' % shortcode
|
msg = '¡is a tie! commit to task [%s]' % shortcode
|
||||||
self.post('/attract/api/%s/subversion/log' % self.project['url'],
|
self.post('/attract/api/%s/subversion/log' % self.project['url'],
|
||||||
json={
|
json={
|
||||||
'revision': 6,
|
'revision': 6,
|
||||||
|
@@ -34,7 +34,7 @@ class TaskWorkflowTest(AbstractAttractTest):
|
|||||||
|
|
||||||
@responses.activate
|
@responses.activate
|
||||||
def test_create_task(self):
|
def test_create_task(self):
|
||||||
task = self.create_task(task_type=u'Just düüüh it')
|
task = self.create_task(task_type='Just düüüh it')
|
||||||
self.assertIsNotNone(task)
|
self.assertIsNotNone(task)
|
||||||
|
|
||||||
# Test directly with MongoDB
|
# Test directly with MongoDB
|
||||||
@@ -42,12 +42,12 @@ class TaskWorkflowTest(AbstractAttractTest):
|
|||||||
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)
|
||||||
self.assertEqual(u'Just düüüh it', found['properties']['task_type'])
|
self.assertEqual('Just düüüh it', found['properties']['task_type'])
|
||||||
|
|
||||||
# Test it through the API
|
# Test it through the API
|
||||||
resp = self.get('/api/nodes/%s' % task['_id'])
|
resp = self.get('/api/nodes/%s' % task['_id'])
|
||||||
found = resp.json()
|
found = resp.json()
|
||||||
self.assertEqual(u'Just düüüh it', found['properties']['task_type'])
|
self.assertEqual('Just düüüh it', found['properties']['task_type'])
|
||||||
|
|
||||||
@responses.activate
|
@responses.activate
|
||||||
def test_edit_task(self):
|
def test_edit_task(self):
|
||||||
@@ -61,15 +61,15 @@ class TaskWorkflowTest(AbstractAttractTest):
|
|||||||
self.assertRaises(sdk_exceptions.PreconditionFailed,
|
self.assertRaises(sdk_exceptions.PreconditionFailed,
|
||||||
self.mngr.edit_task,
|
self.mngr.edit_task,
|
||||||
task._id,
|
task._id,
|
||||||
task_type=u'je møder',
|
task_type='je møder',
|
||||||
name=u'nööw name',
|
name='nööw name',
|
||||||
description=u'€ ≠ ¥',
|
description='€ ≠ ¥',
|
||||||
status='todo',
|
status='todo',
|
||||||
_etag='jemoeder')
|
_etag='jemoeder')
|
||||||
self.mngr.edit_task(task._id,
|
self.mngr.edit_task(task._id,
|
||||||
task_type=u'je møder',
|
task_type='je møder',
|
||||||
name=u'nööw name',
|
name='nööw name',
|
||||||
description=u'€ ≠ ¥',
|
description='€ ≠ ¥',
|
||||||
status='todo',
|
status='todo',
|
||||||
_etag=task._etag)
|
_etag=task._etag)
|
||||||
|
|
||||||
@@ -77,10 +77,10 @@ class TaskWorkflowTest(AbstractAttractTest):
|
|||||||
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.assertEqual(u'je møder', found['properties']['task_type'])
|
self.assertEqual('je møder', found['properties']['task_type'])
|
||||||
self.assertEqual(u'todo', found['properties']['status'])
|
self.assertEqual('todo', found['properties']['status'])
|
||||||
self.assertEqual(u'nööw name', found['name'])
|
self.assertEqual('nööw name', found['name'])
|
||||||
self.assertEqual(u'€ ≠ ¥', found['description'])
|
self.assertEqual('€ ≠ ¥', found['description'])
|
||||||
|
|
||||||
@responses.activate
|
@responses.activate
|
||||||
def test_edit_activity(self):
|
def test_edit_activity(self):
|
||||||
@@ -89,7 +89,7 @@ class TaskWorkflowTest(AbstractAttractTest):
|
|||||||
|
|
||||||
# Only change the name -- the activity should contain both the old and the new name.
|
# Only change the name -- the activity should contain both the old and the new name.
|
||||||
old_name = task['name']
|
old_name = task['name']
|
||||||
new_name = u'nööw name'
|
new_name = 'nööw name'
|
||||||
|
|
||||||
with self.app.test_request_context():
|
with self.app.test_request_context():
|
||||||
# Log in as project admin user
|
# Log in as project admin user
|
||||||
@@ -100,7 +100,7 @@ class TaskWorkflowTest(AbstractAttractTest):
|
|||||||
task_type=task['properties'].task_type,
|
task_type=task['properties'].task_type,
|
||||||
name=new_name,
|
name=new_name,
|
||||||
description=task.description,
|
description=task.description,
|
||||||
status=u'todo',
|
status='todo',
|
||||||
_etag=task._etag)
|
_etag=task._etag)
|
||||||
|
|
||||||
with self.app.test_request_context():
|
with self.app.test_request_context():
|
||||||
@@ -115,8 +115,8 @@ class TaskWorkflowTest(AbstractAttractTest):
|
|||||||
def test_load_save_task(self):
|
def test_load_save_task(self):
|
||||||
"""Test for the Eve hooks -- we should be able to PUT what we GET."""
|
"""Test for the Eve hooks -- we should be able to PUT what we GET."""
|
||||||
|
|
||||||
task_parent = self.create_task(task_type=u'Just düüüh it')
|
task_parent = self.create_task(task_type='Just düüüh it')
|
||||||
task_child = self.create_task(task_type=u'mamaaaah',
|
task_child = self.create_task(task_type='mamaaaah',
|
||||||
parent=task_parent['_id'])
|
parent=task_parent['_id'])
|
||||||
|
|
||||||
self.create_valid_auth_token(ctd.EXAMPLE_PROJECT_OWNER_ID, 'token')
|
self.create_valid_auth_token(ctd.EXAMPLE_PROJECT_OWNER_ID, 'token')
|
||||||
|
Reference in New Issue
Block a user