-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make some tests that cover the model class
- Loading branch information
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |