def test_read_block(self): port = self.make_port() driver = Driver(port, 0, pixel_tests=False) driver._server_process = MockServerProcess(lines=[ 'ActualHash: foobar', 'Content-Type: my_type', 'Content-Transfer-Encoding: none', '#EOF', ]) content_block = driver._read_block(0) self.assertEqual(content_block.content, '') self.assertEqual(content_block.content_type, 'my_type') self.assertEqual(content_block.encoding, 'none') self.assertEqual(content_block.content_hash, 'foobar') driver._server_process = None
def test_read_binary_block(self): port = self.make_port() driver = Driver(port, 0, pixel_tests=True) driver._server_process = MockServerProcess(lines=[ 'ActualHash: actual', 'ExpectedHash: expected', 'Content-Type: image/png', 'Content-Length: 9', '12345678', '#EOF', ]) content_block = driver._read_block(0) self.assertEqual(content_block.content_type, 'image/png') self.assertEqual(content_block.content_hash, 'actual') self.assertEqual(content_block.content, '12345678\n') self.assertEqual(content_block.decoded_content, '12345678\n') driver._server_process = None
def test_read_base64_block(self): port = self.make_port() driver = Driver(port, 0, pixel_tests=True) driver._server_process = MockServerProcess(lines=[ 'ActualHash: actual', 'ExpectedHash: expected', 'Content-Type: image/png', 'Content-Transfer-Encoding: base64', 'Content-Length: 12', 'MTIzNDU2NzgK#EOF', ]) content_block = driver._read_block(0) self.assertEqual(content_block.content_type, 'image/png') self.assertEqual(content_block.content_hash, 'actual') self.assertEqual(content_block.encoding, 'base64') self.assertEqual(content_block.content, 'MTIzNDU2NzgK') self.assertEqual(content_block.decoded_content, '12345678\n')