コード例 #1
0
    def test_get_last_connection_time_display_returns_none_if_last_connection_time_is_none(
            self, garden_factory):
        formatter = GardenFormatter(
            garden_factory.build(last_connection_time=None))

        ret_val = formatter.get_last_connection_time_display()

        assert ret_val == str(None)
コード例 #2
0
 def is_displaying_info_for_garden(self, garden):
     formatter = GardenFormatter(garden)
     return all([
         self.get_garden_status() == formatter.get_is_connected_display(),
         self.get_last_connected_from() == str(
             formatter.last_connection_ip),
         self.get_last_connected_at() ==
         formatter.get_last_connection_time_display(),
         self.get_update_frequency() ==
         formatter.get_update_frequency_display(),
         self.get_connection_strength() ==
         formatter.get_connection_strength_display(),
         self.get_water_level() == formatter.get_water_level_display(),
         self.get_api_key() == str(formatter.token)
     ])
コード例 #3
0
    def test_get_last_connection_time_display_returns_correct_format(
            self, garden_factory):
        day = 25
        month = 2
        year = 2021
        hour = 12
        minute = 13
        period = 'PM'
        dtime = datetime(day=day,
                         month=month,
                         year=year,
                         hour=hour,
                         minute=minute,
                         tzinfo=pytz.UTC)
        formatter = GardenFormatter(
            garden_factory.build(last_connection_time=dtime))

        ret_val = formatter.get_last_connection_time_display()

        assert ret_val == f'{month}/{day}/{year} {hour}:{minute} {period}'