Fix gate-mistral-dashboard-python34

Fixed a lot of AttributeError: 'module' object has no attribute 'nested'
and F821 undefined name 'unicode' errors.

Change-Id: I79e73e27608ec6b76fd4ccf0ee9dcaf2ddf965ed
Closes-Bug: #1544499
This commit is contained in:
Anastasia Kuznetsova 2016-02-16 11:15:59 +03:00
parent 79d53e818b
commit 19761bfa60
7 changed files with 46 additions and 63 deletions

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import contextlib
from django.core.urlresolvers import reverse
import mock
@ -25,9 +23,8 @@ INDEX_URL = reverse('horizon:mistral:actions:index')
class ActionsTest(test.TestCase):
def test_index(self):
with contextlib.nested(
mock.patch('mistraldashboard.api.action_list',
return_value=self.mistralclient_actions.list()),):
with mock.patch('mistraldashboard.api.action_list',
return_value=self.mistralclient_actions.list()):
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'mistral/actions/index.html')

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import contextlib
from django.core.urlresolvers import reverse
import mock
@ -25,9 +23,8 @@ INDEX_URL = reverse('horizon:mistral:executions:index')
class ExecutionsTest(test.TestCase):
def test_index(self):
with contextlib.nested(
mock.patch('mistraldashboard.api.pagination_list',
return_value=self.mistralclient_executions.list()),):
with mock.patch('mistraldashboard.api.pagination_list',
return_value=self.mistralclient_executions.list()):
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'mistral/executions/index.html')

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import contextlib
from django.core.urlresolvers import reverse
import mock
@ -25,9 +23,8 @@ INDEX_URL = reverse('horizon:mistral:tasks:index')
class TasksTest(test.TestCase):
def test_index(self):
with contextlib.nested(
mock.patch('mistraldashboard.api.task_list',
return_value=self.mistralclient_tasks.list()),):
with mock.patch('mistraldashboard.api.task_list',
return_value=self.mistralclient_tasks.list()):
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'mistral/tasks/index.html')

View File

@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import six
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
@ -74,7 +76,7 @@ class DefinitionForm(forms.SelfHandlingForm):
cleaned_data['definition']
)
except Exception as e:
raise forms.ValidationError(unicode(e))
raise forms.ValidationError(six.text_type(e))
if not validated.get('valid'):
raise forms.ValidationError(

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import contextlib
from django.core.urlresolvers import reverse
import mock
@ -27,9 +25,8 @@ UPDATE_URL = reverse('horizon:mistral:workbooks:update')
class WorkflowsTest(test.TestCase):
def test_index(self):
with contextlib.nested(
mock.patch('mistraldashboard.api.workbook_list',
return_value=self.mistralclient_workbooks.list()),):
with mock.patch('mistraldashboard.api.workbook_list',
return_value=self.mistralclient_workbooks.list()):
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'mistral/workbooks/index.html')
@ -51,9 +48,8 @@ class WorkflowsTest(test.TestCase):
'definition_source': 'raw',
'definition_data': workbook.definition
}
with contextlib.nested(
mock.patch('mistraldashboard.api.workbook_validate',
return_value={'valid': True}),) as (mocked_validate,):
with mock.patch('mistraldashboard.api.workbook_validate',
return_value={'valid': True}) as mocked_validate:
res = self.client.post(url, form_data)
self.assertTemplateUsed(res, 'mistral/workbooks/create.html')
@ -65,9 +61,8 @@ class WorkflowsTest(test.TestCase):
form_data = {
'definition': workbook.definition
}
with contextlib.nested(
mock.patch('mistraldashboard.api.workbook_create',
return_value=workbook),) as (mocked_create,):
with mock.patch('mistraldashboard.api.workbook_create',
return_value=workbook) as mocked_create:
res = self.client.post(CREATE_URL, form_data)
self.assertNoFormErrors(res)
self.assertEqual(res.status_code, 302)
@ -95,9 +90,8 @@ class WorkflowsTest(test.TestCase):
'definition_source': 'raw',
'definition_data': workbook.definition
}
with contextlib.nested(
mock.patch('mistraldashboard.api.workbook_validate',
return_value={'valid': True}),) as (mocked_validate,):
with mock.patch('mistraldashboard.api.workbook_validate',
return_value={'valid': True}) as mocked_validate:
res = self.client.post(url, form_data)
self.assertTemplateUsed(res, 'mistral/workbooks/update.html')
@ -109,9 +103,8 @@ class WorkflowsTest(test.TestCase):
form_data = {
'definition': workbook.definition
}
with contextlib.nested(
mock.patch('mistraldashboard.api.workbook_update',
return_value=workbook),) as (mocked_update,):
with mock.patch('mistraldashboard.api.workbook_update',
return_value=workbook) as mocked_update:
res = self.client.post(UPDATE_URL, form_data)
self.assertNoFormErrors(res)
self.assertEqual(res.status_code, 302)
@ -128,12 +121,13 @@ class WorkflowsTest(test.TestCase):
data = {'action': 'workbooks__delete',
'object_ids': [workbooks[0].name]}
with contextlib.nested(
mock.patch('mistraldashboard.api.workbook_list',
return_value=workbooks),
mock.patch('mistraldashboard.api.workbook_delete',
return_value=None),) as (
mocked_list, mocked_delete):
with mock.patch(
'mistraldashboard.api.workbook_list',
return_value=workbooks
), mock.patch(
'mistraldashboard.api.workbook_delete',
return_value=None
) as mocked_delete:
res = self.client.post(INDEX_URL, data)

