Skip to content

Commit

Permalink
Merge pull request #49 from mcaulifn/postfixes
Browse files Browse the repository at this point in the history
fix(post): Fixes issues with post
  • Loading branch information
mcaulifn authored Jan 26, 2021
2 parents 57412f5 + 848050c commit 618ca37
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pysolcast/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _post_data(self, uri: str, data: dict) -> dict: # pylint: disable=inconsist
"""Post data to API."""
url = f'{PySolcast.base_url}{uri}'
try:
_post_response = post(url, data=data)
_post_response = post(url, json=data, auth=(self.api_key, ''))
except (requests.exceptions.ConnectionError, requests.exceptions.Timeout) as error:
self.logger.info(error)
raise error
Expand Down
4 changes: 4 additions & 0 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def test_get_data_200():

# Assert
assert response == json.loads(expected_response)
assert responses.calls[0].request.headers['Authorization'] == 'Basic MTIzNDU6'


@responses.activate
Expand All @@ -74,6 +75,7 @@ def test_get_data_timeout():
obj._get_data(uri) # pylint: disable=protected-access

# Assert
assert responses.calls[0].request.headers['Authorization'] == 'Basic MTIzNDU6'


@responses.activate
Expand Down Expand Up @@ -108,6 +110,7 @@ def test_post_data():
# Assert
assert isinstance(measurement_response, dict)
assert measurement_response == json.loads(measurement_single)
assert responses.calls[0].request.headers['Authorization'] == 'Basic MTIzNDU6'


@responses.activate
Expand Down Expand Up @@ -141,3 +144,4 @@ def test_post_data_timeout():
obj._post_data(uri, measurement_single) # pylint: disable=protected-access

# Assert
assert responses.calls[0].request.headers['Authorization'] == 'Basic MTIzNDU6'

0 comments on commit 618ca37

Please sign in to comment.