def test_get_builder(self, read_yaml_mock):
        self.set_read_yaml_mock_response(read_yaml_mock)

        yaml_loader = ContentLoader('anything.yml', 'content/')

        assert isinstance(yaml_loader.get_builder(), ContentBuilder)

        assert yaml_loader.get_builder().sections == yaml_loader._sections
    def test_multple_builders(self, read_yaml_mock):
        self.set_read_yaml_mock_response(read_yaml_mock)

        yaml_loader = ContentLoader('anything.yml', 'content/')

        builder1 = yaml_loader.get_builder()
        builder2 = yaml_loader.get_builder()

        assert builder1 != builder2
    def test_get_question(self, read_yaml_mock):
        self.set_read_yaml_mock_response(read_yaml_mock)

        yaml_loader = ContentLoader('anything.yml', 'content/')

        assert yaml_loader.get_question('question1') == {
            'depends': [{'being': 'SaaS', 'on': 'lot'}],
            'name': 'question1', 'id': 'question1'
        }
    def test_get_question_returns_a_copy(self, read_yaml_mock):
        self.set_read_yaml_mock_response(read_yaml_mock)

        yaml_loader = ContentLoader('anything.yml', 'content/')

        q1 = yaml_loader.get_question('question1')
        q1["id"] = "modified"
        q1["depends"] = []

        assert yaml_loader.get_question('question1') != q1
Esempio n. 5
0
def load_questions(schema_type, framework_slug, lot_slug):
    loader = ContentLoader('./')
    loader.load_manifest(
        framework_slug,
        MANIFESTS[schema_type]['question_set'],
        MANIFESTS[schema_type]['manifest']
    )

    builder = loader.get_builder(framework_slug, MANIFESTS[schema_type]['manifest']).filter({'lot': lot_slug})
    return {q['id']: q for q in sum((s.questions for s in builder.sections), [])}
Esempio n. 6
0
def load_questions(schema_type, framework_slug, lot_slug):
    loader = ContentLoader('./')
    loader.load_manifest(framework_slug,
                         MANIFESTS[schema_type]['question_set'],
                         MANIFESTS[schema_type]['manifest'])

    builder = loader.get_builder(framework_slug,
                                 MANIFESTS[schema_type]['manifest']).filter(
                                     {'lot': lot_slug})
    return {
        q['id']: q
        for q in sum((s.questions for s in builder.sections), [])
    }
Esempio n. 7
0
from dmutils.content_loader import ContentLoader

from config import configs


bootstrap = Bootstrap()
csrf = CsrfProtect()
data_api_client = apiclient.DataAPIClient()
feature_flags = flask_featureflags.FeatureFlag()
login_manager = LoginManager()
DISPLAY_DATE_FORMAT = '%d/%m/%Y'
DISPLAY_TIME_FORMAT = '%H:%M:%S'
DISPLAY_DATETIME_FORMAT = '%A, %d %B %Y at %H:%M'

service_content = ContentLoader(
    "app/section_order.yml", "app/content/g6/"
)


