63 Commits

Author SHA1 Message Date
Tatiana Ovchinnikova
539c14e1c6 Remove #noqa from two common imports and add them to import_exceptions
We have two imports with #noqa: django.conf.urls.patterns and
django.conf.urls.url however using them is a standard way of creating
any urls.py module. So there are over 150 imports in Horizon code
where #noqa could be replaced with two lines in list of import_exceptions.

Change-Id: I81c3290e0dc958b5037dd6a87e44df18adfbe751
2014-09-16 14:08:28 +04:00
Yves-Gwenael Bourhis
f4594e8199 Allow translators to translate BatchActions
Currently BatchAction proposes only an action_present and action_past verb
to be concatenated with a data_type_singular or data_type_plural string.

The issue is that many languages need to conjugate the verb with the
plural/singular subject, and some translations where terribly awfull and
impossible to do.
Indeed, some languages have up to 5 plural forms depending on the number of
items.

This patch introduces the fact that action_present is a method instead of an
attribute, which in conjonction with https://review.openstack.org/57701 allows
better translation to be performed.

This patch also adds contextual mrkers to STATUS_DISPLAY_CHOICES,
TASK_DISPLAY_CHOICES and POWER_DISPLAY_CHOICES because it was impossible to
translate the stand-alone words out of context for a translator (i.e. the word
"active" will be translated differently if the active object is feminine or
masculine, since feminine and masculine depends also on the language, it is
mission impossible for the translator to translate "active" if he does not know
"what" is "active").

It is important to use unicode strings with contextual markers because of the
following django bug:
https://code.djangoproject.com/ticket/22565
The django community was very quick and responsive and fixed the bug very fast:
https://code.djangoproject.com/changeset/142c27218a0bb07bb197faab7b1d8eb3a084f5b9
and back-ported their fix in the 1.6 and 1.7 django branches:
https://code.djangoproject.com/changeset/61fd00d4fd65f44d0a05be4c7e95124e4102ec27
https://code.djangoproject.com/changeset/034866204b39f797c73997b03cd90443aa03aa91
but since in horizon we support back to django 1.4, we will have to live with
it by providing unicode strings until we drop support of old django versions.

We can't introduce contextual markers and ungettext (pluralization) verywhere
at once because Translators would totally loose their previous work. So we have
to progressively introduce contextual markers and pluralization, when a string
is changed, or for new strings. It is also the reason why this patch changes
only the strings of the instance view actions.

Since we can't use contextual markers and pluralization for all the code at
once, this patch partially:

partial-bug: 1307476

Change-Id: I4cef42dc4a12f55cf750d9a18083254c6a96e716
2014-09-09 13:49:03 +02:00
Gary W. Smith
b4b2100729 Exclude .ropeproject from flake8 checks
Change-Id: I4e0bc52de3b251a62f24e89df2db598fbc7e7016
Closes-Bug: #1297016
2014-08-22 11:23:17 -07:00
Akihiro Motoki
f00f10428d Remove "builtins = _" from tox.ini
In Horizon "_" (ugettext_lazy) is defined by usual imports,
so "builtins = _" in tox.ini is unnecessary.

Change-Id: I2d429f5a4783f8da44739da7fe3ba1d6c76f4146
2014-08-17 18:04:53 +00:00
Julie Pichon
5cc882ea4c Run the integration tests headlessly
This will make it easier to run them on the gate.

Change-Id: I0cd4d440687c63220ea3f794756adb441a10fa8d
Closes-Bug: #1355186
2014-08-11 14:50:07 +01:00
Jenkins
f24d6decba Merge "Replace force_unicode with force_text" 2014-08-08 00:18:38 +00:00
Jenkins
9ac012e491 Merge "Set python hash seed to 0 in tox.ini" 2014-08-07 10:08:36 +00:00
Felipe Reyes
af49cf1f15 Replace force_unicode with force_text
Django changed the name to force_unicode and it's only available in
python2 as an alias of force_text. The new name is available since
Django 1.4.2

