Python 3.6 compatibility: Applied 2to3
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
# -*- coding=utf-8 -*-
|
||||
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import collections
|
||||
import datetime
|
||||
import logging.config
|
||||
@@ -33,9 +30,9 @@ class ShortcodeTest(AbstractAttractTest):
|
||||
from attract import shortcodes
|
||||
|
||||
with self.app.test_request_context():
|
||||
code = shortcodes.generate_shortcode(self.proj_id, u'jemoeder', u'ø')
|
||||
self.assertEqual(u'ø1', code)
|
||||
code = shortcodes.generate_shortcode(self.proj_id, 'jemoeder', 'ø')
|
||||
self.assertEqual('ø1', code)
|
||||
|
||||
with self.app.test_request_context():
|
||||
code = shortcodes.generate_shortcode(self.proj_id, u'jemoeder', u'č')
|
||||
self.assertEqual(u'č2', code)
|
||||
code = shortcodes.generate_shortcode(self.proj_id, 'jemoeder', 'č')
|
||||
self.assertEqual('č2', code)
|
||||
|
@@ -57,13 +57,13 @@ class ShotManagerTest(AbstractShotTest):
|
||||
shot1_id = shot1['_id']
|
||||
shot2_id = shot2['_id']
|
||||
|
||||
task1 = self.create_task(shot1_id, u'fx')
|
||||
task2 = self.create_task(shot1_id, u'fx')
|
||||
task3 = self.create_task(shot1_id, u'høken')
|
||||
task1 = self.create_task(shot1_id, 'fx')
|
||||
task2 = self.create_task(shot1_id, 'fx')
|
||||
task3 = self.create_task(shot1_id, 'høken')
|
||||
|
||||
task4 = self.create_task(shot2_id, u'effects')
|
||||
task5 = self.create_task(shot2_id, u'effects')
|
||||
task6 = self.create_task(shot2_id, u'ïnžane')
|
||||
task4 = self.create_task(shot2_id, 'effects')
|
||||
task5 = self.create_task(shot2_id, 'effects')
|
||||
task6 = self.create_task(shot2_id, 'ïnžane')
|
||||
|
||||
with self.app.test_request_context():
|
||||
# Log in as project admin user
|
||||
@@ -71,7 +71,7 @@ class ShotManagerTest(AbstractShotTest):
|
||||
|
||||
self.mock_blenderid_validate_happy()
|
||||
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,
|
||||
# so we can't test equality.
|
||||
@@ -80,12 +80,12 @@ class ShotManagerTest(AbstractShotTest):
|
||||
all_tasks[task_type] = {task['_id'] for task in tasks}
|
||||
|
||||
self.assertEqual({
|
||||
u'fx': {task1['_id'], task2['_id']},
|
||||
u'høken': {task3['_id']},
|
||||
'fx': {task1['_id'], task2['_id']},
|
||||
'høken': {task3['_id']},
|
||||
}, shot_id_to_task[shot1_id])
|
||||
|
||||
self.assertEqual({
|
||||
u'effects': {task4['_id'], task5['_id']},
|
||||
'effects': {task4['_id'], task5['_id']},
|
||||
None: {task6['_id']},
|
||||
}, shot_id_to_task[shot2_id])
|
||||
|
||||
@@ -110,8 +110,8 @@ class ShotManagerTest(AbstractShotTest):
|
||||
# _etag='jemoeder')
|
||||
|
||||
self.smngr.edit_shot(shot_id=shot['_id'],
|
||||
name=u'ผัดไทย',
|
||||
description=u'Shoot the Pad Thai',
|
||||
name='ผัดไทย',
|
||||
description='Shoot the Pad Thai',
|
||||
status='todo',
|
||||
notes=None,
|
||||
_etag=shot._etag)
|
||||
@@ -121,9 +121,9 @@ class ShotManagerTest(AbstractShotTest):
|
||||
nodes_coll = self.app.data.driver.db['nodes']
|
||||
found = nodes_coll.find_one(ObjectId(shot['_id']))
|
||||
self.assertEqual(pre_edit_shot['name'], found['name']) # shouldn't be edited.
|
||||
self.assertEqual(u'todo', found['properties']['status'])
|
||||
self.assertEqual(u'Shoot the Pad Thai', found['description'])
|
||||
self.assertNotIn(u'notes', found['properties'])
|
||||
self.assertEqual('todo', found['properties']['status'])
|
||||
self.assertEqual('Shoot the Pad Thai', found['description'])
|
||||
self.assertNotIn('notes', found['properties'])
|
||||
|
||||
@responses.activate
|
||||
def test_shot_summary(self):
|
||||
@@ -156,21 +156,21 @@ class PatchShotTest(AbstractShotTest):
|
||||
patch = {
|
||||
'op': 'from-blender',
|
||||
'$set': {
|
||||
'name': u'"shot" is "geschoten" in Dutch',
|
||||
'name': '"shot" is "geschoten" in Dutch',
|
||||
'properties.trim_start_in_frames': 123,
|
||||
'properties.trim_end_in_frames': 0,
|
||||
'properties.duration_in_edit_in_frames': 4215,
|
||||
'properties.cut_in_timeline_in_frames': 1245,
|
||||
'properties.status': u'on_hold',
|
||||
'properties.status': 'on_hold',
|
||||
}
|
||||
}
|
||||
self.patch(url, json=patch, auth_token='token')
|
||||
|
||||
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(0, dbnode['properties']['trim_end_in_frames'])
|
||||
self.assertEqual(u'on_hold', dbnode['properties']['status'])
|
||||
self.assertEqual('on_hold', dbnode['properties']['status'])
|
||||
|
||||
@responses.activate
|
||||
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.
|
||||
old_name = shot['name']
|
||||
new_name = u'"shot" is "geschoten" in Dutch'
|
||||
new_name = '"shot" is "geschoten" in Dutch'
|
||||
patch = {
|
||||
'op': 'from-blender',
|
||||
'$set': {
|
||||
@@ -209,20 +209,20 @@ class PatchShotTest(AbstractShotTest):
|
||||
patch = {
|
||||
'op': 'from-web',
|
||||
'$set': {
|
||||
'description': u'Таким образом, этот человек заходит в бар, и говорит…',
|
||||
'properties.notes': u'Два бокала вашей лучшей водки, пожалуйста.',
|
||||
'properties.status': u'final',
|
||||
'description': 'Таким образом, этот человек заходит в бар, и говорит…',
|
||||
'properties.notes': 'Два бокала вашей лучшей водки, пожалуйста.',
|
||||
'properties.status': 'final',
|
||||
}
|
||||
}
|
||||
self.patch(url, json=patch, auth_token='token')
|
||||
|
||||
dbnode = self.get(url, auth_token='token').json()
|
||||
self.assertEqual(u'Таким образом, этот человек заходит в бар, и говорит…',
|
||||
self.assertEqual('Таким образом, этот человек заходит в бар, и говорит…',
|
||||
dbnode['description'])
|
||||
self.assertEqual(u'Два бокала вашей лучшей водки, пожалуйста.',
|
||||
self.assertEqual('Два бокала вашей лучшей водки, пожалуйста.',
|
||||
dbnode['properties']['notes'])
|
||||
self.assertEqual(u'final', dbnode['properties']['status'])
|
||||
self.assertEqual(u'New shot', dbnode['name'])
|
||||
self.assertEqual('final', dbnode['properties']['status'])
|
||||
self.assertEqual('New shot', dbnode['name'])
|
||||
|
||||
@responses.activate
|
||||
def test_patch_from_web_happy_nones(self):
|
||||
@@ -235,7 +235,7 @@ class PatchShotTest(AbstractShotTest):
|
||||
'$set': {
|
||||
'description': None,
|
||||
'properties.notes': None,
|
||||
'properties.status': u'final',
|
||||
'properties.status': 'final',
|
||||
}
|
||||
}
|
||||
self.patch(url, json=patch, auth_token='token')
|
||||
@@ -243,8 +243,8 @@ class PatchShotTest(AbstractShotTest):
|
||||
dbnode = self.get(url, auth_token='token').json()
|
||||
self.assertNotIn('description', dbnode)
|
||||
self.assertNotIn('notes', dbnode['properties'])
|
||||
self.assertEqual(u'final', dbnode['properties']['status'])
|
||||
self.assertEqual(u'New shot', dbnode['name'])
|
||||
self.assertEqual('final', dbnode['properties']['status'])
|
||||
self.assertEqual('New shot', dbnode['name'])
|
||||
|
||||
@responses.activate
|
||||
def test_patch_bad_op(self):
|
||||
@@ -409,15 +409,15 @@ class RequiredAfterCreationTest(AbstractShotTest):
|
||||
|
||||
node_type_name = node_type_shot['name']
|
||||
|
||||
shot = {'name': u'test shot',
|
||||
'description': u'',
|
||||
'properties': {u'trim_start_in_frames': 0,
|
||||
u'trim_end_in_frames': 0,
|
||||
u'duration_in_edit_in_frames': 1,
|
||||
u'cut_in_timeline_in_frames': 0},
|
||||
shot = {'name': 'test shot',
|
||||
'description': '',
|
||||
'properties': {'trim_start_in_frames': 0,
|
||||
'trim_end_in_frames': 0,
|
||||
'duration_in_edit_in_frames': 1,
|
||||
'cut_in_timeline_in_frames': 0},
|
||||
'node_type': node_type_name,
|
||||
'project': unicode(self.proj_id),
|
||||
'user': unicode(self.user_id)}
|
||||
'project': str(self.proj_id),
|
||||
'user': str(self.user_id)}
|
||||
|
||||
resp = self.post('/api/nodes', json=shot,
|
||||
auth_token='token', expected_status=201)
|
||||
@@ -441,27 +441,27 @@ class ProjectSummaryTest(unittest.TestCase):
|
||||
from attract.shots_and_assets import ProjectSummary
|
||||
|
||||
self.summ = ProjectSummary()
|
||||
self.summ.count(u'todo')
|
||||
self.summ.count(u'todo')
|
||||
self.summ.count(u'in-progress')
|
||||
self.summ.count(u'überhard')
|
||||
self.summ.count(u'Æon Flux')
|
||||
self.summ.count(u'Æon Flux')
|
||||
self.summ.count(u'in-progress')
|
||||
self.summ.count(u'todo')
|
||||
self.summ.count('todo')
|
||||
self.summ.count('todo')
|
||||
self.summ.count('in-progress')
|
||||
self.summ.count('überhard')
|
||||
self.summ.count('Æon Flux')
|
||||
self.summ.count('Æon Flux')
|
||||
self.summ.count('in-progress')
|
||||
self.summ.count('todo')
|
||||
|
||||
def test_counting(self):
|
||||
self.assertEqual(8, self.summ._total)
|
||||
self.assertEqual(3, self.summ._counts[u'todo'])
|
||||
self.assertEqual(2, self.summ._counts[u'Æon Flux'])
|
||||
self.assertEqual(3, self.summ._counts['todo'])
|
||||
self.assertEqual(2, self.summ._counts['Æon Flux'])
|
||||
|
||||
def test_percentages(self):
|
||||
percs = list(self.summ.percentages())
|
||||
|
||||
self.assertEqual((u'in-progress', 25), percs[0])
|
||||
self.assertEqual((u'todo', 38), percs[1])
|
||||
self.assertEqual((u'Æon Flux', 25), percs[2])
|
||||
self.assertEqual(('in-progress', 25), percs[0])
|
||||
self.assertEqual(('todo', 38), percs[1])
|
||||
self.assertEqual(('Æon Flux', 25), percs[2])
|
||||
|
||||
# This should be rounded down, not rounded up, to ensure the sum of
|
||||
# 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."""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import collections
|
||||
import datetime
|
||||
import logging.config
|
||||
@@ -158,48 +156,48 @@ class TestCommitLogObserver(unittest.TestCase):
|
||||
def test_create_log_entry(self):
|
||||
from attract import subversion
|
||||
|
||||
entry = subversion.create_log_entry(date_text=u'2016-10-21 17:40:17 +0200',
|
||||
msg=u'Ünicøde is good',
|
||||
entry = subversion.create_log_entry(date_text='2016-10-21 17:40:17 +0200',
|
||||
msg='Ünicøde is good',
|
||||
revision='123',
|
||||
author=u'børk',
|
||||
author='børk',
|
||||
changelist='nothing')
|
||||
self.assertEqual(tuple(entry), (
|
||||
datetime.datetime(2016, 10, 21, 15, 40, 17, 0, tzinfo=tzutc()),
|
||||
u'Ünicøde is good',
|
||||
'Ünicøde is good',
|
||||
'123',
|
||||
u'børk',
|
||||
'børk',
|
||||
'nothing'
|
||||
))
|
||||
|
||||
self.assertRaises(ValueError, subversion.create_log_entry,
|
||||
date_text='Unparseable date',
|
||||
msg=u'Ünicøde is good',
|
||||
msg='Ünicøde is good',
|
||||
revision='123',
|
||||
author=u'børk',
|
||||
author='børk',
|
||||
changelist='nothing')
|
||||
|
||||
entry = subversion.create_log_entry(date_text=u'2016-10-21 17:40:17 +0200',
|
||||
msg=u'Ünicøde is good',
|
||||
entry = subversion.create_log_entry(date_text='2016-10-21 17:40:17 +0200',
|
||||
msg='Ünicøde is good',
|
||||
revision='123',
|
||||
author=u'børk')
|
||||
author='børk')
|
||||
self.assertEqual(tuple(entry), (
|
||||
datetime.datetime(2016, 10, 21, 15, 40, 17, 0, tzinfo=tzutc()),
|
||||
u'Ünicøde is good',
|
||||
'Ünicøde is good',
|
||||
'123',
|
||||
u'børk',
|
||||
'børk',
|
||||
None
|
||||
))
|
||||
|
||||
entry = subversion.create_log_entry(
|
||||
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',
|
||||
author=u'børk')
|
||||
author='børk')
|
||||
self.assertEqual(tuple(entry), (
|
||||
datetime.datetime(2016, 10, 21, 15, 40, 17, 0, tzinfo=tzutc()),
|
||||
u'Ünicøde is good',
|
||||
'Ünicøde is good',
|
||||
'123',
|
||||
u'børk',
|
||||
'børk',
|
||||
None
|
||||
))
|
||||
|
||||
@@ -225,9 +223,9 @@ class PushCommitTest(AbstractAttractTest):
|
||||
subversion.task_logged.connect(record_blink)
|
||||
|
||||
push_data = {
|
||||
'repo': u'strange-repo™',
|
||||
'repo': 'strange-repo™',
|
||||
'revision': '4',
|
||||
'msg': u'မြန်မာဘာသာ is beautiful.\n\nThis solves task [T431134]',
|
||||
'msg': 'မြန်မာဘာသာ is beautiful.\n\nThis solves task [T431134]',
|
||||
'author': 'Haha',
|
||||
'date': '2016-10-21 17:40:17 +0200',
|
||||
}
|
||||
@@ -237,8 +235,8 @@ class PushCommitTest(AbstractAttractTest):
|
||||
auth_token=token['token'])
|
||||
|
||||
self.assertEqual(1, len(blinks))
|
||||
self.assertEqual(u'T431134', blinks[0]['shortcode'])
|
||||
self.assertEqual(u'မြန်မာဘာသာ is beautiful.\n\nThis solves task [T431134]',
|
||||
self.assertEqual('T431134', blinks[0]['shortcode'])
|
||||
self.assertEqual('မြန်မာဘာသာ is beautiful.\n\nThis solves task [T431134]',
|
||||
blinks[0]['log_entry'].msg)
|
||||
self.assertEqual(datetime.datetime(2016, 10, 21, 15, 40, 17, 0, tzinfo=tzutc()),
|
||||
blinks[0]['log_entry'].date)
|
||||
@@ -283,7 +281,7 @@ class SvnTaskLoggedTest(AbstractAttractTest):
|
||||
_, token = cli.create_svner_account('svner@example.com', self.project['url'])
|
||||
|
||||
# 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'],
|
||||
json={
|
||||
'revision': 6,
|
||||
|
@@ -34,7 +34,7 @@ class TaskWorkflowTest(AbstractAttractTest):
|
||||
|
||||
@responses.activate
|
||||
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)
|
||||
|
||||
# Test directly with MongoDB
|
||||
@@ -42,12 +42,12 @@ class TaskWorkflowTest(AbstractAttractTest):
|
||||
nodes_coll = self.app.data.driver.db['nodes']
|
||||
found = nodes_coll.find_one(ObjectId(task['_id']))
|
||||
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
|
||||
resp = self.get('/api/nodes/%s' % task['_id'])
|
||||
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
|
||||
def test_edit_task(self):
|
||||
@@ -61,15 +61,15 @@ class TaskWorkflowTest(AbstractAttractTest):
|
||||
self.assertRaises(sdk_exceptions.PreconditionFailed,
|
||||
self.mngr.edit_task,
|
||||
task._id,
|
||||
task_type=u'je møder',
|
||||
name=u'nööw name',
|
||||
description=u'€ ≠ ¥',
|
||||
task_type='je møder',
|
||||
name='nööw name',
|
||||
description='€ ≠ ¥',
|
||||
status='todo',
|
||||
_etag='jemoeder')
|
||||
self.mngr.edit_task(task._id,
|
||||
task_type=u'je møder',
|
||||
name=u'nööw name',
|
||||
description=u'€ ≠ ¥',
|
||||
task_type='je møder',
|
||||
name='nööw name',
|
||||
description='€ ≠ ¥',
|
||||
status='todo',
|
||||
_etag=task._etag)
|
||||
|
||||
@@ -77,10 +77,10 @@ class TaskWorkflowTest(AbstractAttractTest):
|
||||
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'])
|
||||
self.assertEqual('je møder', found['properties']['task_type'])
|
||||
self.assertEqual('todo', found['properties']['status'])
|
||||
self.assertEqual('nööw name', found['name'])
|
||||
self.assertEqual('€ ≠ ¥', found['description'])
|
||||
|
||||
@responses.activate
|
||||
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.
|
||||
old_name = task['name']
|
||||
new_name = u'nööw name'
|
||||
new_name = 'nööw name'
|
||||
|
||||
with self.app.test_request_context():
|
||||
# Log in as project admin user
|
||||
@@ -100,7 +100,7 @@ class TaskWorkflowTest(AbstractAttractTest):
|
||||
task_type=task['properties'].task_type,
|
||||
name=new_name,
|
||||
description=task.description,
|
||||
status=u'todo',
|
||||
status='todo',
|
||||
_etag=task._etag)
|
||||
|
||||
with self.app.test_request_context():
|
||||
@@ -115,8 +115,8 @@ class TaskWorkflowTest(AbstractAttractTest):
|
||||
def test_load_save_task(self):
|
||||
"""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_child = self.create_task(task_type=u'mamaaaah',
|
||||
task_parent = self.create_task(task_type='Just düüüh it')
|
||||
task_child = self.create_task(task_type='mamaaaah',
|
||||
parent=task_parent['_id'])
|
||||
|
||||
self.create_valid_auth_token(ctd.EXAMPLE_PROJECT_OWNER_ID, 'token')
|
||||
|
Reference in New Issue
Block a user