class JSONResponseBodyParserTest(unittest.TestCase):
    def tearDown(self):
        mockito.unstub()
        super(JSONResponseBodyParserTest, self).tearDown()

    def setUp(self):
        super(JSONResponseBodyParserTest, self).setUp()
        self._deferred = mockito.mock()
        self._parser = JSONResponseBodyParser(self._deferred)

    def test_parser_can_receive_single_piece_of_data(self):
        expected = {'expected': 'value'}
        self._parser.dataReceived(json.dumps(expected))
        self._parser.connectionLost(None)
        mockito.verify(self._deferred).callback(expected)

    def test_parser_can_receive_multiple_pieces_of_data(self):
        expected = {'expected': 'value'}
        for char in json.dumps(expected):
            self._parser.dataReceived(char)
        self._parser.connectionLost(None)
        mockito.verify(self._deferred).callback(expected)
 def setUp(self):
     super(JSONResponseBodyParserTest, self).setUp()
     self._deferred = mockito.mock()
     self._parser = JSONResponseBodyParser(self._deferred)