Closes-Bug: #1345642
Change-Id: Ida8c545ceec7c31999f2497d540a0dc5a653d286
2014-08-06 14:34:53 +02:00
Christian Berendt
b30072e47e Set python hash seed to 0 in tox.ini
New tox (>=1.7.0) sets a random python hash seed by default. This is
generally good for testing because it will help keep projects working
regardless of the hash seed, but nova unittests don't currently pass
with a random hash seed so set it to the python default seed.

This change will allow us to use new tox again and remove the
restriction on tox<=1.6.1 to run unittests.

Also see Ib54364877a251db48c54dfdc43c503281ea1f04a.

Change-Id: I8834487e8c7bcdbeae8397c1a10a18873976ce61
Partial-Bug: #1348818
2014-08-04 12:35:44 +00:00
Akihiro Motoki
5319c21e0e Fix and enable H701 check "Empty localization string"
Change-Id: Iae800f38cadb3d4f68ac4b70dd2d758d39a7f359
Closes-Bug: #1351196
2014-08-02 12:43:39 +09:00
Akihiro Motoki
588d1de8fa Fix and enable H702 _() method check
Enable hacking rule H702 Formatting operation should
be outside of localization method call.
This rule is useful to avoid untranslated strings.

Change-Id: I1c32707ed418c1e64cce24b0adceee14af16200c
2014-08-02 12:43:27 +09:00
Akihiro Motoki
cd35fff1b6 Re-enable flake8 check
This is the final fix to re-enable flake8/pep8 check in the gate.
E265 errors in doc/source/conf.py are also fixed.

Imports with "from xxxx import (xxxx)" style cannot pass "tox -e pep8"
though they pass "run_tests.sh -p". Newlines with backslash escape
is used in this commit to pass it.
The reason needs to be investigated later.

Change-Id: Ic0d765d404212d13f678b2a3aef7b9612bf5238d
Closes-Bug: #1347472
2014-07-31 04:16:36 +09:00
James E. Blair
5b302877fc Remove requirements style check
This is incorrect and should never have been added.  The order of
lines in requirements files affects the pip dependency resolver.
Therefore, while it's nice to add new packages in alphabetical
order, it must not be required.

Move pbr to the top of the list as it should always be installed
first.  Move hacking to the top of the test-requires list.

Change-Id: I81f7e75b77baccd12d9660dc009f30f2f2c891bc
2014-07-08 09:50:14 -07:00
Peter Belanyi
0a83ae972e Add jshint for javascript linting
Added nodeenv as a test requirement.

Added a jshint environment to tox.ini, which installs node.js into the
python virtual environment with nodeenv, installs jshint using npm,
and calls runtest.sh to run the tests.

runtest.sh now supports the -j|--jshint flags to run jshint on the
javascript files. jshint must be installed before running runtest.sh

The documentation also got updated to include some info about jshint.

This patch does not add jshint to the OpenStack codebase, just provides
a way to install it for testing, to avoid license clash (jshint has a
slightly modified MIT license, which is incompatible with OpenStack's
Apache license).

Change-Id: I9dd0743eaee50fdba3dbb527c29f2501bdd44ca6
Implements: blueprint node-toolchain
Implements: blueprint jshint-codestyle
2014-06-26 14:00:45 +02:00
Gary W. Smith
1f38f87138 Fix keystone warnings while building docs
When building the documentation via run_tests.sh, doc/source/conf.py
explicitly sets the DJANGO_SETTINGS_MODULE environment variable,
overriding any existing value that it already has. Furthermore, it sets
it to point to a settings file that does not use keystone v3, which
is expected by the tests (and is the source of the warning).  Note that
when running unit tests via run_tests.sh, a different settings file is
supplied which DOES use keystone v3.

Change the doc/source/conf.py to only set DJANGO_SETTINGS_MODULE if it
is not already set.  Change tox.ini and run_tests.sh to set
DJANGO_SETTINGS_MODULE to the same settings file used by the unit tests,
with keystone v3 support.

