Example #1
0
def scenario(api):
    with console('Getting heartbeat'):
        resp = api.getHeartbeat()

    assert resp.status_code == 200

    with console('Playing with the cohorts'):
        vars = {'locale': 'en-US', 'territory': 'US'}
        vars.update(_VARS)
        resp = api.addUserToCohort(vars=vars)
        vars['cohort'] = 'default'
        resp = api.returnCohortSettings(vars)
Example #2
0
def main():
    parser = argparse.ArgumentParser(description='Smwogger. Smoke Tester.')

    parser.add_argument('url', help='Swagger URL or file')
    parser.add_argument('--test', help='Test URL or file', default=None)

    parser.add_argument('-v',
                        '--verbose',
                        help="Display more info",
                        action='store_true',
                        default=False)

    args = parser.parse_args()
    url = args.url

    if args.verbose:
        logger.setLevel(logging.INFO)
        ch = logging.StreamHandler()
        ch.setLevel(logging.INFO)
        formatter = logging.Formatter('%(message)s')
        ch.setFormatter(formatter)
        logger.addHandler(ch)
        logger.propagate = False

    with console("Scanning spec"):
        runner = get_runner(url, test_url=args.test, verbose=args.verbose)

    if isinstance(runner, SmokeTest):
        spec = runner.api.spec
        print()
        print("\t\tThis is project %r" % spec['info']['title'])
        print("\t\t%s" % spec['info']['description'])
        print("\t\tVersion %s" % spec['info']['version'])
        print()
        print()

        print('Running Scenario from x-smoke-test')
        for index, (oid, options) in enumerate(runner.scenario()):
            with console('%d:%s' % (index + 1, oid)):
                try:
                    runner(oid, **options)
                except Exception:
                    raise
    else:
        print('Running Python Scenario')
        runner()
Example #3
0
 async def _scenario():
     for index, (oid, options) in enumerate(runner.scenario()):
         with console('%d:%s' % (index + 1, oid),
                      verbose=args.verbose):
             try:
                 await runner(oid, **options)
             except Exception:
                 raise
     await stream.put(DONE)
Example #4
0
def main():
    parser = argparse.ArgumentParser(
        description='Smwogger. Smoke Tester.')

    parser.add_argument('url', help='Swagger URL or file')
    parser.add_argument('--test', help='Test URL or file',
                        default=None)
    parser.add_argument('-v', '--verbose', action='count', default=0,
                        help=('Verbosity level. -v will display '
                              'tracebacks. -vv requests and responses.'))

    args = parser.parse_args()
    url = args.url

    if args.verbose > 0:
        logger.setLevel(logging.INFO)
        ch = logging.StreamHandler()
        ch.setLevel(logging.INFO)
        formatter = logging.Formatter('%(message)s')
        ch.setFormatter(formatter)
        logger.addHandler(ch)
        logger.propagate = False

    loop = asyncio.get_event_loop()
    stream = asyncio.Queue()
    api = API(url, verbose=args.verbose, stream=stream)

    try:
        with console("Scanning spec", verbose=args.verbose):
            runner = get_runner(api, url, test_url=args.test,
                                verbose=args.verbose,
                                stream=stream)

        coros = []
        if isinstance(runner, SmokeTest):
            spec = runner.api.spec
            if args.verbose > 1:
                print()
                print("\t\tThis is project %r" % spec['info']['title'])
                print("\t\t%s" % spec['info']['description'])
                print("\t\tVersion %s" % spec['info']['version'])
                print()
                print()
                print('Running Scenario from x-smoke-test')

            async def _scenario():
                for index, (oid, options) in enumerate(runner.scenario()):
                    with console('%d:%s' % (index + 1, oid),
                                 verbose=args.verbose):
                        try:
                            await runner(oid, **options)
                        except Exception:
                            raise
                await stream.put(DONE)

            coros.append(_scenario())
        else:
            if args.verbose > 1:
                print('Running Python Scenario')

            async def single_run():
                await runner(args)
                await stream.put(DONE)

            coros.append(single_run())

        coros.append(log(stream))
        loop.run_until_complete(asyncio.gather(*coros))
    finally:
        api.close()
        loop.close()

    if args.verbose == 0:
        print()