Skip to content

Commit

Permalink
feat: test dao get_deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
SteBaum committed Jun 7, 2024
1 parent f824224 commit 34d18cb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tdp/core/models/deployment_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ def __str__(self):
tablefmt="plain",
)

def __eq__(self, other):
if isinstance(other, DeploymentModel):
return (
self.id == other.id
and self.options == other.options
and self.start_time == other.start_time
and self.end_time == other.end_time
and self.state == other.state
and self.deployment_type == other.deployment_type
and self.operations == other.operations
)

@staticmethod
def from_dag(
dag: Dag,
Expand Down
26 changes: 26 additions & 0 deletions tdp/test_dao.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2022 TOSIT.IO
# SPDX-License-Identifier: Apache-2.0

import pytest

from tdp.conftest import create_session
from tdp.core.models.deployment_model import DeploymentModel
from tdp.core.models.enums import DeploymentStateEnum
from tdp.dao import Dao


@pytest.mark.parametrize("db_engine", [True], indirect=True)
def test_get_deployment(db_engine):
with create_session(db_engine) as session:
session.add(
DeploymentModel(
id=1,
state=DeploymentStateEnum.RUNNING,
)
)
session.commit()
with Dao(db_engine) as dao:
assert dao.get_deployment(1) == DeploymentModel(
id=1,
state=DeploymentStateEnum.RUNNING,
)

0 comments on commit 34d18cb

Please sign in to comment.