Commit Graph

9 Commits

Author SHA1 Message Date
Akihiro Motoki 7052b7f065 Address RemovedInDjango40Warning (7)
HttpRequest.is_ajax() was marked as deprecated since Django 3.1 and will be
removed in Django 4.0 [1].

While the current implementation of is_ajax() relies on a jQuery-specific way
of signifying AJAX as noted in the Django relnotes, horizon works with this.
Thus this commit copies the existing logic of HttpRequest.is_ajax() to the
horizon repo (as horizon.utils.http.is_ajax()) and consumes it.

https: //docs.djangoproject.com/en/4.0/releases/3.1/#features-deprecated-in-3-1
Change-Id: I3def53033524985818a891a1b9d4659fad4ba2ba
2022-02-04 16:27:32 +09:00
Ivan Kolodyazhny 14e779bbac Use unittest.mock instead of third party mock
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.

Change-Id: I2de669d8e89b8daeb7ee5405ffab35af6307c40b
2020-03-26 19:45:37 +02:00
Akihiro Motoki d16ed45e06 Support "Get me a network" in launch instance
"Get-me-a-network" feature is supported in Nova API 2.37 or later.
To support this in horizon, a dummy "auto_allocated_network" is shown
in the launch instance form. I believe this approach fits the current
way of the launch instance form. The dummy network is a special network ID
and if specified the nova API wrapper converts 'nics' parameter properly.

In addition, a dummy "auto_allocated_network" is now shown in the network
table. This is because Neutron creates an actual auto allocated network
once a server is created specifying nics=="auto".
I believe this fake behavior brings consistency in the network table
to some extent, while this is just a compromise.

Note that this patch does not cover the network topology integration.
"auto_allocated_network" is not shown until the actual auto allocated
network is created. The network topology integration requires more work.
For example, the link for the fake auto allocated network should be
disabled in the flat view. The pop-up for the fake auto allocated network
should be disabled in the graph view.

Change-Id: I062fc1b7ed75dc771ddc7f13c8324ed4ffab6808
Closes-Bug: #1690433
2018-05-07 20:49:29 +09:00
Zuul 3e0da5b91c Merge "Fix W503 warnings" 2018-04-24 09:48:08 +00: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 11eb4e9d3e Fix W503 warnings
W503 line break before binary operator

Looking at the code base, it sounds okay to follow this check.

Change-Id: Id511e0104dc6de5b204021661d4a8776ca6d3658
2018-04-11 18:13:47 +09:00
Akihiro Motoki 68167ca3b5 Improve mocking in REST API tests (test_neutron)
The current REST API tests have a lot of rooms to be improved like:
- mocking the whole module of the API wrapper
- Unnecessary usage of test.mock_factory()
- Unnecesary setUp()
- Test data should not be accessed directly via TestData

This commit improves test/unit/api/rest/test_neutron.py.

Change-Id: I8634b0f72fe089e0da4cda8a0ba5af56ffb856c6
Partial-Bug: #1752917
2018-03-28 18:39:52 +00:00
Akihiro Motoki c5cd0b2048 Switch Neutron/Network API tests to mock
This patch changes mox to mock for the following test modules:
* openstack_dashboard/test/unit/api/test_network.py
* openstack_dashboard/test/unit/api/test_neutron.py
* openstack_dashboard/test/unit/api/rest/test_network.py
* openstack_dashboard/test/unit/api/rest/test_neutron.py

Partially-Implements: blueprint mock-framework-in-unit-tests

Change-Id: Ib97fb1c06a883fb9fd5ce39b8fe2362a88135692
2018-03-28 18:39:14 +00: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