View File

@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import six
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
@ -108,7 +110,7 @@ class DefinitionForm(forms.SelfHandlingForm):
cleaned_data['definition']
)
except Exception as e:
raise forms.ValidationError(unicode(e))
raise forms.ValidationError(six.text_type(e))
if not validated.get('valid'):
raise forms.ValidationError(

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import contextlib
from django.core.urlresolvers import reverse
import mock
@ -27,9 +25,8 @@ UPDATE_URL = reverse('horizon:mistral:workflows:update')
class WorkflowsTest(test.TestCase):
def test_index(self):
with contextlib.nested(
mock.patch('mistraldashboard.api.workflow_list',
return_value=self.mistralclient_workflows.list()),):
with mock.patch('mistraldashboard.api.workflow_list',
return_value=self.mistralclient_workflows.list()):
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'mistral/workflows/index.html')
@ -51,9 +48,8 @@ class WorkflowsTest(test.TestCase):
'definition_source': 'raw',
'definition_data': workflow.definition
}
with contextlib.nested(
mock.patch('mistraldashboard.api.workflow_validate',
return_value={'valid': True}),) as (mocked_validate,):
with mock.patch('mistraldashboard.api.workflow_validate',
return_value={'valid': True}) as mocked_validate:
res = self.client.post(url, form_data)
self.assertTemplateUsed(res, 'mistral/workflows/create.html')
@ -65,9 +61,8 @@ class WorkflowsTest(test.TestCase):
form_data = {
'definition': workflow.definition
}
with contextlib.nested(
mock.patch('mistraldashboard.api.workflow_create',
return_value=workflow),) as (mocked_create,):
with mock.patch('mistraldashboard.api.workflow_create',
return_value=workflow) as mocked_create:
res = self.client.post(CREATE_URL, form_data)
self.assertNoFormErrors(res)
self.assertEqual(res.status_code, 302)
@ -95,9 +90,8 @@ class WorkflowsTest(test.TestCase):
'definition_source': 'raw',
'definition_data': workflow.definition
}
with contextlib.nested(
mock.patch('mistraldashboard.api.workflow_validate',
return_value={'valid': True}),) as (mocked_validate,):
with mock.patch('mistraldashboard.api.workflow_validate',
return_value={'valid': True}) as mocked_validate:
res = self.client.post(url, form_data)
self.assertTemplateUsed(res, 'mistral/workflows/update.html')
@ -109,9 +103,8 @@ class WorkflowsTest(test.TestCase):
form_data = {
'definition': workflow.definition
}
with contextlib.nested(
mock.patch('mistraldashboard.api.workflow_update',
return_value=workflow),) as (mocked_update,):
with mock.patch('mistraldashboard.api.workflow_update',
return_value=workflow) as mocked_update:
res = self.client.post(UPDATE_URL, form_data)
self.assertNoFormErrors(res)
self.assertEqual(res.status_code, 302)
@ -128,12 +121,13 @@ class WorkflowsTest(test.TestCase):
data = {'action': 'workflows__delete',
'object_ids': [workflows[0].name]}
with contextlib.nested(
mock.patch('mistraldashboard.api.workflow_list',
return_value=workflows),
mock.patch('mistraldashboard.api.workflow_delete',
return_value=None),) as (
mocked_list, mocked_delete):
with mock.patch(
'mistraldashboard.api.workflow_list',
return_value=workflows
), mock.patch(
'mistraldashboard.api.workflow_delete',
return_value=None
) as mocked_delete:
res = self.client.post(INDEX_URL, data)