-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1791 from DSD-DBS/check-capella-version-for-linke…
…d-repos feat: Verify compatibility of TeamForCapella model links at all times
- Loading branch information
Showing
39 changed files
with
1,096 additions
and
526 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
backend/capellacollab/projects/toolmodels/modelsources/t4c/util.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from capellacollab.settings.modelsources.t4c.repositories import ( | ||
models as t4c_repository_models, | ||
) | ||
from capellacollab.tools import models as tools_models | ||
|
||
from . import exceptions | ||
|
||
|
||
def verify_compatibility_of_model_and_server( | ||
model_name: str, | ||
model_version: tools_models.DatabaseVersion | None, | ||
t4c_repository: t4c_repository_models.DatabaseT4CRepository, | ||
): | ||
server = t4c_repository.instance | ||
if model_version is None: | ||
raise exceptions.T4CIntegrationVersionRequired(model_name) | ||
|
||
if ( | ||
t4c_repository.instance.version.id | ||
not in model_version.config.compatible_versions + [model_version.id] | ||
): | ||
raise exceptions.T4CIntegrationWrongCapellaVersion( | ||
server.name, | ||
t4c_repository.name, | ||
server.version.name, | ||
server.version.id, | ||
model_version.name, | ||
model_version.id, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
backend/tests/projects/toolmodels/modelsources/fixtures.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import pytest | ||
from sqlalchemy import orm | ||
|
||
import capellacollab.projects.toolmodels.models as toolmodels_models | ||
import capellacollab.projects.toolmodels.modelsources.git.crud as project_git_crud | ||
import capellacollab.projects.toolmodels.modelsources.git.models as project_git_models | ||
import capellacollab.projects.toolmodels.modelsources.t4c.crud as models_t4c_crud | ||
import capellacollab.projects.toolmodels.modelsources.t4c.models as models_t4c_models | ||
import capellacollab.settings.modelsources.t4c.repositories.models as settings_t4c_repositories_models | ||
|
||
|
||
@pytest.fixture(name="t4c_model") | ||
def fixture_t4c_model( | ||
db: orm.Session, | ||
capella_model: toolmodels_models.DatabaseToolModel, | ||
t4c_repository: settings_t4c_repositories_models.DatabaseT4CRepository, | ||
) -> models_t4c_models.DatabaseT4CModel: | ||
return models_t4c_crud.create_t4c_model( | ||
db, capella_model, t4c_repository, "default" | ||
) | ||
|
||
|
||
@pytest.fixture(name="git_model") | ||
def fixture_git_model( | ||
db: orm.Session, capella_model: toolmodels_models.DatabaseToolModel | ||
) -> project_git_models.DatabaseGitModel: | ||
git_model = project_git_models.PostGitModel( | ||
path="https://example.com/test/project", | ||
entrypoint="test/test.aird", | ||
revision="main", | ||
username="user", | ||
password="password", | ||
) | ||
return project_git_crud.add_git_model_to_capellamodel( | ||
db, capella_model, git_model | ||
) |
Oops, something went wrong.