コード例 #1
0
ファイル: test_commands.py プロジェクト: briandoconnor/pypfb
def test_from_json(runner, invoke, path_join):
    with runner.isolated_filesystem():
        result = invoke(
            "from",
            "-o",
            "output.avro",
            "json",
            path_join("data"),
            "-s",
            path_join("schema", "kf.avro"),
            "--program",
            "DEV",
            "--project",
            "test",
        )
        assert result.exit_code == 0, result.output
        with open("output.avro", "rb") as f:
            r = reader(f)
            _test_schema(r)
            data = list(r)
            assert len(data) == 37
            for record in data:
                if record["name"] == "submitted_aligned_reads":
                    obj = record["object"]
                    if "soixantine_counterimpulse" in obj["submitter_id"]:
                        assert decode_enum(obj["state"]) == "validated"
                        assert decode_enum(obj["data_type"]) == "Aligned Reads"
                        assert decode_enum(
                            obj["data_category"]) == "Sequencing Reads"
                        assert decode_enum(obj["file_state"]) == "registered"
                        assert obj["file_format"] == "thumb_cotranspire"
                        assert obj["file_name"] == "virtuosi_conticent"
コード例 #2
0
ファイル: test_commands.py プロジェクト: briandoconnor/pypfb
def _test_schema(r):
    for node in r.writer_schema["fields"][2]["type"]:
        if node["name"] == "experiment_metadata":
            for field in node["fields"]:
                if field["name"] == "state":
                    assert decode_enum(field["default"]) == "validated"
                    for type_ in field["type"]:
                        if isinstance(type_, dict) and type_["type"] == "enum":
                            for symbol in type_["symbols"]:
                                decode_enum(symbol)