Skip to content

Commit

Permalink
Merge pull request #76 from ssenart/develop
Browse files Browse the repository at this point in the history
[#75] Fix an error when no temperature data is available
  • Loading branch information
ssenart authored Dec 21, 2024
2 parents 29f9e1a + cce50b9 commit 2ced7a7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.2.5](https://github.com/ssenart/PyGazpar/compare/1.2.5...1.2.4) - 2024-12-21

### Fixed
- [#75](https://github.com/ssenart/PyGazpar/issues/75): Fix an error when no temperature data is available.

## [1.2.4](https://github.com/ssenart/PyGazpar/compare/1.2.4...1.2.3) - 2024-10-09

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion pygazpar/jsonparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def parse(jsonStr: str, temperaturesStr: str, pceIdentifier: str) -> List[Dict[s

for releve in data[pceIdentifier]['releves']:
temperature = releve['temperature']
if temperature is None:
if temperature is None and temperatures is not None and len(temperatures) > 0:
temperature = temperatures.get(releve['journeeGaziere'])

item = {}
Expand Down
14 changes: 14 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ def test_hourly_live(self):

assert (len(data[Frequency.HOURLY.value]) == 0)

def test_one_day_jsonweb(self):
client = Client(JsonWebDataSource(self.__username, self.__password))

data = client.loadSince(self.__pceIdentifier, 1, [Frequency.DAILY])

assert (len(data[Frequency.DAILY.value]) <= 1)

def test_two_days_jsonweb(self):
client = Client(JsonWebDataSource(self.__username, self.__password))

data = client.loadSince(self.__pceIdentifier, 2, [Frequency.DAILY])

assert (len(data[Frequency.DAILY.value]) <= 2)

# @pytest.mark.skip(reason="Requires live data")
def test_daily_jsonweb(self):
client = Client(JsonWebDataSource(self.__username, self.__password))
Expand Down

0 comments on commit 2ced7a7

Please sign in to comment.