class JSONDeserializerTestCase(ValidatorTestCase): """Tests for class JSONDeserializer """ def setUp(self): """Create a JSONDeserializer instance """ super(JSONDeserializerTestCase, self).setUp() self.item = JSONDeserializer() def test_dispatch(self): """Tests for method dispatch """ input = mock.MagicMock() input.body = '{"MyInput": "mydata"}' expected = {u'body': {u'MyInput': u'mydata'}} observed = self.item.dispatch(input, action="default") self.assertEqual(expected, observed) def test_deserialize(self): """Tests for method deserialize """ self.item.external = mock.MagicMock() input = mock.MagicMock() input.body = '{"MyInput": "mydata"}' expected = {u'body': {u'MyInput': u'mydata'}} self.item.external.return_value = "OK" observed = self.item.deserialize(input) self.assertEqual(expected, observed) def test_default(self): """Tests for method default """ self.item.external = mock.MagicMock() request = mock.MagicMock() request.body = '{"MyInput": "mydata"}' expected = {u'body': {u'MyInput': u'mydata'}} self.item.external.return_value = "OK" observed = self.item.default(request) self.assertEqual(expected, observed) def tearDown(self): """Cleanup the JSONDeserializer instance """ super(JSONDeserializerTestCase, self).tearDown() self.m.UnsetStubs() self.m.ResetAll()