Skip to content

Commit

Permalink
Fixed another bug in MinderGas API client implementation #228
Browse files Browse the repository at this point in the history
  • Loading branch information
dennissiemensma committed Jan 12, 2017
1 parent 9e3df64 commit 11b7829
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/changelog.rst
Expand Up @@ -24,6 +24,7 @@ v1.5.4 - 2017-01-12
**Tickets resolved in this release:**

- Improve datalogger for DSMR v5.0 (`#212 <https://github.com/dennissiemensma/dsmr-reader/issues/212>`_).
- Fixed another bug in MinderGas API client implementation (`#228 <https://github.com/dennissiemensma/dsmr-reader/issues/228>`_).



Expand Down
2 changes: 1 addition & 1 deletion dsmr_mindergas/services.py
Expand Up @@ -70,7 +70,7 @@ def export():

if response.status_code != 201:
# Try again in an hour.
next_export = midnight + timezone.timedelta(hours=1)
next_export = timezone.now() + timezone.timedelta(hours=1)
print(' [!] MinderGas upload failed (HTTP {}): {}'.format(response.status_code, response.text))

print(' - MinderGas | Delaying the next upload until: {}'.format(next_export))
Expand Down
5 changes: 3 additions & 2 deletions dsmr_mindergas/tests/test_services.py
Expand Up @@ -130,7 +130,7 @@ def test_export_random_schedule(self, now_mock, should_export_mock, requests_pos
@mock.patch('django.utils.timezone.now')
def test_export_fail(self, now_mock, should_export_mock, requests_post_mock):
""" Test export() failing by denied API call. """
now_mock.return_value = timezone.make_aware(timezone.datetime(2015, 12, 12, hour=0, minute=5))
now_mock.return_value = timezone.make_aware(timezone.datetime(2015, 12, 12, hour=4, minute=45))
should_export_mock.return_value = True

settings = MinderGasSettings.get_solo()
Expand All @@ -145,8 +145,9 @@ def test_export_fail(self, now_mock, should_export_mock, requests_post_mock):
dsmr_mindergas.services.export()

settings = MinderGasSettings.get_solo()

# This should be set one hour forward now.
self.assertEqual(settings.next_export, timezone.make_aware(timezone.datetime(2015, 12, 12, hour=1, minute=0)))
self.assertEqual(settings.next_export, timezone.now() + timezone.timedelta(hours=1))
self.assertTrue(requests_post_mock.called)

@mock.patch('requests.post')
Expand Down
2 changes: 1 addition & 1 deletion dsmrreader/__init__.py
Expand Up @@ -17,6 +17,6 @@
from django.utils.version import get_version


VERSION = (1, 5, 4, 'beta', 1)
VERSION = (1, 5, 4, 'beta', 2)

__version__ = get_version(VERSION)

0 comments on commit 11b7829

Please sign in to comment.