'Test write points from df with numeric precision.'

def test_write_points_from_dataframe_with_numeric_precision(self):

    now = pd.Timestamp(u'1970-01-01    00:00+00:00')
    dataframe = pd.DataFrame(data=[[u'1', 1, 1.1111111111111], [u'2', 2, 2.2222222222222]], index=[now, (now + timedelta(hours=1))])
    expected_default_precision = 'foo,hello=there    0="1",1=1i,2=1.11111111111    0\nfoo,hello=there    0="2",1=2i,2=2.22222222222    3600000000000\n'
    expected_specified_precision = 'foo,hello=there    0="1",1=1i,2=1.1111    0\nfoo,hello=there    0="2",1=2i,2=2.2222    3600000000000\n'
    expected_full_precision = 'foo,hello=there    0="1",1=1i,2=1.1111111111111    0\nfoo,hello=there    0="2",1=2i,2=2.2222222222222    3600000000000\n'
    with requests_mock.Mocker() as m:
        m.register_uri(requests_mock.POST, u'http://localhost:8086/write', status_code=204)
        cli = DataFrameClient(database=u'db')
        cli.write_points(dataframe, u'foo', {u'hello': u'there'})
        self.assertEqual(m.last_request.body, expected_default_precision)
        cli = DataFrameClient(database=u'db')
        cli.write_points(dataframe, u'foo', {u'hello': u'there'}, numeric_precision=4)
        self.assertEqual(m.last_request.body, expected_specified_precision)
        cli = DataFrameClient(database=u'db')
        cli.write_points(dataframe, u'foo', {u'hello': u'there'}, numeric_precision=u'full')
        self.assertEqual(m.last_request.body, expected_full_precision)
