'Test track point in time.'

def test_track_point_in_time(self):

    before_birthday = datetime(1985, 7, 9, 12, 0, 0, tzinfo=dt_util.UTC)
    birthday_paulus = datetime(1986, 7, 9, 12, 0, 0, tzinfo=dt_util.UTC)
    after_birthday = datetime(1987, 7, 9, 12, 0, 0, tzinfo=dt_util.UTC)
    runs = []
    track_point_in_utc_time(self.hass, (lambda x: runs.append(1)), birthday_paulus)
    self._send_time_changed(before_birthday)
    self.hass.block_till_done()
    self.assertEqual(0, len(runs))
    self._send_time_changed(birthday_paulus)
    self.hass.block_till_done()
    self.assertEqual(1, len(runs))
    self._send_time_changed(birthday_paulus)
    self.hass.block_till_done()
    self.assertEqual(1, len(runs))
    track_point_in_time(self.hass, (lambda x: runs.append(1)), birthday_paulus)
    self._send_time_changed(after_birthday)
    self.hass.block_till_done()
    self.assertEqual(2, len(runs))
    unsub = track_point_in_time(self.hass, (lambda x: runs.append(1)), birthday_paulus)
    unsub()
    self._send_time_changed(after_birthday)
    self.hass.block_till_done()
    self.assertEqual(2, len(runs))
