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:
parent
79d53e818b
commit
19761bfa60
@ -12,8 +12,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import contextlib
|
|
||||||
|
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
@ -25,9 +23,8 @@ INDEX_URL = reverse('horizon:mistral:actions:index')
|
|||||||
class ActionsTest(test.TestCase):
|
class ActionsTest(test.TestCase):
|
||||||
|
|
||||||
def test_index(self):
|
def test_index(self):
|
||||||
with contextlib.nested(
|
with mock.patch('mistraldashboard.api.action_list',
|
||||||
mock.patch('mistraldashboard.api.action_list',
|
return_value=self.mistralclient_actions.list()):
|
||||||
return_value=self.mistralclient_actions.list()),):
|
|
||||||
res = self.client.get(INDEX_URL)
|
res = self.client.get(INDEX_URL)
|
||||||
|
|
||||||
self.assertTemplateUsed(res, 'mistral/actions/index.html')
|
self.assertTemplateUsed(res, 'mistral/actions/index.html')
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import contextlib
|
|
||||||
|
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
@ -25,9 +23,8 @@ INDEX_URL = reverse('horizon:mistral:executions:index')
|
|||||||
class ExecutionsTest(test.TestCase):
|
class ExecutionsTest(test.TestCase):
|
||||||
|
|
||||||
def test_index(self):
|
def test_index(self):
|
||||||
with contextlib.nested(
|
with mock.patch('mistraldashboard.api.pagination_list',
|
||||||
mock.patch('mistraldashboard.api.pagination_list',
|
return_value=self.mistralclient_executions.list()):
|
||||||
return_value=self.mistralclient_executions.list()),):
|
|
||||||
res = self.client.get(INDEX_URL)
|
res = self.client.get(INDEX_URL)
|
||||||
|
|
||||||
self.assertTemplateUsed(res, 'mistral/executions/index.html')
|
self.assertTemplateUsed(res, 'mistral/executions/index.html')
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import contextlib
|
|
||||||
|
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
@ -25,9 +23,8 @@ INDEX_URL = reverse('horizon:mistral:tasks:index')
|
|||||||
class TasksTest(test.TestCase):
|
class TasksTest(test.TestCase):
|
||||||
|
|
||||||
def test_index(self):
|
def test_index(self):
|
||||||
with contextlib.nested(
|
with mock.patch('mistraldashboard.api.task_list',
|
||||||
mock.patch('mistraldashboard.api.task_list',
|
return_value=self.mistralclient_tasks.list()):
|
||||||
return_value=self.mistralclient_tasks.list()),):
|
|
||||||
res = self.client.get(INDEX_URL)
|
res = self.client.get(INDEX_URL)
|
||||||
|
|
||||||
self.assertTemplateUsed(res, 'mistral/tasks/index.html')
|
self.assertTemplateUsed(res, 'mistral/tasks/index.html')
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
@ -74,7 +76,7 @@ class DefinitionForm(forms.SelfHandlingForm):
|
|||||||
cleaned_data['definition']
|
cleaned_data['definition']
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise forms.ValidationError(unicode(e))
|
raise forms.ValidationError(six.text_type(e))
|
||||||
|
|
||||||
if not validated.get('valid'):
|
if not validated.get('valid'):
|
||||||
raise forms.ValidationError(
|
raise forms.ValidationError(
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import contextlib
|
|
||||||
|
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
@ -27,9 +25,8 @@ UPDATE_URL = reverse('horizon:mistral:workbooks:update')
|
|||||||
class WorkflowsTest(test.TestCase):
|
class WorkflowsTest(test.TestCase):
|
||||||
|
|
||||||
def test_index(self):
|
def test_index(self):
|
||||||
with contextlib.nested(
|
with mock.patch('mistraldashboard.api.workbook_list',
|
||||||
mock.patch('mistraldashboard.api.workbook_list',
|
return_value=self.mistralclient_workbooks.list()):
|
||||||
return_value=self.mistralclient_workbooks.list()),):
|
|
||||||
res = self.client.get(INDEX_URL)
|
res = self.client.get(INDEX_URL)
|
||||||
|
|
||||||
self.assertTemplateUsed(res, 'mistral/workbooks/index.html')
|
self.assertTemplateUsed(res, 'mistral/workbooks/index.html')
|
||||||
@ -51,9 +48,8 @@ class WorkflowsTest(test.TestCase):
|
|||||||
'definition_source': 'raw',
|
'definition_source': 'raw',
|
||||||
'definition_data': workbook.definition
|
'definition_data': workbook.definition
|
||||||
}
|
}
|
||||||
with contextlib.nested(
|
with mock.patch('mistraldashboard.api.workbook_validate',
|
||||||
mock.patch('mistraldashboard.api.workbook_validate',
|
return_value={'valid': True}) as mocked_validate:
|
||||||
return_value={'valid': True}),) as (mocked_validate,):
|
|
||||||
res = self.client.post(url, form_data)
|
res = self.client.post(url, form_data)
|
||||||
|
|
||||||
self.assertTemplateUsed(res, 'mistral/workbooks/create.html')
|
self.assertTemplateUsed(res, 'mistral/workbooks/create.html')
|
||||||
@ -65,9 +61,8 @@ class WorkflowsTest(test.TestCase):
|
|||||||
form_data = {
|
form_data = {
|
||||||
'definition': workbook.definition
|
'definition': workbook.definition
|
||||||
}
|
}
|
||||||
with contextlib.nested(
|
with mock.patch('mistraldashboard.api.workbook_create',
|
||||||
mock.patch('mistraldashboard.api.workbook_create',
|
return_value=workbook) as mocked_create:
|
||||||
return_value=workbook),) as (mocked_create,):
|
|
||||||
res = self.client.post(CREATE_URL, form_data)
|
res = self.client.post(CREATE_URL, form_data)
|
||||||
self.assertNoFormErrors(res)
|
self.assertNoFormErrors(res)
|
||||||
self.assertEqual(res.status_code, 302)
|
self.assertEqual(res.status_code, 302)
|
||||||
@ -95,9 +90,8 @@ class WorkflowsTest(test.TestCase):
|
|||||||
'definition_source': 'raw',
|
'definition_source': 'raw',
|
||||||
'definition_data': workbook.definition
|
'definition_data': workbook.definition
|
||||||
}
|
}
|
||||||
with contextlib.nested(
|
with mock.patch('mistraldashboard.api.workbook_validate',
|
||||||
mock.patch('mistraldashboard.api.workbook_validate',
|
return_value={'valid': True}) as mocked_validate:
|
||||||
return_value={'valid': True}),) as (mocked_validate,):
|
|
||||||
res = self.client.post(url, form_data)
|
res = self.client.post(url, form_data)
|
||||||
|
|
||||||
self.assertTemplateUsed(res, 'mistral/workbooks/update.html')
|
self.assertTemplateUsed(res, 'mistral/workbooks/update.html')
|
||||||
@ -109,9 +103,8 @@ class WorkflowsTest(test.TestCase):
|
|||||||
form_data = {
|
form_data = {
|
||||||
'definition': workbook.definition
|
'definition': workbook.definition
|
||||||
}
|
}
|
||||||
with contextlib.nested(
|
with mock.patch('mistraldashboard.api.workbook_update',
|
||||||
mock.patch('mistraldashboard.api.workbook_update',
|
return_value=workbook) as mocked_update:
|
||||||
return_value=workbook),) as (mocked_update,):
|
|
||||||
res = self.client.post(UPDATE_URL, form_data)
|
res = self.client.post(UPDATE_URL, form_data)
|
||||||
self.assertNoFormErrors(res)
|
self.assertNoFormErrors(res)
|
||||||
self.assertEqual(res.status_code, 302)
|
self.assertEqual(res.status_code, 302)
|
||||||
@ -128,12 +121,13 @@ class WorkflowsTest(test.TestCase):
|
|||||||
data = {'action': 'workbooks__delete',
|
data = {'action': 'workbooks__delete',
|
||||||
'object_ids': [workbooks[0].name]}
|
'object_ids': [workbooks[0].name]}
|
||||||
|
|
||||||
with contextlib.nested(
|
with mock.patch(
|
||||||
mock.patch('mistraldashboard.api.workbook_list',
|
'mistraldashboard.api.workbook_list',
|
||||||
return_value=workbooks),
|
return_value=workbooks
|
||||||
mock.patch('mistraldashboard.api.workbook_delete',
|
), mock.patch(
|
||||||
return_value=None),) as (
|
'mistraldashboard.api.workbook_delete',
|
||||||
mocked_list, mocked_delete):
|
return_value=None
|
||||||
|
) as mocked_delete:
|
||||||
|
|
||||||
res = self.client.post(INDEX_URL, data)
|
res = self.client.post(INDEX_URL, data)
|
||||||
|
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
@ -108,7 +110,7 @@ class DefinitionForm(forms.SelfHandlingForm):
|
|||||||
cleaned_data['definition']
|
cleaned_data['definition']
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise forms.ValidationError(unicode(e))
|
raise forms.ValidationError(six.text_type(e))
|
||||||
|
|
||||||
if not validated.get('valid'):
|
if not validated.get('valid'):
|
||||||
raise forms.ValidationError(
|
raise forms.ValidationError(
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import contextlib
|
|
||||||
|
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
@ -27,9 +25,8 @@ UPDATE_URL = reverse('horizon:mistral:workflows:update')
|
|||||||
class WorkflowsTest(test.TestCase):
|
class WorkflowsTest(test.TestCase):
|
||||||
|
|
||||||
def test_index(self):
|
def test_index(self):
|
||||||
with contextlib.nested(
|
with mock.patch('mistraldashboard.api.workflow_list',
|
||||||
mock.patch('mistraldashboard.api.workflow_list',
|
return_value=self.mistralclient_workflows.list()):
|
||||||
return_value=self.mistralclient_workflows.list()),):
|
|
||||||
res = self.client.get(INDEX_URL)
|
res = self.client.get(INDEX_URL)
|
||||||
|
|
||||||
self.assertTemplateUsed(res, 'mistral/workflows/index.html')
|
self.assertTemplateUsed(res, 'mistral/workflows/index.html')
|
||||||
@ -51,9 +48,8 @@ class WorkflowsTest(test.TestCase):
|
|||||||
'definition_source': 'raw',
|
'definition_source': 'raw',
|
||||||
'definition_data': workflow.definition
|
'definition_data': workflow.definition
|
||||||
}
|
}
|
||||||
with contextlib.nested(
|
with mock.patch('mistraldashboard.api.workflow_validate',
|
||||||
mock.patch('mistraldashboard.api.workflow_validate',
|
return_value={'valid': True}) as mocked_validate:
|
||||||
return_value={'valid': True}),) as (mocked_validate,):
|
|
||||||
res = self.client.post(url, form_data)
|
res = self.client.post(url, form_data)
|
||||||
|
|
||||||
self.assertTemplateUsed(res, 'mistral/workflows/create.html')
|
self.assertTemplateUsed(res, 'mistral/workflows/create.html')
|
||||||
@ -65,9 +61,8 @@ class WorkflowsTest(test.TestCase):
|
|||||||
form_data = {
|
form_data = {
|
||||||
'definition': workflow.definition
|
'definition': workflow.definition
|
||||||
}
|
}
|
||||||
with contextlib.nested(
|
with mock.patch('mistraldashboard.api.workflow_create',
|
||||||
mock.patch('mistraldashboard.api.workflow_create',
|
return_value=workflow) as mocked_create:
|
||||||
return_value=workflow),) as (mocked_create,):
|
|
||||||
res = self.client.post(CREATE_URL, form_data)
|
res = self.client.post(CREATE_URL, form_data)
|
||||||
self.assertNoFormErrors(res)
|
self.assertNoFormErrors(res)
|
||||||
self.assertEqual(res.status_code, 302)
|
self.assertEqual(res.status_code, 302)
|
||||||
@ -95,9 +90,8 @@ class WorkflowsTest(test.TestCase):
|
|||||||
'definition_source': 'raw',
|
'definition_source': 'raw',
|
||||||
'definition_data': workflow.definition
|
'definition_data': workflow.definition
|
||||||
}
|
}
|
||||||
with contextlib.nested(
|
with mock.patch('mistraldashboard.api.workflow_validate',
|
||||||
mock.patch('mistraldashboard.api.workflow_validate',
|
return_value={'valid': True}) as mocked_validate:
|
||||||
return_value={'valid': True}),) as (mocked_validate,):
|
|
||||||
res = self.client.post(url, form_data)
|
res = self.client.post(url, form_data)
|
||||||
|
|
||||||
self.assertTemplateUsed(res, 'mistral/workflows/update.html')
|
self.assertTemplateUsed(res, 'mistral/workflows/update.html')
|
||||||
@ -109,9 +103,8 @@ class WorkflowsTest(test.TestCase):
|
|||||||
form_data = {
|
form_data = {
|
||||||
'definition': workflow.definition
|
'definition': workflow.definition
|
||||||
}
|
}
|
||||||
with contextlib.nested(
|
with mock.patch('mistraldashboard.api.workflow_update',
|
||||||
mock.patch('mistraldashboard.api.workflow_update',
|
return_value=workflow) as mocked_update:
|
||||||
return_value=workflow),) as (mocked_update,):
|
|
||||||
res = self.client.post(UPDATE_URL, form_data)
|
res = self.client.post(UPDATE_URL, form_data)
|
||||||
self.assertNoFormErrors(res)
|
self.assertNoFormErrors(res)
|
||||||
self.assertEqual(res.status_code, 302)
|
self.assertEqual(res.status_code, 302)
|
||||||
@ -128,12 +121,13 @@ class WorkflowsTest(test.TestCase):
|
|||||||
data = {'action': 'workflows__delete',
|
data = {'action': 'workflows__delete',
|
||||||
'object_ids': [workflows[0].name]}
|
'object_ids': [workflows[0].name]}
|
||||||
|
|
||||||
with contextlib.nested(
|
with mock.patch(
|
||||||
mock.patch('mistraldashboard.api.workflow_list',
|
'mistraldashboard.api.workflow_list',
|
||||||
return_value=workflows),
|
return_value=workflows
|
||||||
mock.patch('mistraldashboard.api.workflow_delete',
|
), mock.patch(
|
||||||
return_value=None),) as (
|
'mistraldashboard.api.workflow_delete',
|
||||||
mocked_list, mocked_delete):
|
return_value=None
|
||||||
|
) as mocked_delete:
|
||||||
|
|
||||||
res = self.client.post(INDEX_URL, data)
|
res = self.client.post(INDEX_URL, data)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user