def test_links_to_sections_go_to_the_correct_pages_whether_they_be_sections_or_questions( self, content_loader, brief): # noqa content_fixture = ContentLoader("tests/fixtures/content") content_fixture.load_manifest("dos", "data", "edit_brief") content_loader.get_manifest.return_value = content_fixture.get_manifest( "dos", "edit_brief") document = self.get_requirements_task_list_page(brief) section_steps = document.cssselect("ol.dm-task-list") section_1_link = section_steps[0].xpath( 'li//a[contains(text(), "Section 1")]') section_2_link = section_steps[0].xpath( 'li//a[contains(text(), "Section 2")]') section_4_link = section_steps[0].xpath( 'li//a[contains(text(), "Section 4")]') # section with multiple questions assert ( section_1_link[0].get("href").strip() == "/buyers/frameworks/digital-outcomes-and-specialists-4/requirements/digital-specialists/1234/section-1" ) # section with single question assert ( section_2_link[0].get("href").strip() == "/buyers/frameworks/digital-outcomes-and-specialists-4" "/requirements/digital-specialists/1234/edit/section-2/required2") # section with single question and a description assert ( section_4_link[0].get("href").strip() == "/buyers/frameworks/digital-outcomes-and-specialists-4/requirements/digital-specialists/1234/section-4" )
def _make_content_loader_factory(application, frameworks, initial_instance=None): # for testing purposes we allow an initial_instance to be provided primary_cl = initial_instance if initial_instance is not None else ContentLoader( 'app/content') for framework_data in frameworks: if not framework_data['slug'] in application.config.get( 'DM_FRAMEWORK_CONTENT_MAP', {}): if framework_data['framework'] == 'g-cloud': primary_cl.load_manifest(framework_data['slug'], 'services', 'services_search_filters') # we need to be able to display old services, even on expired frameworks primary_cl.load_manifest(framework_data['slug'], 'services', 'display_service') primary_cl.load_manifest(framework_data['slug'], 'services', 'download_results') try_load_metadata(primary_cl, application, framework_data, ['following_framework']) elif framework_data[ 'framework'] == 'digital-outcomes-and-specialists': primary_cl.load_manifest(framework_data['slug'], 'briefs', 'display_brief') try_load_manifest(primary_cl, application, framework_data, 'briefs', 'briefs_search_filters') # seal primary_cl in a closure by returning a function which will only ever return an independent copy of it. # this is of course only guaranteed when the initial_instance argument wasn't used. return lambda: deepcopy(primary_cl)
def _make_content_loader_factory(): primary_cl = ContentLoader('app/content') primary_cl.load_manifest('digital-outcomes-and-specialists', 'briefs', 'edit_brief') primary_cl.load_manifest('digital-outcomes-and-specialists', 'brief-responses', 'output_brief_response') primary_cl.load_manifest('digital-outcomes-and-specialists', 'brief-responses', 'legacy_output_brief_response') primary_cl.load_manifest('digital-outcomes-and-specialists', 'clarification_question', 'clarification_question') primary_cl.load_manifest('digital-outcomes-and-specialists', 'briefs', 'award_brief') primary_cl.load_manifest('digital-outcomes-and-specialists-2', 'briefs', 'edit_brief') primary_cl.load_manifest('digital-outcomes-and-specialists-2', 'brief-responses', 'output_brief_response') primary_cl.load_manifest('digital-outcomes-and-specialists-2', 'clarification_question', 'clarification_question') primary_cl.load_manifest('digital-outcomes-and-specialists-2', 'briefs', 'award_brief') primary_cl.load_manifest('digital-outcomes-and-specialists-3', 'briefs', 'edit_brief') primary_cl.load_manifest('digital-outcomes-and-specialists-3', 'brief-responses', 'output_brief_response') primary_cl.load_manifest('digital-outcomes-and-specialists-3', 'clarification_question', 'clarification_question') primary_cl.load_manifest('digital-outcomes-and-specialists-3', 'briefs', 'award_brief') primary_cl.load_manifest('digital-outcomes-and-specialists-4', 'briefs', 'edit_brief') primary_cl.load_manifest('digital-outcomes-and-specialists-4', 'briefs', 'display_brief') primary_cl.load_manifest('digital-outcomes-and-specialists-4', 'brief-responses', 'output_brief_response') primary_cl.load_manifest('digital-outcomes-and-specialists-4', 'clarification_question', 'clarification_question') primary_cl.load_manifest('digital-outcomes-and-specialists-4', 'briefs', 'award_brief') primary_cl.load_manifest('digital-outcomes-and-specialists-5', 'briefs', 'edit_brief') primary_cl.load_manifest('digital-outcomes-and-specialists-5', 'briefs', 'display_brief') primary_cl.load_manifest('digital-outcomes-and-specialists-5', 'brief-responses', 'output_brief_response') primary_cl.load_manifest('digital-outcomes-and-specialists-5', 'clarification_question', 'clarification_question') primary_cl.load_manifest('digital-outcomes-and-specialists-5', 'briefs', 'award_brief') # seal primary_cl in a closure by returning a function which will only ever return an independent copy of it return lambda: deepcopy(primary_cl)
def get_framework_contract_title(content_path: str, framework_slug: str) -> str: """The contract title is different for G-Cloud and DOS. Look up the correct name with the content loader""" content_loader = ContentLoader(content_path) content_loader.load_messages(framework_slug, ["e-signature"]) return str( content_loader.get_message(framework_slug, "e-signature", "framework_contract_title"))
def _make_content_loader_factory(): primary_cl = ContentLoader('app/content') _load_dos(primary_cl) _load_g_cloud(primary_cl) # seal primary_cl in a closure by returning a function which will only ever return an independent copy of it return lambda: deepcopy(primary_cl)
def load_manifest(schema_type, framework_slug, lot_slug): loader = ContentLoader('./') loader.load_manifest(framework_slug, MANIFESTS[schema_type]['question_set'], MANIFESTS[schema_type]['manifest']) return loader.get_builder(framework_slug, MANIFESTS[schema_type]['manifest']).filter( {'lot': lot_slug})
def test_edit_brief_submission_raises_error_if_question_type_not_known(self, content_loader): with pytest.raises(UndefinedError): content_fixture = ContentLoader('tests/fixtures/content') content_fixture.load_manifest('dos', 'data', 'edit_brief_fail') content_loader.get_manifest.return_value = content_fixture.get_manifest('dos', 'edit_brief_fail') self.client.get( "/buyers/frameworks/digital-outcomes-and-specialists-4/requirements/digital-specialists" "/1234/edit/section-1/unhandled")
def main(): args = docopt(__doc__) frameworks_repo = Path(args["--frameworks-repo"]).resolve() framework_slug = args["<framework_slug>"] content_loader = ContentLoader(frameworks_repo) content_loader.load_manifest(framework_slug, "services", "services_search_filters") manifest = content_loader.get_manifest(framework_slug, "services_search_filters") # FIXME there isn't a uniform way to get the lots from the framework # content repo, hard code for G-Cloud for now framework_lots = [ { "name": "Cloud hosting", "slug": "cloud-hosting" }, { "name": "Cloud software", "slug": "cloud-software" }, { "name": "Cloud support", "slug": "cloud-support" }, ] writer = csv.writer(sys.stdout) # do the thing writer.writerow(["lot", "filter name", "filter value", "filter sub-value"]) def rows_for_filters(filters: dict): for section in filters.values(): yield ["", str(section["label"]), "", ""] for option in section["filters"]: yield ["", "", str(option["label"]), ""] # category filters can have sub-categories # (but not sub-sub-categories) if "children" in option: for suboption in option["children"]: yield ["", "", "", suboption["label"]] # start with filters that are common to all lots common_filters = filters_for_lot("all", manifest, framework_lots) writer.writerow(["Any lot", "", ""]) writer.writerows(rows_for_filters(common_filters)) for lot in framework_lots: writer.writerow([lot.get("name", lot["slug"])]) writer.writerows( rows_for_filters( filters_for_lot(lot["slug"], manifest, framework_lots)))
def test_edit_brief_submission_return_link_to_brief_overview_if_single_question(self, content_loader): content_fixture = ContentLoader('tests/fixtures/content') content_fixture.load_manifest('dos', 'data', 'edit_brief') content_loader.get_manifest.return_value = content_fixture.get_manifest('dos', 'edit_brief') res = self.client.get( "/buyers/frameworks/digital-outcomes-and-specialists-4/requirements/digital-specialists" "/1234/edit/section-2/required2") assert res.status_code == 200 document = html.fromstring(res.get_data(as_text=True)) secondary_action_link = document.xpath('//a[normalize-space(text())="Return to overview"]')[0] assert document.xpath('//h1')[0].text_content().strip() == "Required 2" assert secondary_action_link.get('href').strip() == "/buyers/frameworks/digital-outcomes-and-specialists-4/requirements/digital-specialists/1234" # noqa self._test_breadcrumbs_on_question_page(response=res, has_summary_page=False, question="Required 2")
def test_edit_brief_submission_multiquestion(self, content_loader): content_fixture = ContentLoader('tests/fixtures/content') content_fixture.load_manifest('dos', 'data', 'edit_brief') content_loader.get_manifest.return_value = content_fixture.get_manifest('dos', 'edit_brief') res = self.client.get( "/buyers/frameworks/digital-outcomes-and-specialists-4/requirements/digital-specialists/1234/edit/section-5/required3") # noqa assert res.status_code == 200 document = html.fromstring(res.get_data(as_text=True)) assert document.xpath('//h1')[0].text_content().strip() == "Required 3" assert document.xpath( '//label[contains(@for, "required3_1")]')[0].text_content().strip() == "Required 3_1" assert document.xpath( '//label[contains(@for, "required3_2")]')[0].text_content().strip() == "Required 3_2"
def _make_content_loader_factory(): master_cl = ContentLoader('app/content') master_cl.load_manifest('digital-outcomes-and-specialists', 'briefs', 'edit_brief') master_cl.load_manifest('digital-outcomes-and-specialists', 'brief-responses', 'legacy_edit_brief_response') master_cl.load_manifest('digital-outcomes-and-specialists', 'brief-responses', 'edit_brief_response') master_cl.load_manifest('digital-outcomes-and-specialists', 'brief-responses', 'legacy_display_brief_response') master_cl.load_manifest('digital-outcomes-and-specialists', 'brief-responses', 'display_brief_response') master_cl.load_manifest('digital-outcomes-and-specialists-2', 'briefs', 'edit_brief') master_cl.load_manifest('digital-outcomes-and-specialists-2', 'brief-responses', 'edit_brief_response') master_cl.load_manifest('digital-outcomes-and-specialists-2', 'brief-responses', 'display_brief_response') master_cl.load_manifest('digital-outcomes-and-specialists-3', 'briefs', 'edit_brief') master_cl.load_manifest('digital-outcomes-and-specialists-3', 'brief-responses', 'edit_brief_response') master_cl.load_manifest('digital-outcomes-and-specialists-3', 'brief-responses', 'display_brief_response') master_cl.load_manifest('digital-outcomes-and-specialists-4', 'briefs', 'edit_brief') master_cl.load_manifest('digital-outcomes-and-specialists-4', 'brief-responses', 'edit_brief_response') master_cl.load_manifest('digital-outcomes-and-specialists-4', 'brief-responses', 'display_brief_response') master_cl.load_manifest('digital-outcomes-and-specialists-5', 'briefs', 'edit_brief') master_cl.load_manifest('digital-outcomes-and-specialists-5', 'brief-responses', 'edit_brief_response') master_cl.load_manifest('digital-outcomes-and-specialists-5', 'brief-responses', 'display_brief_response') # seal master_cl in a closure by returning a function which will only ever return an independent copy of it return lambda: deepcopy(master_cl)
def setup_method(self, method): super().setup_method(method) self.data_api_client_patch = mock.patch( "app.main.views.create_a_brief.edit.data_api_client", autospec=True ) self.data_api_client = self.data_api_client_patch.start() self.data_api_client.get_brief.return_value = BriefStub( framework_slug="digital-outcomes-and-specialists-4", ).single_result_response() self.data_api_client.get_framework.return_value = FrameworkStub( slug='digital-outcomes-and-specialists-4', status='live', lots=[ LotStub(slug='digital-specialists', allows_brief=True).response() ] ).single_result_response() self.login_as_buyer() self.content_fixture = ContentLoader('tests/fixtures/content') self.content_fixture.load_manifest('dos', 'data', 'edit_brief')
def _make_content_loader_factory(application, frameworks, initial_instance=None): # for testing purposes we allow an initial_instance to be provided master_cl = initial_instance if initial_instance is not None else ContentLoader('app/content') for framework_data in frameworks: try: master_cl.load_manifest(framework_data['slug'], 'services', 'edit_service_as_admin') except ContentNotFoundError: # Not all frameworks have this, so no need to panic (e.g. G-Cloud 4, G-Cloud 5) application.logger.info( "Could not load edit_service_as_admin manifest for {}".format(framework_data['slug']) ) try: master_cl.load_manifest(framework_data['slug'], 'declaration', 'declaration') except ContentNotFoundError: # Not all frameworks have this, so no need to panic (e.g. G-Cloud 4, G-Cloud 5, G-Cloud-6) application.logger.info( "Could not load declaration manifest for {}".format(framework_data['slug']) ) # seal master_cl in a closure by returning a function which will only ever return an independent copy of it. # this is of course only guaranteed when the initial_instance argument wasn't used. return lambda: deepcopy(master_cl)
def test_post_update_if_single_question_no_description_redirects_to_overview(self, content_loader): content_fixture = ContentLoader('tests/fixtures/content') content_fixture.load_manifest('dos', 'data', 'edit_brief') content_loader.get_manifest.return_value = content_fixture.get_manifest('dos', 'edit_brief') res = self.client.post( "/buyers/frameworks/digital-outcomes-and-specialists-4/requirements/" "digital-specialists/1234/edit/section-2/required2", data={ "required2": "Answer" }) assert res.status_code == 302 self.data_api_client.update_brief.assert_called_with( '1234', {"required2": "Answer"}, page_questions=['required2'], updated_by='*****@*****.**' ) assert res.headers['Location'].endswith( 'buyers/frameworks/digital-outcomes-and-specialists-4/requirements/digital-specialists/1234' ) is True
def _make_content_loader_factory(application, frameworks, initial_instance=None): # for testing purposes we allow an initial_instance to be provided master_cl = initial_instance if initial_instance is not None else ContentLoader( 'app/content') for framework_data in frameworks: try: master_cl.load_manifest(framework_data['slug'], 'services', 'edit_service_as_admin') except ContentNotFoundError: _log_missing_manifest(application, "edit_service_as_admin", framework_data['slug']) try: master_cl.load_manifest(framework_data['slug'], 'declaration', 'declaration') except ContentNotFoundError: _log_missing_manifest(application, "declaration", framework_data['slug']) # seal master_cl in a closure by returning a function which will only ever return an independent copy of it. # this is of course only guaranteed when the initial_instance argument wasn't used. return lambda: deepcopy(master_cl)
def setup(self): content_loader = ContentLoader('tests/fixtures/content') content_loader.load_manifest('dos', "services", "edit_submission") self.content_manifest = content_loader.get_manifest( 'dos', "edit_submission") self.record = { "supplier": { "name": "ACME INC" }, "declaration": { "supplierRegisteredName": "ACME Ltd" }, "supplier_id": 34567, "onFramework": True, "services": [{ "locations": ["Offsite", "Scotland", "North East England"], "accessibleApplicationsOutcomes": True }] }
def main(): args = docopt(__doc__) frameworks_repo = Path(args["--frameworks-repo"]).resolve() framework_slug = args["<framework_slug>"] stage = args["<stage>"] lot = args["<lot>"] data_api_client = DataAPIClient(get_api_endpoint_from_stage(stage), get_auth_token('api', stage)) content_loader = ContentLoader(frameworks_repo) content_loader.load_manifest(framework_slug, "services", "services_search_filters") manifest = content_loader.get_manifest(framework_slug, "services_search_filters") # FIXME there isn't a uniform way to get the lots from the framework # content repo, hard code for G-Cloud for now framework_lots = [ {"name": "Cloud hosting", "slug": "cloud-hosting"}, {"name": "Cloud software", "slug": "cloud-software"}, {"name": "Cloud support", "slug": "cloud-support"}, ] writer = csv.writer(sys.stdout) # do the thing writer.writerow(['serviceId', 'topLevelCategories']) for service in data_api_client.find_services_iter(framework=framework_slug, status='published', lot=lot): service_categories = service['serviceCategories'] if service.get('serviceCategories') else [] top_level_categories = [] for f in filters_for_lot(service['lot'], manifest, framework_lots)['categories']['filters']: children = [f['label'] for f in f['children']] if f.get('children') else [] if any(item in service_categories for item in children): top_level_categories.append(f['label']) writer.writerow([service['id'], '; '.join(top_level_categories)])
failed_draft_ids) if __name__ == "__main__": arguments = docopt(__doc__) # Get script arguments framework_slug = arguments['<framework>'] stage = arguments['<stage>'] or 'local' dry_run = arguments['--dry-run'] or None create_draft = arguments['--create-draft'] or None data_api_client = DataAPIClient( base_url=get_api_endpoint_from_stage(stage), auth_token=get_auth_token('api', stage)) content_loader = ContentLoader("../digitalmarketplace-frameworks") local_directory = arguments['--folder'] # Check folder exists if local_directory and not os.path.exists(local_directory): print(f"Local directory {local_directory} not found. Aborting upload.") exit(1) # Check framework status framework = data_api_client.get_framework(framework_slug) framework_status = framework['frameworks']['status'] if framework_status not in ['open']: print( f"Cannot update services for framework {framework_slug} in status '{framework_status}'" )
from dmutils.env_helpers import get_api_endpoint_from_stage logger = logging_helpers.configure_logger() if __name__ == '__main__': arguments = docopt(__doc__) supplier_ids = get_supplier_ids_from_args(arguments) STAGE = arguments['<stage>'] FRAMEWORK_SLUG = arguments['<framework>'] GOVUK_NOTIFY_API_KEY = arguments['<notify_api_key>'] GOVUK_NOTIFY_TEMPLATE_ID = arguments['<notify_template_id>'] CONTENT_PATH = arguments['<content_path>'] DRY_RUN = arguments['--dry-run'] content_loader = ContentLoader(CONTENT_PATH) content_loader.load_messages(FRAMEWORK_SLUG, ['e-signature']) mail_client = scripts_notify_client(GOVUK_NOTIFY_API_KEY, logger=logger) api_client = DataAPIClient(base_url=get_api_endpoint_from_stage(STAGE), auth_token=get_auth_token('api', STAGE)) context_helper = SuccessfulSupplierContextForNotify( api_client, FRAMEWORK_SLUG, supplier_ids=supplier_ids, logger=logger) context_helper.populate_data() context_data = context_helper.get_users_personalisations() framework = api_client.get_framework(FRAMEWORK_SLUG).get('frameworks') prefix = "[Dry Run] " if DRY_RUN else "" # Add in any framework-specific dates etc here extra_template_context = {
def _make_content_loader_factory(): master_cl = ContentLoader('app/content') master_cl.load_manifest('g-cloud-6', 'services', 'edit_service') master_cl.load_messages('g-cloud-6', ['urls']) master_cl.load_manifest('g-cloud-7', 'services', 'edit_service') master_cl.load_manifest('g-cloud-7', 'services', 'edit_submission') master_cl.load_manifest('g-cloud-7', 'declaration', 'declaration') master_cl.load_messages('g-cloud-7', ['urls']) master_cl.load_manifest('digital-outcomes-and-specialists', 'declaration', 'declaration') master_cl.load_manifest('digital-outcomes-and-specialists', 'services', 'edit_submission') master_cl.load_manifest('digital-outcomes-and-specialists', 'briefs', 'edit_brief') master_cl.load_messages('digital-outcomes-and-specialists', ['urls']) master_cl.load_manifest('digital-outcomes-and-specialists-2', 'declaration', 'declaration') master_cl.load_manifest('digital-outcomes-and-specialists-2', 'services', 'edit_submission') master_cl.load_manifest('digital-outcomes-and-specialists-2', 'services', 'edit_service') master_cl.load_manifest('digital-outcomes-and-specialists-2', 'briefs', 'edit_brief') master_cl.load_messages('digital-outcomes-and-specialists-2', ['urls']) master_cl.load_manifest('g-cloud-8', 'services', 'edit_service') master_cl.load_manifest('g-cloud-8', 'services', 'edit_submission') master_cl.load_manifest('g-cloud-8', 'declaration', 'declaration') master_cl.load_messages('g-cloud-8', ['urls']) master_cl.load_manifest('g-cloud-9', 'services', 'edit_service') master_cl.load_manifest('g-cloud-9', 'services', 'edit_submission') master_cl.load_manifest('g-cloud-9', 'declaration', 'declaration') master_cl.load_messages('g-cloud-9', ['urls', 'advice']) master_cl.load_manifest('g-cloud-10', 'services', 'edit_service') master_cl.load_manifest('g-cloud-10', 'services', 'edit_submission') master_cl.load_manifest('g-cloud-10', 'declaration', 'declaration') master_cl.load_messages('g-cloud-10', ['urls', 'advice']) master_cl.load_metadata('g-cloud-10', ['copy_services']) master_cl.load_manifest('digital-outcomes-and-specialists-3', 'declaration', 'declaration') master_cl.load_manifest('digital-outcomes-and-specialists-3', 'services', 'edit_submission') master_cl.load_manifest('digital-outcomes-and-specialists-3', 'services', 'edit_service') master_cl.load_manifest('digital-outcomes-and-specialists-3', 'briefs', 'edit_brief') master_cl.load_messages('digital-outcomes-and-specialists-3', ['urls']) master_cl.load_metadata('digital-outcomes-and-specialists-3', ['copy_services', 'following_framework']) master_cl.load_manifest('g-cloud-11', 'services', 'edit_service') master_cl.load_manifest('g-cloud-11', 'services', 'edit_submission') master_cl.load_manifest('g-cloud-11', 'declaration', 'declaration') master_cl.load_messages('g-cloud-11', ['urls', 'advice']) master_cl.load_metadata('g-cloud-11', ['copy_services', 'following_framework']) master_cl.load_manifest('digital-outcomes-and-specialists-4', 'declaration', 'declaration') master_cl.load_manifest('digital-outcomes-and-specialists-4', 'services', 'edit_submission') master_cl.load_manifest('digital-outcomes-and-specialists-4', 'services', 'edit_service') master_cl.load_manifest('digital-outcomes-and-specialists-4', 'briefs', 'edit_brief') master_cl.load_messages('digital-outcomes-and-specialists-4', ['urls']) master_cl.load_metadata('digital-outcomes-and-specialists-4', ['copy_services', 'following_framework']) master_cl.load_manifest('g-cloud-12', 'services', 'edit_service') master_cl.load_manifest('g-cloud-12', 'services', 'edit_submission') master_cl.load_manifest('g-cloud-12', 'declaration', 'declaration') master_cl.load_messages('g-cloud-12', ['urls', 'advice', 'e-signature']) master_cl.load_metadata('g-cloud-12', ['copy_services', 'following_framework']) master_cl.load_manifest('digital-outcomes-and-specialists-5', 'declaration', 'declaration') master_cl.load_manifest('digital-outcomes-and-specialists-5', 'services', 'edit_submission') master_cl.load_manifest('digital-outcomes-and-specialists-5', 'services', 'edit_service') master_cl.load_manifest('digital-outcomes-and-specialists-5', 'briefs', 'edit_brief') master_cl.load_messages('digital-outcomes-and-specialists-5', ['urls', 'e-signature']) master_cl.load_metadata('digital-outcomes-and-specialists-5', ['copy_services', 'following_framework']) # seal master_cl in a closure by returning a function which will only ever return an independent copy of it return lambda: deepcopy(master_cl)
import sys sys.path.insert(0, '.') from docopt import docopt from dmscripts.helpers.auth_helpers import get_auth_token from dmscripts.helpers.supplier_data_helpers import get_supplier_ids_from_file from dmscripts.export_framework_results_reasons import export_suppliers from dmapiclient import DataAPIClient from dmcontent.content_loader import ContentLoader from dmutils.env_helpers import get_api_endpoint_from_stage if __name__ == '__main__': args = docopt(__doc__) client = DataAPIClient(get_api_endpoint_from_stage(args['<stage>']), get_auth_token('api', args['<stage>'])) content_loader = ContentLoader(args['<content_path>']) declaration_definite_pass_schema = json.load( open(args["<declaration_schema_path>"], "r")) declaration_baseline_schema = ( declaration_definite_pass_schema.get("definitions") or {}).get("baseline") supplier_id_file = args['<supplier_id_file>'] supplier_ids = get_supplier_ids_from_file(supplier_id_file) export_suppliers(client, args['<framework_slug>'], content_loader, args['<output_dir>'], declaration_definite_pass_schema, declaration_baseline_schema, supplier_ids)
from flask import Blueprint, current_app, flash from flask_login import current_user, login_required from dmcontent.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') content_loader.load_manifest('digital-service-professionals', 'briefs', 'edit_brief') content_loader.load_manifest('digital-service-professionals', 'brief-responses', 'output_brief_response') content_loader.load_manifest('digital-service-professionals', 'clarification_question', 'clarification_question') content_loader.load_manifest('digital-marketplace', 'briefs', 'edit_brief') content_loader.load_manifest('digital-marketplace', 'brief-responses', 'output_brief_response') content_loader.load_manifest('digital-marketplace', 'clarification_question', 'clarification_question') @buyers.before_request @login_required def require_login():
import mock import unittest import datetime from werkzeug.exceptions import NotFound import app.helpers as helpers from dmcontent.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" assert framework['name'] == 'Digital Outcomes and Specialists'
'cloud-support', ] DOS_LOTS = [ 'digital-outcomes', 'digital-specialists', 'user-research-participants', 'user-research-studios', ] QUESTION_SETS = ['declaration', 'services'] if __name__ == '__main__': arguments = docopt(__doc__) content_path = arguments['<DM-content-root-dir>'] content_loader = ContentLoader(content_path) output_dir = arguments['<output-dir>'] framework_slug = arguments.get('--framework') # Generate all files if --question-set not given question_sets = [arguments.get('--question-set') ] if arguments.get('--question-set') else QUESTION_SETS for question_set in question_sets: if question_set == 'declaration': output_file = "{}/{}-declaration-questions.csv".format( output_dir, framework_slug) generate_csv(output_file, framework_slug, content_loader,