'Test write points with precision for TestInfluxDBClient object.'

def test_write_points_with_precision(self):

    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(self.dummy_points, time_precision=u'n')
        self.assertEqual('cpu_load_short,host=server01,region=us-west    value=0.64    1257894000123456000\n', m.last_request.body)
        cli.write_points(self.dummy_points, time_precision=u'u')
        self.assertEqual('cpu_load_short,host=server01,region=us-west    value=0.64    1257894000123456\n', m.last_request.body)
        cli.write_points(self.dummy_points, time_precision=u'ms')
        self.assertEqual('cpu_load_short,host=server01,region=us-west    value=0.64    1257894000123\n', m.last_request.body)
        cli.write_points(self.dummy_points, time_precision=u's')
        self.assertEqual('cpu_load_short,host=server01,region=us-west    value=0.64    1257894000\n', m.last_request.body)
        cli.write_points(self.dummy_points, time_precision=u'm')
        self.assertEqual('cpu_load_short,host=server01,region=us-west    value=0.64    20964900\n', m.last_request.body)
        cli.write_points(self.dummy_points, time_precision=u'h')
        self.assertEqual('cpu_load_short,host=server01,region=us-west    value=0.64    349415\n', m.last_request.body)
