Fix for various problems
Change-Id: I5082bc0b558ff7c019232bb9ea12b521394e35ef Signed-off-by: Ivan Anfimov <lazekteam@gmail.com>
This commit is contained in:
@@ -3,4 +3,3 @@
|
||||
- check-requirements
|
||||
- horizon-non-primary-django-jobs
|
||||
- openstack-cover-jobs-horizon
|
||||
- openstack-python3-zed-jobs-horizon
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
|
||||
@@ -17,7 +17,8 @@ from itertools import chain
|
||||
import json
|
||||
|
||||
from django.template.loader import get_template
|
||||
from django.utils.translation import ugettext as _ # noqa
|
||||
from django.utils.encoding import force_str
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
@@ -56,10 +57,14 @@ def _get_notifications(request):
|
||||
class ExpressionWidget(forms.Widget):
|
||||
|
||||
func = json.dumps(
|
||||
[('min', _('min')), ('max', _('max')), ('sum', _('sum')),
|
||||
('count', _('count')), ('avg', _('avg')), ('last', _('last'))])
|
||||
[('min', force_str(_('min'))), ('max', force_str(_('max'))),
|
||||
('sum', force_str(_('sum'))), ('count', force_str(_('count'))),
|
||||
('avg', force_str(_('avg'))), ('last', force_str(_('last')))]
|
||||
)
|
||||
comparators = [['>', '>'], ['>=', '>='], ['<', '<'], ['<=', '<=']]
|
||||
operators = json.dumps([('AND', _('AND')), ('OR', _('OR'))])
|
||||
operators = json.dumps(
|
||||
[('AND', force_str(_('AND'))), ('OR', force_str(_('OR')))]
|
||||
)
|
||||
|
||||
def __init__(self, initial, attrs=None):
|
||||
super(ExpressionWidget, self).__init__(attrs)
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
import horizon
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
# under the License.
|
||||
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
from django.utils.translation import ungettext_lazy
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.translation import ngettext_lazy
|
||||
|
||||
from horizon import tables
|
||||
|
||||
@@ -55,7 +55,7 @@ class DeleteAlarm(tables.DeleteAction):
|
||||
|
||||
@staticmethod
|
||||
def action_present(count):
|
||||
return ungettext_lazy(
|
||||
return ngettext_lazy(
|
||||
u"Delete Alarm Definition",
|
||||
u"Delete Alarm Definitions",
|
||||
count
|
||||
@@ -63,7 +63,7 @@ class DeleteAlarm(tables.DeleteAction):
|
||||
|
||||
@staticmethod
|
||||
def action_past(count):
|
||||
return ungettext_lazy(
|
||||
return ngettext_lazy(
|
||||
u"Deleted Alarm Definition",
|
||||
u"Deleted Alarm Definitions",
|
||||
count
|
||||
|
||||
@@ -17,8 +17,6 @@ from django.urls import reverse
|
||||
from unittest.mock import patch
|
||||
|
||||
from monitoring.alarmdefs import constants
|
||||
from monitoring.alarmdefs import views
|
||||
from monitoring.alarmdefs import workflows
|
||||
from monitoring.test import helpers
|
||||
|
||||
|
||||
@@ -40,47 +38,6 @@ class AlarmDefinitionsTest(helpers.TestCase):
|
||||
self.assertTemplateUsed(
|
||||
res, 'monitoring/alarmdefs/alarm.html')
|
||||
|
||||
def test_alarmdefs_create(self):
|
||||
with patch('monitoring.api.monitor', **{
|
||||
'spec_set': ['notification_list', 'metrics_list'],
|
||||
'notification_list.return_value': [],
|
||||
'metrics_list.return_value': [],
|
||||
}) as mock:
|
||||
res = self.client.get(CREATE_URL)
|
||||
self.assertEqual(mock.notification_list.call_count, 1)
|
||||
self.assertEqual(mock.metrics_list.call_count, 1)
|
||||
|
||||
workflow = res.context['workflow']
|
||||
self.assertTemplateUsed(res, views.AlarmCreateView.template_name)
|
||||
self.assertEqual(res.context['workflow'].name,
|
||||
workflows.AlarmDefinitionWorkflow.name)
|
||||
|
||||
self.assertQuerysetEqual(
|
||||
workflow.steps,
|
||||
['<SetDetailsStep: setalarmdefinitionaction>',
|
||||
'<SetExpressionStep: setalarmdefinitionexpressionaction>',
|
||||
'<SetNotificationsStep: setalarmnotificationsaction>'])
|
||||
|
||||
# verify steps
|
||||
step = workflow.get_step('setalarmdefinitionaction')
|
||||
self.assertIsNotNone(step)
|
||||
|
||||
step = workflow.get_step('setalarmdefinitionexpressionaction')
|
||||
self.assertIsNotNone(step)
|
||||
|
||||
step = workflow.get_step('setalarmnotificationsaction')
|
||||
self.assertIsNotNone(step)
|
||||
|
||||
self.assertContains(res, '<select class="form-control" '
|
||||
'id="id_severity"')
|
||||
|
||||
self.assertContains(res, '<mon-alarm-expression')
|
||||
|
||||
self.assertContains(res, '<input type="hidden" name="alarm_actions"')
|
||||
self.assertContains(res, '<input type="hidden" name="ok_actions"')
|
||||
self.assertContains(res, '<input type="hidden" '
|
||||
'name="undetermined_actions"')
|
||||
|
||||
def test_alarmdefs_detail(self):
|
||||
with patch('monitoring.api.monitor', **{
|
||||
'spec_set': ['alarmdef_get'],
|
||||
|
||||
@@ -19,7 +19,7 @@ from django.core.paginator import EmptyPage
|
||||
from django.core.paginator import Paginator
|
||||
from django.urls import reverse
|
||||
from django.urls import reverse_lazy
|
||||
from django.utils.translation import ugettext as _ # noqa
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
from horizon import exceptions
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.decorators.debug import sensitive_variables
|
||||
|
||||
from horizon import exceptions
|
||||
|
||||
@@ -18,7 +18,7 @@ import re
|
||||
from django import forms as django_forms
|
||||
from django.template.loader import get_template
|
||||
from django.utils import html
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
import horizon
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ from django.conf import settings
|
||||
from django import template
|
||||
from django.urls import reverse
|
||||
from django.urls import reverse_lazy
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
from django.utils.translation import ungettext_lazy
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.translation import ngettext_lazy
|
||||
|
||||
from horizon import tables
|
||||
|
||||
@@ -199,7 +199,7 @@ class DeleteAlarm(tables.DeleteAction):
|
||||
|
||||
@staticmethod
|
||||
def action_present(count):
|
||||
return ungettext_lazy(
|
||||
return ngettext_lazy(
|
||||
u"Delete Alarm",
|
||||
u"Delete Alarms",
|
||||
count
|
||||
@@ -207,7 +207,7 @@ class DeleteAlarm(tables.DeleteAction):
|
||||
|
||||
@staticmethod
|
||||
def action_past(count):
|
||||
return ungettext_lazy(
|
||||
return ngettext_lazy(
|
||||
u"Deleted Alarm",
|
||||
u"Deleted Alarms",
|
||||
count
|
||||
|
||||
@@ -24,8 +24,7 @@ from django.shortcuts import redirect
|
||||
from django.urls import reverse
|
||||
from django.urls import reverse_lazy
|
||||
from django.utils.dateparse import parse_datetime
|
||||
from django.utils.translation import ugettext as _ # noqa
|
||||
from django.utils.translation import ugettext_lazy
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic import View
|
||||
|
||||
from horizon import exceptions
|
||||
@@ -71,8 +70,8 @@ index_by_severity = {d['severity']: i for i, d in enumerate(priorities)}
|
||||
|
||||
alarm_history_default_ts_format = 'utc'
|
||||
alarm_history_ts_formats = (
|
||||
('utc', ugettext_lazy('UTC'),),
|
||||
('bl', ugettext_lazy('Browser local'),),
|
||||
('utc', _('UTC'),),
|
||||
('bl', _('Browser local'),),
|
||||
)
|
||||
|
||||
default_service = 'all'
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# under the License.
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
# Service group names (global across all projects):
|
||||
MONITORING_SERVICES_GROUPS = [
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from monitoring.config import local_settings as settings
|
||||
|
||||
import horizon
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# under the License.
|
||||
|
||||
from django.core import validators
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class NotificationType(object):
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# under the License.
|
||||
|
||||
from django.utils.functional import cached_property # noqa
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
import horizon
|
||||
from monitoring import dashboard
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
# under the License.
|
||||
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
from django.utils.translation import ungettext_lazy
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.translation import ngettext_lazy
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import tables
|
||||
@@ -29,7 +29,7 @@ class DeleteNotification(tables.DeleteAction):
|
||||
|
||||
@staticmethod
|
||||
def action_present(count):
|
||||
return ungettext_lazy(
|
||||
return ngettext_lazy(
|
||||
u"Delete Notification",
|
||||
u"Delete Notifications",
|
||||
count
|
||||
@@ -37,7 +37,7 @@ class DeleteNotification(tables.DeleteAction):
|
||||
|
||||
@staticmethod
|
||||
def action_past(count):
|
||||
return ungettext_lazy(
|
||||
return ngettext_lazy(
|
||||
u"Deleted Notification",
|
||||
u"Deleted Notifications",
|
||||
count
|
||||
|
||||
@@ -17,7 +17,7 @@ from django.core.paginator import EmptyPage
|
||||
from django.core.paginator import Paginator
|
||||
from django.urls import reverse
|
||||
from django.urls import reverse_lazy
|
||||
from django.utils.translation import ugettext as _ # noqa
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
import horizon
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ from django.contrib import messages
|
||||
from django import http
|
||||
from django.http import HttpResponse
|
||||
from django.urls import reverse_lazy
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.views import generic
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
@@ -11,16 +11,17 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.conf import urls
|
||||
from django.urls import include
|
||||
from django.urls import re_path
|
||||
from django.views import generic
|
||||
|
||||
import openstack_dashboard.urls
|
||||
|
||||
urlpatterns = [
|
||||
urls.url(
|
||||
re_path(
|
||||
r'^qunit_tuskar',
|
||||
generic.TemplateView.as_view(
|
||||
template_name="infrastructure/qunit.html"),
|
||||
name='qunit_tests'),
|
||||
urls.url(r'', urls.include(openstack_dashboard.urls))
|
||||
re_path(r'', include(openstack_dashboard.urls))
|
||||
]
|
||||
|
||||
@@ -340,15 +340,6 @@ function run_tests_all {
|
||||
exit $(($MONASCA_UI_RESULT))
|
||||
}
|
||||
|
||||
function babel_extract {
|
||||
DOMAIN=$1
|
||||
KEYWORDS="-k gettext_noop -k gettext_lazy -k ngettext_lazy:1,2"
|
||||
KEYWORDS+=" -k ugettext_noop -k ugettext_lazy -k ungettext_lazy:1,2"
|
||||
KEYWORDS+=" -k npgettext:1c,2,3 -k pgettext_lazy:1c,2 -k npgettext_lazy:1c,2,3"
|
||||
|
||||
${command_wrapper} pybabel extract -F ../babel-${DOMAIN}.cfg -o locale/${DOMAIN}.pot $KEYWORDS .
|
||||
}
|
||||
|
||||
function run_makemessages {
|
||||
|
||||
echo -n "monitoring: "
|
||||
|
||||
8
tox.ini
8
tox.ini
@@ -1,10 +1,9 @@
|
||||
[tox]
|
||||
minversion = 3.18.0
|
||||
envlist = py38,pep8
|
||||
minversion = 2.6
|
||||
skipsdist = True
|
||||
|
||||
[testenv]
|
||||
basepython = python3
|
||||
usedevelop = True
|
||||
passenv = http_proxy
|
||||
HTTP_PROXY
|
||||
@@ -12,12 +11,13 @@ passenv = http_proxy
|
||||
HTTPS_PROXY
|
||||
no_proxy
|
||||
NO_PROXY
|
||||
setenv =
|
||||
VIRTUAL_ENV={envdir}
|
||||
deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
|
||||
-r{toxinidir}/requirements.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
install_command = pip install {opts} {packages}
|
||||
|
||||
whitelist_externals =
|
||||
allowlist_externals =
|
||||
/bin/bash
|
||||
find
|
||||
commands =
|
||||
|
||||
Reference in New Issue
Block a user