def create_app(config_name):

    application = Flask(__name__,
                        static_folder='static/',
                        static_url_path=configs[config_name].STATIC_URL_PATH)

    init_app(
        application,
        configs[config_name],
        bootstrap=bootstrap,
        data_api_client=data_api_client,
        feature_flags=feature_flags,
    def test_get_missing_question(self, read_yaml_mock):
        self.set_read_yaml_mock_response(read_yaml_mock)

        yaml_loader = ContentLoader('anything.yml', 'content/')

        assert yaml_loader.get_question('question111') == {}
import mock
import unittest
import datetime
from werkzeug.exceptions import NotFound

import app.helpers as helpers
from dmutils.content_loader import ContentLoader

from dmapiclient import api_stubs

content_loader = ContentLoader('tests/fixtures/content')
content_loader.load_manifest('dos', 'data', 'edit_brief')
questions_builder = content_loader.get_builder('dos', 'edit_brief')


class TestBuyersHelpers(unittest.TestCase):
    def test_get_framework_and_lot(self):
        data_api_client = mock.Mock()
        data_api_client.get_framework.return_value = api_stubs.framework(
            slug='digital-outcomes-and-specialists',
            status='live',
            lots=[
                api_stubs.lot(slug='digital-specialists', allows_brief=True)
            ]
        )

        framework, lot = helpers.buyers_helpers.get_framework_and_lot('digital-outcomes-and-specialists',
                                                                      'digital-specialists',
                                                                      data_api_client)

        assert framework['status'] == "live"
    def inner(record):
        row = [
            ("supplier_id", record["supplier_id"]),
            ("supplier_name", record["supplier"]["name"]),
            ("supplier_declaration_name", record["declaration"].get("nameOfOrganisation", "")),
            ("status", "PASSED" if record["onFramework"] else "FAILED"),
        ]
        return row + make_fields_from_content_questions(questions, record)

    return inner


if __name__ == '__main__':
    arguments = docopt(__doc__)

    STAGE = arguments['<stage>']
    API_TOKEN = arguments['<api_token>']
    CONTENT_PATH = arguments['<content_path>']

    client = DataAPIClient(get_api_endpoint_from_stage(STAGE), API_TOKEN)

    content_loader = ContentLoader(CONTENT_PATH)
    content_loader.load_manifest(FRAMEWORK_SLUG, "services", "edit_submission")
    content_manifest = content_loader.get_manifest(FRAMEWORK_SLUG, "edit_submission")

    records = find_all_participants(client)

    write_csv(records,
              make_row(content_manifest),
              "output/dos-user-research-participants.csv")
from flask_wtf.csrf import CsrfProtect
from dmutils import apiclient, init_app, flask_featureflags, formats
from dmutils.user import User
from dmutils.content_loader import ContentLoader
from config import configs

from markdown import markdown


bootstrap = Bootstrap()
csrf = CsrfProtect()
data_api_client = apiclient.DataAPIClient()
feature_flags = flask_featureflags.FeatureFlag()
login_manager = LoginManager()

content_loader = ContentLoader('app/content')
content_loader.load_manifest('g-cloud-6', 'services', 'edit_service_as_admin')
content_loader.load_manifest('g-cloud-7', 'declaration', 'declaration')


from app.main.helpers.service import parse_document_upload_time


def create_app(config_name):

    application = Flask(__name__,
                        static_folder='static/',
                        static_url_path=configs[config_name].STATIC_URL_PATH)

    init_app(
        application,
import os
import json
import unittest
from mock import Mock
from dmutils.content_loader import ContentLoader
from werkzeug.datastructures import MultiDict

from app.presenters.search_presenters import filters_for_lot, set_filter_states


content_loader = ContentLoader('tests/fixtures/content')
content_loader.load_manifest('g6', 'data', 'manifest')
questions_builder = content_loader.get_builder('g6', 'manifest')


def _get_fixture_data():
    test_root = os.path.abspath(
        os.path.join(os.path.dirname(__file__), "..")
    )
    fixture_path = os.path.join(
        test_root, 'fixtures', 'search_results_fixture.json'
    )
    with open(fixture_path) as fixture_file:
        return json.load(fixture_file)


def _get_fixture_multiple_pages_data():
    test_root = os.path.abspath(
        os.path.join(os.path.dirname(__file__), "..")
    )
    fixture_path = os.path.join(
Esempio n. 13
0
from flask import Blueprint, current_app, flash
from flask_login import current_user, login_required
from dmutils.content_loader import ContentLoader

buyers = Blueprint('buyers', __name__)

content_loader = ContentLoader('app/content')
content_loader.load_manifest('digital-outcomes-and-specialists', 'briefs', 'edit_brief')
content_loader.load_manifest('digital-outcomes-and-specialists', 'brief-responses', 'output_brief_response')
content_loader.load_manifest('digital-outcomes-and-specialists', 'clarification_question', 'clarification_question')


@buyers.before_request
@login_required
def require_login():
    if current_user.is_authenticated() and current_user.role != 'buyer':
        flash('buyer-role-required', 'error')
        return current_app.login_manager.unauthorized()


@buyers.after_request
def add_cache_control(response):
    response.cache_control.no_cache = True
    return response

from ..main import errors
from .views import buyers as buyers_views
Esempio n. 14
0
import dmapiclient
from dmutils import init_app, flask_featureflags, formats
from dmutils.user import User
from dmutils.content_loader import ContentLoader

from config import configs


bootstrap = Bootstrap()
csrf = CsrfProtect()
data_api_client = dmapiclient.DataAPIClient()
feature_flags = flask_featureflags.FeatureFlag()
login_manager = LoginManager()

content_loader = ContentLoader('app/content')
content_loader.load_manifest('g-cloud-6', 'services', 'edit_service_as_admin')
content_loader.load_manifest('g-cloud-7', 'declaration', 'declaration')
content_loader.load_manifest('digital-outcomes-and-specialists', 'declaration', 'declaration')

from app.main.helpers.service import parse_document_upload_time


def create_app(config_name):

    application = Flask(__name__,
                        static_folder='static/',
                        static_url_path=configs[config_name].STATIC_URL_PATH)

    init_app(
        application,
def load_questions(framework_slug, lot_slug):
    loader = ContentLoader('./')
    loader.load_manifest(framework_slug, 'services', 'edit_submission')

    builder = loader.get_builder(framework_slug, 'edit_submission').filter({'lot': lot_slug})
    return {q['id']: q for q in sum((s.questions for s in builder.sections), [])}
Esempio n. 16
0
import dmapiclient
from dmutils import init_app, flask_featureflags
from dmutils.content_loader import ContentLoader
from dmutils.user import User

from config import configs

login_manager = LoginManager()
data_api_client = dmapiclient.DataAPIClient()
order_api_client = dmapiclient.OrderAPIClient()
search_api_client = dmapiclient.SearchAPIClient()
feature_flags = flask_featureflags.FeatureFlag()
csrf = CsrfProtect()

content_loader = ContentLoader('app/content')
content_loader.load_manifest('inoket-1', 'services', 'search_filters')
content_loader.load_manifest('inoket-1', 'services', 'display_service')


def create_app(config_name):
    application = Flask(__name__)

    init_app(
        application,
        configs[config_name],
        data_api_client=data_api_client,
        order_api_client=order_api_client,
        feature_flags=feature_flags,
        login_manager=login_manager,
        search_api_client=search_api_client
from flask import Blueprint
from dmutils.content_loader import ContentLoader

main = Blueprint('main', __name__)

content_loader = ContentLoader('app/content')
content_loader.load_manifest('g-cloud-6', 'services', 'edit_service')
content_loader.load_messages('g-cloud-6', ['dates'])

content_loader.load_manifest('g-cloud-7', 'services', 'edit_service')
content_loader.load_manifest('g-cloud-7', 'services', 'edit_submission')
content_loader.load_manifest('g-cloud-7', 'declaration', 'declaration')
content_loader.load_messages('g-cloud-7', ['dates'])

content_loader.load_manifest('digital-outcomes-and-specialists', 'declaration', 'declaration')
content_loader.load_manifest('digital-outcomes-and-specialists', 'services', 'edit_submission')
content_loader.load_manifest('digital-outcomes-and-specialists', 'brief-responses', 'edit_brief_response')
content_loader.load_messages('digital-outcomes-and-specialists', ['dates'])

content_loader.load_manifest('g-cloud-8', 'services', 'edit_service')
content_loader.load_manifest('g-cloud-8', 'services', 'edit_submission')
content_loader.load_manifest('g-cloud-8', 'declaration', 'declaration')
content_loader.load_messages('g-cloud-8', ['dates'])

content_loader.load_manifest('inoket-1', 'services', 'edit_service')
content_loader.load_manifest('inoket-1', 'services', 'edit_submission')
content_loader.load_manifest('inoket-1', 'declaration', 'declaration')
content_loader.load_messages('inoket-1', ['dates'])

content_loader.load_manifest('inoket-2', 'services', 'edit_service')
content_loader.load_manifest('inoket-2', 'services', 'edit_submission')