'Test the zone events.'

def test_run_with_zone_events(self):

    empty_me = [1, 2]
    def fake_get_events():
        'Return    nothing    twice,    then    some    events.'
        if empty_me:
            empty_me.pop()
        else:
            return fake_events
    client = mock.MagicMock()
    fake_events = [{'zone': 1, 'zone_state': True, 'type': 'zone_status'}, {'zone': 2, 'foo': False}]
    client.get_events.side_effect = fake_get_events
    watcher = nx584.NX584Watcher(client, {})
    @mock.patch.object(watcher, '_process_zone_event')
    def run(fake_process):
        'Run    a    fake    process.'
        fake_process.side_effect = StopMe
        self.assertRaises(StopMe, watcher._run)
        self.assertEqual(fake_process.call_count, 1)
        self.assertEqual(fake_process.call_args, mock.call(fake_events[0]))
    run()
    self.assertEqual(3, client.get_events.call_count)
