'Test the timestamps to custom filter.'

def test_timestamp_custom(self):

    now = dt_util.utcnow()
    tests = [(None, None, None, 'None'), (1469119144, None, True, '2016-07-21    16:39:04'), (1469119144, '%Y', True, '2016'), (1469119144, 'invalid', True, 'invalid'), (dt_util.as_timestamp(now), None, False, now.strftime('%Y-%m-%d    %H:%M:%S'))]
    for (inp, fmt, local, out) in tests:
        if fmt:
            fil = "timestamp_custom('{}')".format(fmt)
        elif (fmt and local):
            fil = "timestamp_custom('{0}',    {1})".format(fmt, local)
        else:
            fil = 'timestamp_custom'
        self.assertEqual(out, template.Template(('{{    %s    |    %s    }}' % (inp, fil)), self.hass).render())
