Пример #1
0
    def write_fixture_wrapper(*args, **kw):
        kw['mock'] = _noop_mock
        response = func(*args, **kw)
        json_path = '{}/{}.{}'.format(
            fixture_output_path,
            fill_pattern_from_args(pattern, func, *args, **kw),
            suffix,
        )

        if not response:
            app.logger.warn('Error response, will not write fixture to ' + json_path)
            return response

        response_body = response.json() if hasattr(response, 'json') else response
        with open(json_path, 'w', encoding='utf-8') as outfile:
            json.dump(response_body, outfile, indent=2)
            app.logger.debug('Wrote fixture to ' + json_path)
        return response
Пример #2
0
 def register_fixture(*args, **kw):
     evaluated_pattern = fill_pattern_from_args(
         base_pattern, func, *args, **kw)
     return response_from_fixture(evaluated_pattern, suffix)