'Test write points batch for TestInfluxDBClient object.'

def test_write_points_batch(self):

    dummy_points = [{u'measurement': u'cpu_usage', u'tags': {u'unit': u'percent'}, u'time': u'2009-11-10T23:00:00Z', u'fields': {u'value': 12.34}}, {u'measurement': u'network', u'tags': {u'direction': u'in'}, u'time': u'2009-11-10T23:00:00Z', u'fields': {u'value': 123.0}}, {u'measurement': u'network', u'tags': {u'direction': u'out'}, u'time': u'2009-11-10T23:00:00Z', u'fields': {u'value': 12.0}}]
    expected_last_body = u'network,direction=out,host=server01,region=us-west    value=12.0    1257894000000000000\n'
    with requests_mock.Mocker() as m:
        m.register_uri(requests_mock.POST, u'http://localhost:8086/write', status_code=204)
        cli = InfluxDBClient(database=u'db')
        cli.write_points(points=dummy_points, database=u'db', tags={u'host': u'server01', u'region': u'us-west'}, batch_size=2)
    self.assertEqual(m.call_count, 2)
    self.assertEqual(expected_last_body, m.last_request.body.decode(u'utf-8'))