Change-Id: Ib297e4188f2426cf575300998bc9d50f36e48f4f
Closes-Bug: #1257725
2014-06-16 15:42:18 -07:00
Christian Berendt
50b85250c8 Use six.add_metaclass instead of __metaclass__
According to http://docs.openstack.org/developer/hacking/ it should
be preferred to use six.add_metaclass instead of __metaclass__.

Change-Id: Iec6550421bcf54f30952d9dc9f3a398288d6a283
2014-06-03 08:11:49 +02:00
Rob Raymond
b3aec6b1d3 Allow extensions to add Angular modules
This change allows extension plugins to make use of AngularJS without
changing horizon template or javascript files.
Horizon bootstraps AngularJS once when a page loads with a list
of modules. An extension can register a list of modules and a list
of javascript files that contain these modules.

Implements blueprint: plugins-angular
Change-Id: I4a76363dd4a631cc0d2fc2c902c2f5cac0f073f2
2014-05-28 15:58:39 -06:00
Jenkins
0d94a5013b Merge "Use the latest Django 1.4 release to test Horizon" 2014-04-18 23:29:56 +00:00
Jenkins
3722a614a9 Merge "Add tox env to build docs" 2014-04-18 21:27:50 +00:00
Ivan Kolodyazhny
5b9d6ee160 Use the latest Django 1.4 release to test Horizon
Change-Id: Ia991731e999ebcda91cf0439f58bb8263737197a
Closes: bug #1308123
2014-04-18 16:05:07 +03:00
Maxime Vidori
721133b3b7 Fix tox does not pass arguments to nose
When testing with tox we currently cannot test a specific file, it
is due to the fact that tox does not pass the arguments to nose.

By adding {posargs} at the end of the tox target which are using
nose, we can now use all of its features

Change-Id: If59830669fabb704cb9b6348819c6cec4060088a
Closes-Bug: #1306016
Co-Authored-By: florent <florent.flament-ext@cloudwatt.com>
2014-04-10 17:39:21 +02:00
Akihiro Motoki
c4146c4016 Add tox env to build docs
In django-based projects, we need to specify DJANGO_SETTINGS_MODULE
when running docs build. It is required to addresses the warnings of
docs build job in the gate.

This commit also changes run_tests.sh --docs to use "python setup.py
build_sphinx" to match tox docs env. This change addresses all sphinx
build warning except keystone v3 related following warning.
I believe it is useful.
  NoReverseMatch: u'domains' is not a registered namespace
  inside 'horizon:admin'

Closes-Bug: #1302532
Related-Bug: #1257725

Change-Id: I3663b81b58be3c6cb05e4af914f768c28b21ea07
2014-04-05 03:13:27 +09:00
ChenZheng
20c63e7e30 Use built-in print() instead of print statement
In python 3 print statement is not supported, so we should use
only print() functions.

Fixes bug 1226943

Change-Id: I721e67c917ba7018401ad40ef30081883dcec420
2014-03-24 16:28:55 +08:00
David Lyle
09de7e80f6 Adding django 1.6 support
Adding tox config to maintain django 1.5 support.

Implements: blueprint django-1point6
Change-Id: Id51b61f8ec8f5a1f83b4d3520dfa4273f07db4cb
2014-03-10 23:09:58 -06:00
ChenZheng
4d6238ceb4 Sort requirement files in alphabetical order
This makes code more readable, and can check whether specific library
in the requirement files easily. We enforce the check in pep8, We also
add the tools for checking requirements.txt and test_requirements.txt.

Change-Id: Ia0a24553b7a5204faf6413c17dae6ba6aae2b5e8
Closes-Bug: #1285478
2014-03-03 10:00:37 +08:00
Jenkins
24ff867af3 Merge "Integration tests - running the tests" 2014-03-01 06:52:00 +00:00
Julie Pichon
b4b0e1a887 Integration tests - running the tests
Initial setup for running the integration tests. A basic test is
included to ensure this works, although it will be rewritten to follow
the Page Object pattern. Thanks to Daniel Korn for the initial test.

https://wiki.openstack.org/wiki/Horizon/Testing/UI

Implements blueprint: selenium-integration-testing

