|
1 |
| -# Test cases can be run with: |
2 |
| -# nosetests |
3 |
| -# coverage report -m |
4 |
| - |
5 |
| -""" Test cases for Pet Model """ |
| 1 | +# Copyright 2016, 2017 John J. Rofrano. All Rights Reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +""" |
| 16 | +Test cases for Pet Model |
| 17 | +
|
| 18 | +Test cases can be run with: |
| 19 | + nosetests |
| 20 | + coverage report -m |
| 21 | +""" |
6 | 22 |
|
7 | 23 | import unittest
|
8 | 24 | from models import Pet, DataValidationError
|
@@ -82,6 +98,14 @@ def test_deserialize_a_pet(self):
|
82 | 98 | self.assertEqual(pet.id, 1)
|
83 | 99 | self.assertEqual(pet.name, "kitty")
|
84 | 100 | self.assertEqual(pet.category, "cat")
|
| 101 | + # test with id passed into constructor |
| 102 | + pet = Pet(2) |
| 103 | + pet.deserialize(data) |
| 104 | + self.assertNotEqual(pet, None) |
| 105 | + self.assertEqual(pet.id, 2) # id should not change |
| 106 | + self.assertEqual(pet.name, "kitty") |
| 107 | + self.assertEqual(pet.category, "cat") |
| 108 | + |
85 | 109 |
|
86 | 110 | def test_deserialize_with_no_name(self):
|
87 | 111 | """ Deserialize a Pet without a name """
|
|
0 commit comments