def load_json(json_byte_stream): json_str = convert_byte_stream_to_str(json_byte_stream) api_response = {'errors': None, 'warnings': []} robot = Robot.get_instance() robot.reset() jpp = None errors, warnings = [], [] try: jpp = JSONProtocolProcessor(json_str) jpp.process() robot.simulate() except JSON_ERROR: errors.append('Cannot parse invalid JSON') except Exception as e: errors.append(str(e)) if jpp: errors.extend(jpp.errors) warnings.extend(jpp.warnings) if robot.get_warnings(): warnings.extend(robot.get_warnings()) api_response['errors'] = errors api_response['warnings'] = warnings return api_response
def test_all(self): failures = [] for protocol_path, protocol_dict in self.get_protocols(): Robot.reset_for_tests() try: jpp = JSONProtocolProcessor(protocol_dict) jpp.process() except Exception as e: failures.append((protocol_path, e, jpp.errors)) if failures: print('The following protocols failed to parse') for path, exc, reason in failures: print("[{}]. Reason: {}".format(path, exc)) assert False
def test_all(self): failures = [] for protocol_path, protocol_dict in self.get_protocols(): Robot.reset_for_tests() try: jpp = JSONProtocolProcessor(protocol_dict) jpp.process() except Exception as e: failures.append( (protocol_path, e, jpp.errors) ) if failures: print('The following protocols failed to parse') for path, exc, reason in failures: print("[{}]. Reason: {}".format(path, exc)) assert False