'Test that time is optional on a series with a time field.'

@mock.patch(u'influxdb.helper.SeriesHelper._current_timestamp')
def testSeriesWithTimeField(self, current_timestamp):

    current_date = datetime.today()
    yesterday = (current_date - timedelta(days=1))
    current_timestamp.return_value = yesterday
    class MyTimeFieldSeriesHelper(SeriesHelper, ):
        class Meta:
            client = TestSeriesHelper.client
            series_name = u'events.stats.{server_name}'
            fields = [u'some_stat', u'time']
            tags = [u'server_name', u'other_tag']
            bulk_size = 5
            autocommit = True
    MyTimeFieldSeriesHelper(server_name=u'us.east-1', other_tag=u'ello', some_stat=159, time=current_date)
    MyTimeFieldSeriesHelper(server_name=u'us.east-1', other_tag=u'ello', some_stat=158)
    (point1, point2) = MyTimeFieldSeriesHelper._json_body_()
    self.assertTrue(((u'time' in point1) and (u'time' in point2)))
    self.assertEqual(point1[u'time'], current_date)
    self.assertEqual(point2[u'time'], yesterday)
