Esempio n. 1
0
def test_load_pvt_tables_with_invalid_file(
        description_document_for_pvt_tables_test, tmp_path):
    """
    PvtModelsDescription.tables should raise a RuntimError when tab file is not found.
    """
    document = description_document_for_pvt_tables_test

    # YAML pointing to a invalid PVT model file
    document.content["tables"]["gavea"] = YAML("Foo.tab")

    expected_msg = (
        "The PVT Table Foo.tab must be place within the test_case.alfacase file on *"
    )
    with pytest.raises(RuntimeError, match=expected_msg):
        load_pvt_models_description(document=document)
def test_load_pvt_tables_with_pvt_model_selector(
    description_document_for_pvt_tables_test, tmp_path
):
    """
    PvtModelsDescription.tables should provide a way to the user select one of multiples pvt models that are inside the file
    This syntax can be used either for absolute path or relative path

    # Ex.: " <tab_file> | <pvt_model_name> "
    """
    document = description_document_for_pvt_tables_test

    document.content["tables"]["acme"] = YAML(
        str(document.file_path.parent / "acme.tab|SOMELABEL")
    )
    document.content["tables"]["acme_2"] = YAML("acme.tab|SOMELABEL")

    pvt_model_description = load_pvt_models_description(document=document)
    assert pvt_model_description.tables == {
        "acme": document.file_path.parent / "acme.tab|SOMELABEL",
        "acme_2": document.file_path.parent / "acme.tab|SOMELABEL",
    }

    # Ensure that the pvt file has the pvt_model GaveaDST
    case_description.CaseDescription(
        pvt_models=pvt_model_description
    ).ensure_valid_references()
def test_load_pvt_tables_with_absolute_file(
    description_document_for_pvt_tables_test, tmp_path
):
    """
    PvtModelsDescription.tables should accept absolute path to a tab file
    """
    document = description_document_for_pvt_tables_test

    new_folder = tmp_path / "new_folder"
    new_folder.mkdir()

    shutil.copy2(
        src=tmp_path / "acme.tab",
        dst=tmp_path / "new_folder/acme.tab",
    )

    # YAML is pointing to a valid PVT file, and is an absolute Path.
    document.content["tables"]["acme"] = YAML(
        str(document.file_path.parent / "new_folder/acme.tab")
    )

    pvt_model_description = load_pvt_models_description(document=document)
    assert pvt_model_description.tables == {
        "acme": document.file_path.parent / "new_folder/acme.tab",
        "acme_2": document.file_path.parent / "acme.tab",
    }
Esempio n. 4
0
def test_load_pvt_tables_with_relative_file(
        description_document_for_pvt_tables_test, tmp_path):
    """
    PvtModelsDescription.tables should accept a path relative to a tab file
    """
    document = description_document_for_pvt_tables_test
    pvt_model_description = load_pvt_models_description(document=document)

    assert pvt_model_description.tables == {
        "acme": document.file_path.parent / "acme.tab",
        "acme_2": document.file_path.parent / "acme.tab",
    }