def test_generate_dos_brief_opens_files(opened_files, tmpdir):
    dos_schemas = [x for x in SCHEMAS['briefs'] if x[1] == "digital-outcomes-and-specialists"]
    test_directory = str(tmpdir.mkdir("briefs"))

    for schema in dos_schemas:
        generate_schema(test_directory, 'briefs', *schema)
    dos_path = "./frameworks/digital-outcomes-and-specialists"
    dos_opened_files = set(x for x in opened_files
                           if x.startswith(dos_path) and os.path.isfile(x))
    dos_expected_files = set([x for x in recursive_file_list(dos_path)
                              if ("questions/briefs" in x or
                                  x.endswith("manifests/edit_brief.yml")) and
                              not x.endswith("lot.yml")])
    assert dos_expected_files == dos_opened_files
def test_generate_dsp_schema_opens_files(opened_files, tmpdir):
    dos_schemas = [x for x in SCHEMAS['services'] if x[1] == "digital-service-professionals"]
    test_directory = str(tmpdir.mkdir("schemas"))

    for schema in dos_schemas:
        generate_schema(test_directory, 'services', *schema)
    dos_path = "./frameworks/digital-service-professionals"
    dos_opened_files = set(x for x in opened_files
                           if x.startswith(dos_path) and os.path.isfile(x))
    dos_expected_files = set([x for x in recursive_file_list(dos_path)
                              if ("questions/services" in x or
                                  x.endswith("manifests/edit_submission.yml")) and
                              not x.endswith("lot.yml")])
    assert dos_expected_files == dos_opened_files
def test_generate_dsp_brief_opens_files(opened_files, tmpdir):
    dos_schemas = [
        x for x in SCHEMAS['briefs'] if x[1] == "digital-service-professionals"
    ]
    test_directory = str(tmpdir.mkdir("briefs"))

    for schema in dos_schemas:
        generate_schema(test_directory, 'briefs', *schema)
    dos_path = "./frameworks/digital-service-professionals"
    dos_opened_files = set(x for x in opened_files
                           if x.startswith(dos_path) and os.path.isfile(x))
    dos_expected_files = set([
        x for x in recursive_file_list(dos_path)
        if ("questions/briefs" in x or x.endswith("manifests/edit_brief.yml"))
        and not x.endswith("lot.yml")
    ])
    assert dos_expected_files == dos_opened_files
Esempio n. 4
0
def test_generate_dos_schema_opens_files(opened_files, tmpdir):
    dos_schemas = [
        x for x in SCHEMAS['services']
        if x[1] == "digital-outcomes-and-specialists"
    ]
    test_directory = str(tmpdir.mkdir("schemas"))

    for schema in dos_schemas:
        generate_schema(test_directory, 'services', *schema)
    dos_path = "./frameworks/digital-outcomes-and-specialists"
    dos_opened_files = set(x for x in opened_files
                           if x.startswith(dos_path) and os.path.isfile(x))
    dos_expected_files = set([
        x for x in recursive_file_list(dos_path)
        if ("questions/services" in x or x.endswith(
            "manifests/edit_submission.yml")) and not x.endswith("lot.yml")
    ])
    assert dos_expected_files == dos_opened_files
def test_generate_g_cloud_schema_opens_files(opened_files, tmpdir):
    """
    This test checks that when building a schema, all files are
    actually opened.

    The assumption is that if there are files which aren't opened,
    either they are unnecessary or something has gone profoundly wrong.
    """
    g_cloud_schemas = [x for x in SCHEMAS['services'] if x[1] == "g-cloud-7"]
    test_directory = str(tmpdir.mkdir("schemas"))

    for schema in g_cloud_schemas:
        generate_schema(test_directory, 'services', *schema)
    g_cloud_path = "./frameworks/g-cloud-7"
    g_cloud_opened_files = set(x for x in opened_files
                               if x.startswith(g_cloud_path) and
                               os.path.isfile(x))
    g_cloud_expected_files = set([x for x in recursive_file_list(g_cloud_path)
                                  if ("questions/services" in x or
                                      x.endswith("manifests/edit_submission.yml")) and
                                  not x.endswith("lot.yml") and not x.endswith("id.yml")])
    assert g_cloud_expected_files == g_cloud_opened_files
Esempio n. 6
0
def test_generate_g_cloud_schema_opens_files(opened_files, tmpdir):
    """
    This test checks that when building a schema, all files are
    actually opened.

    The assumption is that if there are files which aren't opened,
    either they are unnecessary or something has gone profoundly wrong.
    """
    g_cloud_schemas = [x for x in SCHEMAS['services'] if x[1] == "g-cloud-7"]
    test_directory = str(tmpdir.mkdir("schemas"))

    for schema in g_cloud_schemas:
        generate_schema(test_directory, 'services', *schema)
    g_cloud_path = "./frameworks/g-cloud-7"
    g_cloud_opened_files = set(
        x for x in opened_files
        if x.startswith(g_cloud_path) and os.path.isfile(x))
    g_cloud_expected_files = set([
        x for x in recursive_file_list(g_cloud_path)
        if ("questions/services" in x
            or x.endswith("manifests/edit_submission.yml"))
        and not x.endswith("lot.yml") and not x.endswith("id.yml")
    ])
    assert g_cloud_expected_files == g_cloud_opened_files
#!/usr/bin/env python
"""Generate JSON schemas from the frameworks questions content.

Usage:
    generate-schemas.py --output-path=<output_path>

"""
import sys
sys.path.insert(0, '.')

from docopt import docopt
from schema_generator import generate_schema, SCHEMAS


if __name__ == '__main__':
    arguments = docopt(__doc__)
    for schema_type in SCHEMAS:
        for schema in SCHEMAS[schema_type]:
            generate_schema(arguments['--output-path'], schema_type, *schema)
Esempio n. 8
0
#!/usr/bin/env python
"""Generate JSON schemas from the frameworks questions content.

Usage:
    generate-schemas.py --output-path=<output_path>

"""
import os
import sys
sys.path.insert(0, '.')

from docopt import docopt
from schema_generator import generate_schema, SCHEMAS

if __name__ == '__main__':
    arguments = docopt(__doc__)
    OUTPUT_DIR = arguments['--output-path']
    if not os.path.exists(OUTPUT_DIR):
        print("Creating {} directory".format(OUTPUT_DIR))
        os.makedirs(OUTPUT_DIR)
    for schema_type in SCHEMAS:
        for schema in SCHEMAS[schema_type]:
            generate_schema(OUTPUT_DIR, schema_type, *schema)