Beispiel #1
0
    def init_config(cls):
        cls.config = ConfigObj(cls.config_file)
        try:
            # Reading any value from the config file
            cls.VALUE = cls.config['default']['some_key']

            # Initializing the Endpoints reader. Keeping it here because it will be needed across the project
            cls.endpoints_reader = ExcelReader(cls.ENDPOINTS_FILE)
        except KeyError:
            logger.log_exception(TAG)
Beispiel #2
0
 def save_response_to_file(self, file_path):
     """
     Saves the response of the API request to a file
     
     Args:
         file_path (str): File path to where the response should be saved
     """
     try:
         with open(file_path, 'w') as outf:
             json.dump(json.loads(self.response.response_body),
                       outf,
                       indent=4)
     except IOError:
         logger.log_error(
             TAG,
             'Could not save response to file. Check if path exists and you have permission'
         )
         logger.log_exception(TAG)
     except json.decoder.JSONDecodeError:
         logger.log_warn(
             TAG,
             'Response not in JSON format:\n' + self.response.response_body)