Skip to content

Commit e5fc14d

Browse files
author
brentru
committed
testing/models explicit feed checks and group properties check
1 parent de591f0 commit e5fc14d

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

tests/test_model.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@
1818
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1919
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
# SOFTWARE.
21-
from Adafruit_IO import Data
21+
from Adafruit_IO import Data, Feed, Group
2222

2323
import base
2424

2525

2626
class TestData(base.IOTestCase):
2727

2828
def test_data_properties_are_optional(self):
29+
"""Data fields have optional properties
30+
"""
2931
data = Data(value='foo', feed_id=10)
3032
self.assertEqual(data.value, 'foo')
3133
self.assertEqual(data.feed_id, 10)
@@ -36,6 +38,37 @@ def test_data_properties_are_optional(self):
3638
self.assertIsNone(data.expiration)
3739
self.assertIsNone(data.position)
3840
self.assertIsNone(data.id)
41+
self.assertIsNone(data.lat)
42+
self.assertIsNone(data.lon)
43+
self.assertIsNone(data.ele)
44+
45+
46+
def test_feeds_have_explicitly_set_values(self):
47+
""" Let's make sure feeds are explicitly set from within the model:
48+
Feed.__new__.__defaults__ = (None, None, None, None, None, 'ON', 'Private', None, None, None)
49+
"""
50+
feed = Feed(name='foo')
51+
self.assertEqual(feed.name, 'foo')
52+
self.assertIsNone(feed.key)
53+
self.assertIsNone(feed.description)
54+
self.assertIsNone(feed.unit_type)
55+
self.assertIsNone(feed.unit_symbol)
56+
self.assertEqual(feed.history, 'ON')
57+
self.assertEqual(feed.visibility, 'Private')
58+
self.assertIsNone(feed.license)
59+
self.assertIsNone(feed.status_notify)
60+
self.assertIsNone(feed.status_timeout)
61+
62+
def test_group_properties_are_optional(self):
63+
group = Group(name="foo")
64+
self.assertEqual(group.name, 'foo')
65+
self.assertIsNone(group.description)
66+
self.assertIsNone(group.source_keys)
67+
self.assertIsNone(group.id)
68+
self.assertIsNone(group.key)
69+
self.assertIsNone(group.feeds)
70+
self.assertIsNone(group.properties)
71+
3972

4073
def test_from_dict_ignores_unknown_items(self):
4174
data = Data.from_dict({'value': 'foo', 'feed_id': 10, 'unknown_param': 42})

0 commit comments

Comments
 (0)