Change-Id: Id5b62cdeac5295667a3922f7bed1db3c7617f841
2014-02-26 10:45:21 +00:00
Jason E. Rist
0dbb5be8a5 Exclude local directory from flake8 tests.
Closes-Bug: 1281346

Change-Id: I099c3448b16aa7e9066c996fcf3d7520a6b14639
2014-02-17 16:57:07 -07:00
Tatiana Mazur
193f624e1b Remove leftovers of "# noqa"
This patch set removes leftovers of "# noqa" from imports
added to import_exceptions.

It also adds "django.test.utils.override_settings" to
import_exceptions, so a few more "# noqa" tags become
unnecessary.

Closes-Bug: #1273647

Change-Id: I39f856ac3ea371a2fcab272bbf358d0243164b6d
2014-01-28 15:51:04 +04:00
Jenkins
8e6c877c5c Merge "Whitelist external netaddr requirement" 2014-01-10 02:07:25 +00:00
Radomir Dopieralski
028332da4a Remove #noqa from most common imports and add them to import_exceptions
We have a lot of import with #noqa that is there to ignore h302,
because it's traditional to import and use a name directly, instead
of a whole module. This hides other errors and gives people the
impression that it's actually fine to import non-modules, you just
have to slap #noqa on those lines.

I went through the code and identified about a dozen names that are
most commonly imported this way. I remove the #noqa tag from them,
and added them to the list in import_exceptions.

I also removed a few unused imports that were revealed in the process.

Change-Id: I27afb8e2b1d4759ec974ded9464d8f010312ee78
2014-01-07 12:26:35 +01:00
Zhenguo Niu
459a000390 Whitelist external netaddr requirement
* tox.ini(testenv.install_command): Use the --allow-external and
--allow-insecure options so that pip 1.5 and later will assent to
retrieve the netaddr package even though it's not hosted on PyPI.
The --allow-insecure option is aliased to a clearer
--allow-unverified wording in 1.5, but the old form is being used to
avoid breaking users of 1.4.x and will be valid at least through
1.6.x according to comments in the pip source.

Change-Id: I291684fa65279f0cb86f84e0d8e69bfa4b4087c0
Partial-Bug: #1266513
2014-01-07 13:26:18 +08:00
Sushil Kumar
700ba9a7c2 Updates tox.ini to use new features
Reasons:
 - tox update v1.6

Changes:
 - tox 1.6 allows us to skip the sdist step, which is slow.
 - It also allows us to override the install line. In this case, it's
   important as it allows us to stop getting pre-release software we
   weren't asking for.

Original patch by Monty Taylor, talked about here:
http://lists.openstack.org/pipermail/openstack-dev/2013-September/015495.html

Change-Id: I0b2da3369ec303b9997305f602e6c444cafe14b0
2013-12-12 17:06:31 +00:00
Paul Belanger
da8c69afa6 Gate on H4xx docstrings for pep8
In an effort to help horizon more friendly to OpenStack hacking
guidelines, we now gate on H40* violations.

Change-Id: Id07294543660368d2f7f5ac363710176ab23b874
Signed-off-by: Paul Belanger <paul.belanger@polybeacon.com>
2013-11-23 12:51:07 -05:00
Paul Belanger
74117eb8b6 Gate on H102 Apache 2.0 license header not found for pep8
Now all files are properly licensed per OpenStack Hacking.

Change-Id: I223d983018568357197b0d9cf5dde12c135c53c9
Signed-off-by: Paul Belanger <paul.belanger@polybeacon.com>
2013-11-19 13:55:04 -05:00
Jenkins
a1dba8a4cb Merge "Run flake8 tests automatically on ./run_tests.sh" 2013-10-14 10:06:41 +00:00
Kieran Spear
3dbb31b81a Run flake8 tests automatically on ./run_tests.sh
And add a -P option to disable it.

Change-Id: Ie0039217c82acbd9c9071da27027f57263b39f25
Closes-bug: #1237202
2013-10-10 13:59:45 +11:00
Kieran Spear
23ca27afbe Disable H803 check.
H803: Git commit title should not end with period.

