Commit Graph

12 Commits

Author SHA1 Message Date
Akihiro Motoki e5d09edc20 Use python3-style super()
In python3, super() does not always require a class and self reference.
In other words, super() is enough for most cases.
This is much simpler and it is time to switch it to the newer style.

pylint provides a check for this.
Let's enable 'super-with-arguments' check.

NOTE: _prepare_mappings() method of FormRegion in
openstack_dashboard/test/integration_tests/regions/forms.py is refactored.
super() (without explicit class and self referece) does not work when
a subclass method calls a same method in a parent class multiple times.
It looks better to prepare a separate method to provide a common logic.

Change-Id: Id9512a14be9f20dbd5ebd63d446570c7b7c825ff
2020-10-15 14:37:20 +09:00
Akihiro Motoki 6ba506e281 test: use safer way to override settings
Django provides safer ways to override settings.
We should avoid direct replacement of existing setting.

Change-Id: I1fbcb79d18baaae037536b180989cf69c198fa7d
2020-09-13 09:47:50 +09:00
Hervé Beraud 17d8ab6103 Stop to use the __future__ module.
The __future__ module [1] was used in this context to ensure compatibility
between python 2 and python 3.

We previously dropped the support of python 2.7 [2] and now we only support
python 3 so we don't need to continue to use this module and the imports
listed below.

Imports commonly used and their related PEPs:
- `division` is related to PEP 238 [3]
- `print_function` is related to PEP 3105 [4]
- `unicode_literals` is related to PEP 3112 [5]
- `with_statement` is related to PEP 343 [6]
- `absolute_import` is related to PEP 328 [7]

[1] https://docs.python.org/3/library/__future__.html
[2] https://governance.openstack.org/tc/goals/selected/ussuri/drop-py27.html
[3] https://www.python.org/dev/peps/pep-0238
[4] https://www.python.org/dev/peps/pep-3105
[5] https://www.python.org/dev/peps/pep-3112
[6] https://www.python.org/dev/peps/pep-0343
[7] https://www.python.org/dev/peps/pep-0328

Change-Id: Ic03754dcaaa4f1c0018294aa52bb05d956aa5d10
2020-06-03 10:45:18 +02:00
白子玉 3f7fc68085 Changed default identity url to horizon
The keystone doesn't use 5000 port anymore from Newton version. And all
 the references should be changed together.

Change-Id: I3f02686ab5b3abf48f129fde92e90427ca148317
2019-12-06 18:41:38 +08:00
Ivan Kolodyazhny f33e5fd8ac Drop deprecated Keystone V2 API support
Keystone V2 API was deprecated in Stein release in Horizon and
removed from Keystone in Queens release.

Change-Id: I917e273d3174adf0874e516b3d635ccb8ba58a27
2019-09-12 17:15:07 +00:00
Akihiro Motoki 5fd5b4c893 Fix version handling compatible with python-semanticversion 2.8
It seems the behavior of 'partial' argument of Version class __init__
has been changed between semantic-version 2.6.0 and 2.8.1
(though I could not identify the root cause).
'partial' argument is marked as deprecated in semantic-vesion 2.7.0,
so it is a good chance not to depend on 'partial' argument in horizon.

This commit uses Version.coerce() [1] instead to convert non-semver
version into a valid semver version.
We also need to keep the original version information as it is passed
when initializing python-*client (cinderclient and keystoneclient).

In addition, the previous implementation based on semantic-version 2.6.0
returns True for "Version("3.55") == 3". It depends on the behavior
of "partial" argument of semantic_version.Version. It was not
documented and it looks tricky to depend on this behavior.
"major" and "minor" properties are now introduced and api/cinder.py
is updated accordingly. I believe this approach is clearer and stable.

Unit test coverage on dict behavior is improved.
Variable names in the unit tests are adjusted to more meaningful ones.

[1] https://python-semanticversion.readthedocs.io/en/latest/#coercing-an-arbitrary-version-string

Change-Id: If0deee9d0289ff91d58d942b9612f7736356ae18
2019-09-09 15:54:26 +09:00
Akihiro Motoki 4bf069bb92 Ensure to call patch_middleware_get_user() in api.test_base
ApiHelperTests.test_url_for in openstack_dashboard.test.unit.api.test_base
depends on keystone user and token information. To make this work,
we need to call utils.patch_middleware_get_user().
This commit changes ApiHelperTests to inherit APITestCase.

Change-Id: I3848f756604262b07700a65e9be5bacd48da191f
Closes-Bug: #1815285
2019-02-09 21:12:50 +09:00
Akihiro Motoki c6611abe16 Update keystone v3 admin URL in UT
We no longer use port 35357 for keystone v3 API admin operation
and it is recommended to use port 5000.
This commit updates keystone catalog for keystone v3 API.
It also replace keystone v2 URL with v3 one.
Note that keystone v2 data is kept as-is.

Change-Id: Ia152d602b80ae418e0020b3ba30a11016a83da6a
2018-08-14 02:50:47 +09:00
Akihiro Motoki 58019a7411 Disable mox usage by default in test helper
- Add use_mox = True to tests which still depend on mox
- Remove use_mox = False from all tests converted into mock
- Update the warning messages
- Replace 'S'-release with 'Stein'

Part of blueprint mock-framework-in-unit-tests
Change-Id: I208185e97b2de346304a09643a9cb3f1425a7683
Signed-off-by: Akihiro Motoki <amotoki@gmail.com>
2018-04-20 03:34:51 +00:00
Akihiro Motoki d3883a147b Mark other API related tests with mox free
Change-Id: I991100bce99815bbd5af078e53b966c5cfc92233
Partially-Implements: blueprint mock-framework-in-unit-tests
2018-02-17 04:32:33 +09:00
Ivan Kolodyazhny a774fa30dd Use Cinder API v3 by default
Cinder API v3 was introduced several releases ago and is backward
compatible with API v2 so it's safe to swith to use it.

Change-Id: I550e6c59bb14c17da78d7b2abcde5783b2b6825d
Closes-Bug: #1728761
2017-12-18 15:34:41 +02:00
Akihiro Motoki f3af02f20f openstack_dashboard: Move test files to match module structure
This commit relocates test codes in openstack_dashboard
according to blueprint relocation-test-codes.

Change-Id: I397a5a47fe9c1bf3a498c22056d924bf409c514b
2017-12-09 21:38:06 +09:00