Skip to content

Commit

Permalink
Make some tests that cover the model class
Browse files Browse the repository at this point in the history
  • Loading branch information
yarbshk committed Jan 13, 2018
1 parent 4c6c138 commit 8409b9c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Empty file removed tests/unit/row2dict.py
Empty file.
28 changes: 28 additions & 0 deletions tests/unit/test_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import types
from tests.schema import User
from tests.test import TestCase


class ModelTest(TestCase):
def test_as_dict(self):
user_dict = self.user.as_dict()
self.assertIsInstance(user_dict, dict)
self.assertDictEqual(user_dict, {
'id': 1,
'username': 'yarbshk',
'password': 'x',
'_secret': 'x',
'role': None,
'role_id': 1
})

def test_from_dict(self):
user_dict = self.user.as_dict()
user_row = User.from_dict(user_dict)
self.assertIsInstance(user_row, User)
self.assertEqual(user_row.username, self.user.username)
self.assertEqual(user_row.password, self.user.password)

def test_iter(self):
iterator = getattr(self.user, '__iter__')()
self.assertIsInstance(iterator, types.GeneratorType)

0 comments on commit 8409b9c

Please sign in to comment.