Skip to content

Commit

Permalink
Test str
Browse files Browse the repository at this point in the history
  • Loading branch information
wtgee committed Sep 3, 2023
1 parent 1516e96 commit ae57e43
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/aag/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def get_safe_reading(self, reading: dict) -> dict:
reading['cloud_condition'] = 'very cloudy'
elif temp_diff >= self.thresholds.cloudy:
reading['cloud_condition'] = 'cloudy'
elif temp_diff < self.thresholds.cloudy:
else:
reading['cloud_condition'] = 'clear'

reading['wind_condition'] = 'unknown'
Expand All @@ -198,15 +198,15 @@ def get_safe_reading(self, reading: dict) -> dict:
reading['wind_condition'] = 'very windy'
elif reading['wind_speed'] >= self.thresholds.windy:
reading['wind_condition'] = 'windy'
elif reading['wind_speed'] < self.thresholds.windy:
else:
reading['wind_condition'] = 'calm'

reading['rain_condition'] = 'unknown'
if reading['rain_frequency'] <= self.thresholds.rainy:
reading['rain_condition'] = 'rainy'
elif reading['rain_frequency'] <= self.thresholds.wet:
reading['rain_condition'] = 'wet'
elif reading['rain_frequency'] > self.thresholds.wet:
else:
reading['rain_condition'] = 'dry'

reading['cloud_safe'] = True if reading['cloud_condition'] == 'clear' else False
Expand Down
6 changes: 6 additions & 0 deletions tests/test_weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ def test_connect_loop():
assert is_connected is False
assert sensor.is_connected is False

def test_str():
sensor = CloudSensor(connect=False, serial_port='loop://')
sensor.firmware = '5.12-fake'
sensor.serial_number = '1234567890'
assert str(sensor) == 'CloudSensor(CloudWatcher, FW=5.12-fake, SN=1234567890, port=loop://)'


def test_get_safe_reading():
os.environ['AAG_SERIAL_PORT'] = 'loop://'
Expand Down

0 comments on commit ae57e43

Please sign in to comment.