Remove errant references to mox
There is still a single user of mox but all other references to this can be removed. Do just that. Change-Id: I611573a41c47e99e41a54bf53cea55322a493de1 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
5129d958fd
commit
2b3ab46440
@ -315,46 +315,7 @@ Some common things to look for:
|
|||||||
the ``index`` view for a panel that got combined (such as instances &
|
the ``index`` view for a panel that got combined (such as instances &
|
||||||
volumes).
|
volumes).
|
||||||
|
|
||||||
#. Make sure your mock calls are in order before calling ``mox.ReplayAll``.
|
|
||||||
The order matters.
|
|
||||||
|
|
||||||
#. Make sure you repeat any stubbed out method calls that happen more than
|
#. Make sure you repeat any stubbed out method calls that happen more than
|
||||||
once. They don't automatically repeat, you have to explicitly define them.
|
once. They don't automatically repeat, you have to explicitly define them.
|
||||||
While this is a nuisance, it makes you acutely aware of how many API
|
While this is a nuisance, it makes you acutely aware of how many API
|
||||||
calls are involved in a particular function.
|
calls are involved in a particular function.
|
||||||
|
|
||||||
Understanding the output from ``mox``
|
|
||||||
-------------------------------------
|
|
||||||
|
|
||||||
Horizon uses ``mox`` as its mocking framework of choice, and while it
|
|
||||||
offers many nice features, its output when a test fails can be quite
|
|
||||||
mysterious.
|
|
||||||
|
|
||||||
Unexpected Method Call
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
This occurs when you stubbed out a piece of code, and it was subsequently
|
|
||||||
called in a way that you didn't specify it would be. There are two reasons
|
|
||||||
this tends to come up:
|
|
||||||
|
|
||||||
#. You defined the expected call, but a subtle difference crept in. This
|
|
||||||
may be a string versus integer difference, a string versus unicode
|
|
||||||
difference, a slightly off date/time, or passing a name instead of an id.
|
|
||||||
|
|
||||||
#. The method is actually being called *multiple times*. Since mox uses
|
|
||||||
a call stack internally, it simply pops off the expected method calls to
|
|
||||||
verify them. That means once a call is used once, it's gone. An easy way
|
|
||||||
to see if this is the case is simply to copy and paste your method call a
|
|
||||||
second time to see if the error changes. If it does, that means your method
|
|
||||||
is being called more times than you think it is.
|
|
||||||
|
|
||||||
Expected Method Never Called
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
This one is the opposite of the unexpected method call. This one means you
|
|
||||||
told mox to expect a call and it didn't happen. This is almost always the
|
|
||||||
result of an error in the conditions of the test. Using the
|
|
||||||
:meth:`~openstack_dashboard.test.helpers.TestCase.assertNoFormErrors` and
|
|
||||||
:meth:`~horizon.test.helpers.TestCase.assertMessageCount` will make it readily
|
|
||||||
apparent what the problem is in the majority of cases. If not, then use ``pdb``
|
|
||||||
and start interrupting the code flow to see where things are getting off track.
|
|
||||||
|
@ -549,10 +549,10 @@ class InstanceViewTest(test.BaseAdminViewTests):
|
|||||||
@override_settings(API_RESULT_PAGE_SIZE=1)
|
@override_settings(API_RESULT_PAGE_SIZE=1)
|
||||||
def test_severs_index_paginated(self):
|
def test_severs_index_paginated(self):
|
||||||
size = settings.API_RESULT_PAGE_SIZE
|
size = settings.API_RESULT_PAGE_SIZE
|
||||||
mox_servers = self.servers.list()
|
mock_servers = self.servers.list()
|
||||||
|
|
||||||
# get first page
|
# get first page
|
||||||
expected_servers = mox_servers[:size]
|
expected_servers = mock_servers[:size]
|
||||||
res = self._test_servers_paginate_do(
|
res = self._test_servers_paginate_do(
|
||||||
marker=None,
|
marker=None,
|
||||||
servers=expected_servers,
|
servers=expected_servers,
|
||||||
@ -562,7 +562,7 @@ class InstanceViewTest(test.BaseAdminViewTests):
|
|||||||
self.assertCountEqual(servers, expected_servers)
|
self.assertCountEqual(servers, expected_servers)
|
||||||
|
|
||||||
# get second page
|
# get second page
|
||||||
expected_servers = mox_servers[size:2 * size]
|
expected_servers = mock_servers[size:2 * size]
|
||||||
marker = expected_servers[0].id
|
marker = expected_servers[0].id
|
||||||
res = self._test_servers_paginate_do(
|
res = self._test_servers_paginate_do(
|
||||||
marker=marker,
|
marker=marker,
|
||||||
@ -573,7 +573,7 @@ class InstanceViewTest(test.BaseAdminViewTests):
|
|||||||
self.assertCountEqual(servers, expected_servers)
|
self.assertCountEqual(servers, expected_servers)
|
||||||
|
|
||||||
# get last page
|
# get last page
|
||||||
expected_servers = mox_servers[-size:]
|
expected_servers = mock_servers[-size:]
|
||||||
marker = expected_servers[0].id
|
marker = expected_servers[0].id
|
||||||
res = self._test_servers_paginate_do(
|
res = self._test_servers_paginate_do(
|
||||||
marker=marker,
|
marker=marker,
|
||||||
@ -586,11 +586,11 @@ class InstanceViewTest(test.BaseAdminViewTests):
|
|||||||
@override_settings(API_RESULT_PAGE_SIZE=1)
|
@override_settings(API_RESULT_PAGE_SIZE=1)
|
||||||
def test_servers_index_paginated_prev(self):
|
def test_servers_index_paginated_prev(self):
|
||||||
size = settings.API_RESULT_PAGE_SIZE
|
size = settings.API_RESULT_PAGE_SIZE
|
||||||
mox_servers = self.servers.list()
|
mock_servers = self.servers.list()
|
||||||
|
|
||||||
# prev from some page
|
# prev from some page
|
||||||
expected_servers = mox_servers[size:2 * size]
|
expected_servers = mock_servers[size:2 * size]
|
||||||
marker = mox_servers[0].id
|
marker = mock_servers[0].id
|
||||||
|
|
||||||
res = self._test_servers_paginate_do(
|
res = self._test_servers_paginate_do(
|
||||||
marker=marker,
|
marker=marker,
|
||||||
@ -601,8 +601,8 @@ class InstanceViewTest(test.BaseAdminViewTests):
|
|||||||
self.assertCountEqual(servers, expected_servers)
|
self.assertCountEqual(servers, expected_servers)
|
||||||
|
|
||||||
# back to first page
|
# back to first page
|
||||||
expected_servers = mox_servers[:size]
|
expected_servers = mock_servers[:size]
|
||||||
marker = mox_servers[0].id
|
marker = mock_servers[0].id
|
||||||
res = self._test_servers_paginate_do(
|
res = self._test_servers_paginate_do(
|
||||||
marker=marker,
|
marker=marker,
|
||||||
servers=expected_servers,
|
servers=expected_servers,
|
||||||
|
Loading…
Reference in New Issue
Block a user