コード例 #1
0
def test_get_rendered_configdocs():
    """
    Tests the RenderedConfigDocsResource method get_rendered_configdocs
    """
    rcdr = RenderedConfigDocsResource()

    with patch.object(ConfigdocsHelper,
                      'get_rendered_configdocs') as mock_method:
        helper = ConfigdocsHelper(CTX)
        rcdr.get_rendered_configdocs(helper, version='buffer')

    mock_method.assert_called_once_with('buffer')
コード例 #2
0
def test_get_rendered_successful_site_action_configdocs():
    """
    Tests the RenderedConfigDocsResource method get_rendered_configdocs
    for successful_site_action tag
    """
    rcdr = RenderedConfigDocsResource()

    with patch.object(ConfigdocsHelper,
                      'get_rendered_configdocs') as mock_method:
        helper = ConfigdocsHelper(CTX)
        rcdr.get_rendered_configdocs(helper, version='successful_site_action')

    mock_method.assert_called_once_with('successful_site_action')
コード例 #3
0
ファイル: api.py プロジェクト: rb560u/airship-shipyard
def start_api():
    middlewares = [
        AuthMiddleware(),
        ContextMiddleware(),
        LoggingMiddleware(),
        CommonParametersMiddleware()
    ]
    control_api = falcon.API(
        request_type=ShipyardRequest, middleware=middlewares)

    control_api.add_route('/versions', VersionsResource())

    # v1.0 of Shipyard API
    v1_0_routes = [
        # API for managing region data
        ('/health', HealthResource()),
        ('/actions', ActionsResource()),
        ('/actions/{action_id}', ActionsIdResource()),
        ('/actions/{action_id}/control/{control_verb}',
         ActionsControlResource()),
        ('/actions/{action_id}/steps/{step_id}',
         ActionsStepsResource()),
        ('/actions/{action_id}/steps/{step_id}/logs',
         ActionsStepsLogsResource()),
        ('/actions/{action_id}/validations/{validation_id}',
         ActionsValidationsResource()),
        ('/configdocs', ConfigDocsStatusResource()),
        ('/configdocs/{collection_id}', ConfigDocsResource()),
        ('/commitconfigdocs', CommitConfigDocsResource()),
        ('/notedetails/{note_id}', NoteDetailsResource()),
        ('/renderedconfigdocs', RenderedConfigDocsResource()),
        ('/workflows', WorkflowResource()),
        ('/workflows/{workflow_id}', WorkflowIdResource()),
        ('/site_statuses', StatusResource()),
    ]

    # Set up the 1.0 routes
    route_v1_0_prefix = '/api/v1.0'
    for path, res in v1_0_routes:
        route = '{}{}'.format(route_v1_0_prefix, path)
        LOG.info(
            'Adding route: %s Handled by %s',
            route,
            res.__class__.__name__
        )
        control_api.add_route(route, res)

    # Error handlers (FILO handling)
    control_api.add_error_handler(Exception, default_exception_handler)
    control_api.add_error_handler(AppError, AppError.handle)

    # built-in error serializer
    control_api.set_error_serializer(default_error_serializer)

    return control_api
コード例 #4
0
def test_validate_version_parameter():
    """
    test of the version parameter validation
    """
    rcdr = RenderedConfigDocsResource()
    with pytest.raises(ApiError):
        rcdr._validate_version_parameter('asdfjkl')

    try:
        rcdr._validate_version_parameter('buffer')
        rcdr._validate_version_parameter('committed')
    except:
        assert False