def test_read_handshake(self): handshake_dict = {"conf": self.conf, "pidDir": ".", "context": self.context} pid_dir = handshake_dict['pidDir'] expected_conf = handshake_dict['conf'] expected_context = handshake_dict['context'] inputs = ["{}\n".format(json.dumps(handshake_dict)), "end\n"] component = Component(input_stream=BytesIO(''.join(inputs).encode('utf-8')), output_stream=BytesIO()) given_conf, given_context = component.read_handshake() pid_path = os.path.join(pid_dir, str(component.pid)) self.assertTrue(os.path.exists(pid_path)) os.remove(pid_path) self.assertEqual(given_conf, expected_conf) self.assertEqual(given_context, expected_context) self.assertEqual(component.serializer.serialize_dict({"pid": component.pid}).encode('utf-8'), component.serializer.output_stream.buffer.getvalue())
def test_read_handshake(self): handshake_dict = { "conf": self.conf, "pidDir": ".", "context": self.context } pid_dir = handshake_dict['pidDir'] expected_conf = handshake_dict['conf'] expected_context = handshake_dict['context'] inputs = ["{}\n".format(json.dumps(handshake_dict)), "end\n"] component = Component(input_stream=BytesIO( ''.join(inputs).encode('utf-8')), output_stream=BytesIO()) given_conf, given_context = component.read_handshake() pid_path = os.path.join(pid_dir, str(component.pid)) self.assertTrue(os.path.exists(pid_path)) os.remove(pid_path) self.assertEqual(given_conf, expected_conf) self.assertEqual(given_context, expected_context) self.assertEqual( component.serializer.serialize_dict({ "pid": component.pid }).encode('utf-8'), component.serializer.output_stream.buffer.getvalue())