'Test publisher post.'

@mock.patch('ceilometer.publisher.http.LOG')
def test_http_post_events(self, thelog):

    parsed_url = urlparse.urlparse('http://localhost:90/path1')
    publisher = http.HttpPublisher(self.CONF, parsed_url)
    res = requests.Response()
    res.status_code = 200
    with mock.patch.object(requests.Session, 'post', return_value=res) as m_req:
        publisher.publish_events(self.event_data)
    self.assertEqual(1, m_req.call_count)
    self.assertFalse(thelog.exception.called)
    res = requests.Response()
    res.status_code = 401
    with mock.patch.object(requests.Session, 'post', return_value=res) as m_req:
        publisher.publish_events(self.event_data)
    self.assertEqual(1, m_req.call_count)
    self.assertTrue(thelog.exception.called)