I don't think we really care whether a commit title ends with a period
or not. Certainly not enough to warrant patches failing checks and
wasting people's time and CI resources.

Change-Id: I52fd73c35545943b1a7e2cec62ddb52a5f90a24b
Closes-bug: 1236621.
2013-10-08 13:19:36 +11:00
simon
afaa72185c PEP8 E126 has been resolved
Change-Id: Ic5d3b96b6061b7a34e7620d8d09418bd6976fbb1
Partial-Bug: #1085346
2013-09-17 20:48:09 +09:00
Kun Huang
d455336685 Enable F403 and F999 check
* F403 has already been fix in https://review.openstack.org/#/c/38435/.
* This patch fixes the remaining F999 issue.

Change-Id: Id484a577973bb56168b6d85a5fc909a471e1128c
2013-09-07 23:10:57 +08:00
simon
ec727ac394 PEP8 E121 has been resolved
Change-Id: I6ad2704100447c5a3be12c2ebeec824726e3bd0b
Partial-Bug: #1085346
2013-09-05 14:38:58 +08:00
Tatiana Mazur
953d1b9793 Enable H302 check
This patch replaces some method imports with module imports and
makes H302 test enabled.

Fixes bug 1188531

Change-Id: Ibfbddeaa19cbbb244da58ffd5c918c41f03a0c65
2013-08-22 17:39:09 +04:00
Kieran Spear
242c8df495 Enable H201: do not write "except:"
Fixes all occurrences of this. We have a custom exception handler
in Horizon anyway that only catches ClientException in most of these
cases, but this commit lets us gate on the other cases.

Change-Id: Iea3dc13817f3e5b775b2024424bf3a906da5584b
Closes-Bug: #1211657
2013-08-13 17:21:32 +10:00
Monty Taylor
dc266f44e7 Updated from global requirements
Change-Id: Ibf423f14a5c37aa298b2115bfd4936f660c6f530
2013-08-08 13:16:35 -03:00
Kun Huang
f585152407 remove 'import *' usage (or mark is #noqa)
This is talked in bug #1188533, and in current codes, there are several
places here:

horizon/forms/__init__.py:18:from django.forms import *
    mark '# noqa'

openstack_dashboard/settings.py:182:    from local.local_settings import *
openstack_dashboard/test/settings.py:5:from horizon.test.settings import *
    mark '# noqa'

openstack_dashboard/dashboards/project/instances/workflows/__init__.py:1:from create_instance import *
openstack_dashboard/dashboards/project/instances/workflows/__init__.py:2:from update_instance import *
openstack_dashboard/dashboards/project/instances/workflows/__init__.py:3:from resize_instance import *
    fix it

openstack_dashboard/dashboards/project/images_and_snapshots/urls.py:21:from django.conf.urls.defaults import *
    fix it

fixes bug # 1188533
Change-Id: Id671280903f8452a78f81f1240d92297de7a89a8
2013-07-30 11:45:39 +08:00
Alex Gaynor
f194236a73 Removed a comment from tox.ini that no longer applied.
This refered to a flake8 rule that's no longer in
use.

Change-Id: Ibeb038c713ae7f91c8e6ca897fe24911da6bd465
2013-07-22 23:39:42 -07:00
Alex Gaynor
56ae8fdfc5 Enable pep8 F841 checking.
This check looks to see whether a local variable
is unused. Also fixed all violators of said check.

Change-Id: I7c186df41b5601078ffc54588aace8136c6576bd
2013-07-22 01:09:52 -07:00
Tatiana Mazur
3087c3486b Enable H304 check
This patch replaces relative imports with full paths and
makes H304 test enabled.

Fixes bug 1188535

Change-Id: I47254cf9a790727102f7993d0fd107da514983df
2013-07-16 18:49:56 +04:00
Sergey Lukjanov
59ef565871 Enable H306 check
H306  imports not in alphabetical order

Change-Id: Ief2accac748248ebf46d4e49230662ff9b233053
2013-07-02 11:38:27 +04:00
Jenkins
f356811ddd Merge "python3: Introduce py33 to tox.ini" 2013-06-26 09:37:39 +00:00