Collections Abstract Base Classes have been moved to the
collections.abc module, which was part of the collections
module before[1] [2]. Usage from the collections module
directly is deprecated and will be removed from 3.10.
This commit updates to import abc module explicitly
wherever required as the same will no longer be visible/directly
used from the collections module.
[1] https://docs.python.org/3/library/collections.abc.html
[2] http://paste.openstack.org/show/802512/
Change-Id: I173f4d647474c21c5d062280bd5703edffb4978e
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
Switching the test runner to pytest in horizon assumes pytest is always
installed, but horizon test helpers are used in horizon plugin tests and
pytest is not used in horizon plugin tests. As a result, all horizon plugin
tests are now broken.
This commit considers a case where pytest does not exist.
A wrapper decorator for pytest.mark.xxxx is introduced and
it acts as a null decorator if pytest is not installed.
Change-Id: I80736b108f5ae9a36c0e756bf386468879be3293
Closes-Bug: #1873532
Changes test invocation from `manage.py test` to `pytest`. Adds addtitional
test requirements like pytest, pytest-django, pytest-html. Adds
`pytest.mark` alongside django's test `tag`. Adds posibility to export test
results into xml and html formats.
Depends-On: https://review.opendev.org/#/c/712315/
Related-Bug: #1866666
Co-Authored-By: Ivan Kolodyazhny <e0ne@e0ne.info>
Change-Id: Idb6e63cd23ca2ba8ca56f36eb8b63069bd211944
We have several codes to handle the differences between py2 and py3.
py2 support has been dropped so there is no need for them now.
Change-Id: I30080f4e1a5ac04860c4341d966ee53131eb2022
We don't support Python 2 anymore so we don't need this
compatibility library.
six.reraise usages are left as is until it'll be moved to some
base lib like oslo.utils to not re-implenent this method in
Horizon.
This patch also removes Python2-specific base test case methods
assertItemsEqual and assertNotRegexpMatches in flavor of new
Python 3 analogues.
Change-Id: I0b567382edf4d68674a7b8d0b02333fb57293958
Resolves the following warning:
DeprecationWarning: Using or importing the ABCs from 'collections'
instead of from 'collections.abc' is deprecated, and in 3.8 it will
stop working
Change-Id: Ib2214e7560cda1ef510c08859d5ee0726eb66b7b
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
In Django 1.10 the new middleware interface was introduced [1].
process_request and process_response are no longer part of the interface.
On the other hand, process_exception is the part of the interface.
To clarify that we are using the new middleware interface,
it looks better to rename the methods in the old interface to private.
[1] https://docs.djangoproject.com/en/2.0/topics/http/middleware/
Change-Id: I0bb39321f3659458a86beb2b258e9e903392620a
We announced in the Rocky cycle that use_mox will be dropped
in the beginning of Stein cycle. This commit drops use_mox and
cleans up mox related stuffs in horizon and openstack_dashboard codes.
Note that openstack_auth is under the mock migration,
so we cannot mox3 from test-requirements.txt.
blueprint mock-framework-in-unit-tests
Change-Id: I189daf2d678bef0fa8219acaab5cf45bbe54178f
Nose has been in maintenance mode for the past several years. It has
issue with exit code [1] which leads to false positive results for our
seleniun-headless job.
This patch changes test runner for Horizon tests and does the following
things:
* Django test runner executes test in a different order than Nose does.
That's why we've got an issue with side-effect in
horizon.tests.unit.tables.test_tables.MyToggleAction class. This patch
adds workaround to it.
* Rename filename of test files to names starting with 'test_'
so that the django test runner can find tests expectedly.
* '--with-html-output' option is temporary dropped and will be added in
a following patch.
* Integraion tests is marked via django.test.tag mechanism which is
introduced in Django 1.10
* 'selenium-headless' is broken now because we don't have geckodriver on
gates, this patch makes it non-voting.
* 'tox -e cover' is fixed
* Remove @memorized decorator from
dashboards.project.images.images.tables.filter_tenant_ids function.
[1] https://github.com/nose-devs/nose/issues/984
Depends-On: https://review.openstack.org/572095
Depends-On: https://review.openstack.org/572124
Depends-On: https://review.openstack.org/572390
Depends-On: https://review.openstack.org/572391
Related blueprint: improve-horizon-testing
Change-Id: I7fb2fd7dd40f301ea822154b9809a9a07610c507
- 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>
This completes mock migration in horizon UT.
IsA and IsHttpRequest are moved to horizon.test.helpers
as they are genric enough and IsA is needed in a horizon UT.
Part of blueprint mock-framework-in-unit-tests
Change-Id: I702551fe900224c9ebbbf3ef815206be035b6d14
This commit enhances django tab implementation to allow horizon plugins
to add tabs to a tab group in other repository like the main horizon repo.
New setting "EXTRA_TABS" is introduced to the horizon plugin 'enabled' file.
To this aim, the tab group class looks up HORIZON_CONFIG['extra_tabs']
with its class full name and loads them as extra tabs if any.
HORIZON_CONFIG['extra_tabs'] are populated via horizon plugin settings.
This commit moves update_settings in openstack_dashboard.test.helpers
to horizon as I would like to use it in a new horizon unit test.
blueprint horizon-plugin-tab-for-info-and-quotas
Closes-Bug: #1746754
Change-Id: Ice2469a90553754929826d14d20b4719bd1f62d3
horizon test helpers now depend on mox3.
This prevents horizon plugins from consuming the test helpers
even if a plugin itself is mox free.
This commit makes mox import optional.
Change-Id: I631518d8f4cd9641920f68cd1e405298ddb7965a
Closes-Bug: #1753555
This commit introduces 'use_mox' attribute to TestCase class.
If this is set to False, TestCase does not setup mox.
In addition, a common method to emit the deprecation warning
was introduced in APITestCase.
Part of blueprint mock-framework-in-unit-tests
Change-Id: I1e3df7ea2a867b8a7aa69523bed2beaab9663dc0
Mostly the issue with Horizon was we were using some
undocumented widgets that were cut for version 1.11
django. This patch adds their code into our repo for
now, but we need to do a proper rewrite of our widgets
for Queens to use current widgets in Django.
Also edits some tests because the functionality changed
in Django 1.11
Implements: blueprint dj111
Co-Authored-By: Rob Cresswell <robert.cresswell@outlook.com>
Change-Id: I444d45f274662f4f33701c16cce4ae80cb546654
attribute-level imports are not checked by hacking module now.
most noqa is used to disable warnings on attribute-level imports.
This commit drops noqa for this purpose.
After this, there are 8 noqa under horizon/ :)
In addition to this, the following changes are made.
horizon/exceptions.py: The following imports are dropped.
They are not used anywhere.
from django.http import HttpRequest
from django.views.debug import CLEANSED_SUBSTITUTE
horizon/forms/__init__.py:
Some entries were missing in __all__. They are added.
Change-Id: I33b504ef6c396f0675e8a340867e2ca59c77c684
Horizon currently has two webdrivers for selenium-based
testing; this patch merges them into one so all tests
(selenium functional tests and integration tests) benefit
from improvements we make to the webdriver.
Change-Id: Iac471c2c7e40c799711746ef9e3e4ef87aecf098
These lines of code were introduced as Horizon migrated
through several Django versions and are no longer
needed.
Change-Id: I12aae1a843fccc803859da6337a3274339a3741f
Partially-Implements: blueprint drop-dj17
The Python 2 assertItemsEqual() method was renamed to
assertCountEqual() in Python 3, and assertNotRegexpMatches() was
renamed to assertNotRegex(). Add aliases in
horizon.test.helpers.TestCase.
tox.ini: add horizon.test.tests.messages to Python 3.4.
Partial-Implements: blueprint porting-python3
Change-Id: If7abd51fd3559a5ab32d433c6dc3476bd678b2bf
Prior to Django 1.7, assertContains and assertNotContains test helper
methods behaved differently regarding the 'streaming' flag of a
response. This patch fixes the override I made earlier by calling it
conditionally only for the Django version prior to 1.7. This should
prevent problems with response._charset attribute that no longer works
in Django 1.8
Partially Implements: blueprint django18
Change-Id: I10cbc016e51b1ec7b959623989e8c4aec5899cbf
mox doesn't work on Python 3, whereas mox3 works on Python 2 and Python
3. Cinder, Nova and many other projects already replaced mox with mox3.
mox3 is now maintained by OpenStack.
Partial-Implements: blueprint porting-python3
Change-Id: I10e6a9754ebd58a2640d73ec8966527c3aa1fe9a
Django changed the functionality of django.test.LiveServerTestCase
in 1.7 The old functionality is now supported by
django.contrib.testing.StaticLiveServerTestCase
This adds a version check to do a conditional import to pull in
either the old test case class or the new.
For more information see:
https://docs.djangoproject.com/en/1.7/ref/contrib/staticfiles/#specialized-test-case-to-support-live-testing
Closes-Bug: #1439169
Change-Id: I182847a8e77de0b9c279eeb305b536d8cdf6c43b
To prevent memory overrun when downloading large objects from Swift
* `resp_chunk_size` keyword should be passed to swiftclient
* `obj.data` iterator returned from swiftclient is passed to HttpResponse
(or StreamingHttpResponse for Django>=1.5) as usual since both response
classes work with iterators/files/byte strings (yet StreamingHttpResponse
does it better).
The commit introduces new setting SWIFT_FILE_TRANSFER_CHUNK_SIZE that
defines the size of chunk in bytes for Swift objects downloading.
DocImpact
Change-Id: I18e5809b86bfa24948dc642da2a55dffaa1a4ce1
Closes-Bug: #1427819
There was a selector bug that caused the Jasmine helper to not find
failures in Jasmine tests. The selectors are now fixed.
Change-Id: I2f66f4b04cd6e9fc1f7259bdac351ac0fe87e23c
Closes-Bug: 1421788
The helpers.TestCase classes didn't call their superclass' methods
in their setUp and tearDown methods, which made it impossible to
probperly inherit from them and use mixins with them.
I split the code that was differing for them into separate methods,
removed common code and made them use super() correctly.
Due to some inspect magic, the factory creation has to be duplicated.
Change-Id: I0bf909b1e4324c1e36bcdb83daece391bd0cfae7
According to the Jinja2 documentation the preferred usage for
the syntax of the {{ ... }} delimter is {{ ... }}. This patch
changes all occurcens of {{... and ...}} to {{ ... }}.
Change-Id: I755475d1476cbfeac190217fa67dc2640917762c
If both the keystone token and the session expired, the user was asked to login
twice. This is because the token expiration was not checked.
When a user had timed out both in session and keystone token validity, the user
was asked to log in, then the timestamp was checked, and the user logged out
again and asked to log in a second time.
We now check both the timestamp and keystone token validity before
authentication validity and force back the login page to retrieve a new
keystone token, avoiding the timeout race condition between session and token
validity which was forcing a dual login. A keystone token expiration is now
considered as a session timeout too.
Also, a page can start loading while the token is valid, and finish while it's
invalid. This was leading to errors during the page loading.
We now set a TOKEN_TIMEOUT_MARGIN period in seconds which allows defining
a margin before which we consider the token as expired.
This is a configurable parameter in the django settings because the time a page
takes to render is infra and deployment specific. This margin is preset to
ten seconds.
Requires: https://review.openstack.org/101556
Closes-Bug: 1308918
Change-Id: I0bf0d079a9dc000c1a30f0e20dcaa03b22d63e51
Various checkbox elements listeners that were set only for
horizon.tables should also be set for tabs which are lazy-loaded
(namely, are defined with `preload = False`) - so, they were moved to
a separate function and reused. Provide tests for the fixed js
regression using SeleniumTestCase with authorization backend being
stubbed out. This allows to use lazy tabs defined in django code
instead of writing html fixtures (as done for QUnit tests).
Change-Id: I39954ddb439f97238511f6eee5f992213690846f
Closes-Bug: #1191006
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
Warnings H904, H307 and H405 are new or considerably changed, and will
be fixed in a separate patch.
Partial-bug: #1347472
Change-Id: Id9325a40d443f77242d3634002789501afbfc35a
Co-Authored-By: Juan M. Olle <juan.m.olle@intel.com>
- Add requirement for xfvbwrapper
- Add CLI option for running tests headless
- Update Selenium TestCase to start virtual display if the option is set
- Update documentation about running Selenium tests
Change-Id: Icb1ac3491b8eef6c168bf1421cf073da67600982
Closes-Bug: #1290329
The selenium tests are often hanging in the gate due to rogue
'firefox -silent' processes. Borrow a fix from SST that overrides
the default Firefox WebDriver so it doesn't spawn the processes in the
first place.
There's also a ~10% timeout failure in the qunit/jasmine tests.
Make sure the default socket timeout is set early enough so
the initial selenium/testserver setup doesn't occasionally fail on the
first test of a test case. This gets it down to around 5% failure rate.
Also wrap each test case in a sleep() sandwich to give services time to
settle before the tests start. This isn't ideal as it makes the tests
take longer, but with this change I finally get no false negatives at all
over 100+ runs.
Change-Id: I24963f575fd6eeb81dbff883404c7cff45e97397
Closes-bug: 1317630
Remove vim setting:
comment - # vim: tabstop=4 shiftwidth=4 softtabstop=4
at the top of source code files, except for files in
openstack/common.
Change-Id: I9a5c6b17c6ef7ecec601f4503dfc7b31fc72e90a
Close-bug: #1229324
When assertMessageCount() fails, we display the list of messages that
were included in the response. However because the messages are lazily
translated by default, this would fail and show the following error
instead:
TypeError: sequence item 0: expected string, __proxy__ found
Change-Id: I1d2ed97b66428e0ee1aac783c8370ab3ea665b29
Closes-Bug: #1315031