Exemplo n.º 1
0
def test_greeting():
    with open('tests/part-of-day.json', 'r') as f:
        part_of_day_results = json.load(f)

    for hour in range(24):
        result_time_of_day = Daytime.part_of_day(
            ephem.Date((2018, 11, 22, hour, 1)))
        assert result_time_of_day == part_of_day_results[str(
            hour)], "expected {} for {} o'clock', got {}.".format(
                part_of_day_results[str(hour)], hour, result_time_of_day)
Exemplo n.º 2
0
    def _stop_tracker(self):
        logging.info("Tracker stopped.")

        self._board.led.state = Led.OFF
        self._tracker_active = False

        summaries = []
        self._lock.acquire()
        for service in self._services:
            try: 
                service.stop()
                summaries.append(service.generate_summary())
            except Exception as e:
                logging.error("Could not stop service of class {}. Error: {}".format(service.__class__.__name__, e))

        self._services = None
        self._lock.release()
        if not self._debug:
            googlevoice.say(
                "Good {}. Welcome back. Here's your summary: ".format(Daytime.part_of_day()))
            for summary in filter(None, summaries):
                logging.info(summary)
                googlevoice.say(summary)