← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1315045] [NEW] assertNoMessages() not working as expected

 

Public bug reported:

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

** Affects: horizon
     Importance: Undecided
     Assignee: Julie Pichon (jpichon)
         Status: New

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Dashboard (Horizon).
https://bugs.launchpad.net/bugs/1315045

Title:
  assertNoMessages() not working as expected

Status in OpenStack Dashboard (Horizon):
  New

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

To manage notifications about this bug go to:
https://bugs.launchpad.net/horizon/+bug/1315045/+subscriptions


Follow ups

References