Notification handler unit tests do not test event types

Bug #1458921 reported by Rohit Jaiswal
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ceilometer
Won't Fix
Undecided
Rohit Jaiswal

Bug Description

Unit tests for the notification handlers just test the part which emits the sample but not the event_types regex. The regex is instrumental in routing the notification to a plugin handler and should be unit tested.

Probably, use something similar to this -

def _get_match_status(self, event, notification_class):
        handler = notification_class(mock.Mock())
        event_filter = handler.filter_rule
        return event_filter.match(context=None,
                                  event_type=event,
                                  publisher_id=None,
                                  metadata=None,
                                  payload=None)

 def test_role_events(self):
       self.assertEqual(True, self._get_match_status('identity.role.created',
                                                      notifications.Role))
      self.assertEqual(False, self._get_match_status(
            'identity.role_assignment.created',
            notifications.Role))

Revision history for this message
Rohit Jaiswal (rohit-jaiswal-3) wrote :

Probably need to add something similar to above for all applicable notification handlers.

Changed in ceilometer:
assignee: nobody → Rohit Jaiswal (rohit-jaiswal-3)
Revision history for this message
Rohit Jaiswal (rohit-jaiswal-3) wrote :

For instance, the bug https://bugs.launchpad.net/ceilometer/+bug/1457785 wouldn't exist if we had unit tests for supported event types for a noti. handler

Revision history for this message
gordon chung (chungg) wrote :

you might want to check with Prad. this test becomes moot when he does declarative metering work.

Changed in ceilometer:
status: New → Triaged
Revision history for this message
Pradeep Kilambi (pkilambi) wrote :

Agreed. With declarative notifications approach these tests might not be relevant in future.

Revision history for this message
gordon chung (chungg) wrote :
Changed in ceilometer:
status: Triaged → Won't Fix
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.