Пример #1
0
def test_get(tmp_trestle_dir: pathlib.Path) -> None:
    """Test get model."""
    # create a model
    catalog_data = generators.generate_sample_model(cat.Catalog)
    repo = Repository(tmp_trestle_dir)
    repo.import_model(catalog_data, 'imported')
    managed_oscal = repo.get_model(cat.Catalog, 'imported')
    assert managed_oscal._model_name == 'imported'
Пример #2
0
def test_get_model_not_exists(tmp_trestle_dir: pathlib.Path) -> None:
    """Invalid get model does not exists."""
    repo = Repository(tmp_trestle_dir)
    with pytest.raises(TrestleError, match='does not exist'):
        repo.get_model(cat.Catalog, 'anything')
Пример #3
0
def test_get_invalid_top_model(tmp_trestle_dir: pathlib.Path) -> None:
    """Invalid top model."""
    repo = Repository(tmp_trestle_dir)
    with pytest.raises(TrestleError, match='not a top level model'):
        repo.get_model(oscal.common.Metadata, 'anything')