assertNoMessages() not working as expected

Bug #1315045 reported by Julie Pichon
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Expired
Undecided
Unassigned

Bug Description

If you add self.assertNoMessages() to any test that currently has something like self.assertMessageCount(res, error=1) the test will still pass.

If we use instead self.assertNoMessages(res) it works as expected with the test failing. Although the code seemingly supports not
specifying a response ( https://github.com/openstack/horizon/blob/53eb11604b7/horizon/test/helpers.py#L132 ) this path doesn't seem to work and the messages are always set to None.

My first instinct would be to make the response argument mandatory, in line with most (all?) assertions that need a response, though it'd be nice to first investigate how/why/if this used to work.

We use assertNoMessages() without an argument pretty much everywhere, but fixing them to add the argument doesn't seem to cause problems. There is one exception that appears due to the helper class handling rather than the test itself:

======================================================================
ERROR: test_instance_log (openstack_dashboard.dashboards.project.instances.tests.InstanceTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jpichon/devel/horizon/openstack_dashboard/test/helpers.py", line 83, in instance_stub_out
    return fn(self, *args, **kwargs)
  File "/home/jpichon/devel/horizon/openstack_dashboard/dashboards/project/instances/tests.py", line 789, in test_instance_log
    self.assertNoMessages(res)
  File "/home/jpichon/devel/horizon/horizon/test/helpers.py", line 120, in assertNoMessages
    self.assertMessageCount(response, success=0, warn=0, info=0, error=0)
  File "/home/jpichon/devel/horizon/horizon/test/helpers.py", line 139, in assertMessageCount
    elif hasattr(response, "context") and "messages" in response.context:
TypeError: argument of type 'NoneType' is not iterable

Akihiro Motoki (amotoki)
tags: added: horizon-core unittest
Julie Pichon (jpichon)
Changed in horizon:
assignee: Julie Pichon (jpichon) → nobody
utsav dusad (utsavdusad)
Changed in horizon:
assignee: nobody → utsav dusad (utsavdusad)
Revision history for this message
Rob Cresswell (robcresswell-deactivatedaccount) wrote :

Using self.assertNoMessages() seems to function fine for me on master, throwing an error as expected.

Changed in horizon:
assignee: utsav dusad (utsavdusad) → nobody
status: New → Incomplete
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for OpenStack Dashboard (Horizon) because there has been no activity for 60 days.]

Changed in horizon:
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.