コード例 #1
0
ファイル: cli.py プロジェクト: decadent/polytropos
def coverage(schema_basepath: str, schema_name: str, data_path: str,
             output_prefix: str, t_group: Optional[str],
             i_group: Optional[str]) -> None:
    """Produce a coverage report consisting of four files: coverage and groups for each of immutable and temporal
    tracks."""
    CoverageFile.standalone(schema_basepath, schema_name, data_path,
                            output_prefix, cast(Optional[VariableId], t_group),
                            cast(Optional[VariableId], i_group))
コード例 #2
0
def coverage(schema_basepath: str, schema_name: str, data_path: str,
             output_prefix: str, t_group: Optional[str],
             i_group: Optional[str], exclude_trivial: bool) -> None:
    """Produce a coverage report consisting of four files: coverage and groups for each of immutable and temporal
    tracks."""
    with Context.build("",
                       "",
                       input_dir=data_path,
                       schemas_dir=schema_basepath) as context:
        CoverageFile.standalone(context, schema_name, output_prefix,
                                cast(Optional[VariableId], t_group),
                                cast(Optional[VariableId], i_group),
                                exclude_trivial)
コード例 #3
0
def test_nested_does_not_short_circuit_crawl():
    """Bug history:
         - Detected around 9/20/2019
         - Isolated minimum reproducible case on 9/24/2019
         - Caused by commit e23b825 (8/27/2019)
         - Regression test based on minimum reproducible case
    """
    spec: Dict = {
        "root": {
            "name": "return",
            "data_type": "Folder",
            "sort_order": 0
        },
        "application_submissions": {
            "name": "application_submissions",
            "data_type": "List",
            "parent": "root",
            "sort_order": 0
        },
        "award_restrict": {
            "name": "award_restrict",
            "data_type": "Text",
            "parent": "application_submissions",
            "sort_order": 0
        },
        "filer": {
            "name": "filer",
            "data_type": "Folder",
            "parent": "root",
            "sort_order": 1
        },
        "name_org": {
            "name": "name_org",
            "data_type": "Text",
            "parent": "filer",
            "sort_order": 0
        }
    }

    temporal: Track = Track.build(spec, None, "temporal")
    immutable: Track = Track.build({}, None, "immutable")
    schema: Schema = Schema(temporal, immutable, name="semantic")

    basepath: str = os.path.dirname(os.path.abspath(__file__))
    composite_path: str = os.path.join(basepath, "data")

    shutil.rmtree(output_path, ignore_errors=True)
    os.makedirs(output_path)
    with Context.build(conf_dir="dummy", data_dir="dummy") as context:
        coverage: CoverageFile = CoverageFile(context, schema, output_path + "/semantic", None, None)
        coverage(composite_path, "dummy")

    expected_path: str = os.path.join(basepath, "expected.csv")
    actual_path: str = os.path.join(output_path, "semantic_temporal.csv")
    with open(expected_path) as expected_fh, open(actual_path) as actual_fh:
        expected: csv.DictReader = csv.DictReader(expected_fh)
        actual: csv.DictReader = csv.DictReader(actual_fh)
        e_rows = [row for row in expected]
        a_rows = [row for row in actual]
        assert a_rows == e_rows
コード例 #4
0
 def _do_run(test_name: str, t_group_var: Optional[str],
             i_group_var: Optional[str]):
     composite_path: str = os.path.join(module_basepath, "composites")
     output_path: str = os.path.join(output_basepath,
                                     test_name + "/" + test_name)
     coverage: CoverageFile = CoverageFile(context, module_source_schema,
                                           output_path, t_group_var,
                                           i_group_var)
     coverage(composite_path, "dummy")
コード例 #5
0
 def _do_run(data_type: str, test_name: str, t_group_var: Optional[str],
             i_group_var: Optional[str]):
     composite_path: str = os.path.join(module_basepath, data_type.lower(),
                                        "composites")
     output_path: str = os.path.join(
         output_basepath,
         data_type.lower() + "/" + test_name + "/" + test_name)
     coverage: CoverageFile = CoverageFile(context,
                                           source_schema(data_type),
                                           output_path,
                                           t_group_var,
                                           i_group_var,
                                           exclude_trivial=True)
     coverage(composite_path, "dummy")