def test_set_error_dict(self): error = Error(code=1, title="title", message="message") expected = Collection('href', error=error) collection = Collection('href') collection.error = error.to_dict()["error"] self.assertIsInstance(collection.error, Error) self.assertEqual(collection, expected)
def test_error_to_dict(self): error = Error('code', 'message', 'title') expected = { 'error': { 'code': 'code', 'message': 'message', 'title': 'title', } } self.assertEqual(error.to_dict(), expected)
def test_error_not_equal(self): error = Error() other = Error('code', 'message', 'title') self.assertFalse(error.__ne__(error)) self.assertFalse(other.__ne__(other)) self.assertTrue(error.__ne__(other)) self.assertTrue(other.__ne__(error))
def test_error_minimal_to_dict(self): error = Error() expected = { 'error': {} } self.assertEqual(error.to_dict(), expected)