Skip to content

Commit

Permalink
test_imagery.py full coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
tamasmagyar committed Apr 14, 2020
1 parent d8bf3bb commit bc3852c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Testing
-------
* [Samuel Yap] (https://github.com/samuelyap)
* [Patrick Casbon] (https://github.com/patcas)
* [Tamas Magyar] (https://github.com/tamasmagyar)

Packaging and Distribution
--------------------------
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/agroapi10/test_imagery.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import unittest
from datetime import datetime
from unittest.mock import patch

from pyowm.commons.image import Image, ImageTypeEnum
from pyowm.agroapi10.enums import PresetEnum, SatelliteEnum
from pyowm.agroapi10.imagery import MetaImage, SatelliteImage
Expand Down Expand Up @@ -96,3 +98,15 @@ def test_downloaded_on_fails_with_unknown_timeformat(self):

def test_repr(self):
repr(self.test_instance)

def test_init(self):
test_instance = SatelliteImage(TestMetaImage.test_instance, self.test_image)

self.assertFalse(hasattr(test_instance, '_downloaded_on'))

def test_persist(self):
with patch('builtins.open', unittest.mock.mock_open()) as mocked_open:
persists = self.test_instance.persist('filename')
assert persists is None

mocked_open.assert_called_once_with('filename', 'wb')

0 comments on commit bc3852c

Please sign in to comment.