Skip to content

Commit

Permalink
Fixed mypy for Python 3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
ckunki committed Oct 21, 2024
1 parent 1fb1219 commit 90df9a0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
5 changes: 3 additions & 2 deletions exasol/nb_connector/itde_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ def restart_itde(conf: Secrets) -> None:
if status is ItdeContainerStatus.ABSENT:
raise RuntimeError("The Docker-DB container doesn't exist.")

if ItdeContainerStatus.RUNNING not in status:
if ItdeContainerStatus.RUNNING not in status: # type: ignore[operator]
container_name = conf.get(AILabConfig.itde_container)
with ContextDockerClient() as docker_client:
container = docker_client.containers.get(container_name)
container.start()

if ItdeContainerStatus.VISIBLE not in status:
if not ItdeContainerStatus.VISIBLE not in status: # type: ignore[operator]
network_name = conf.get(AILabConfig.itde_network)
if network_name:
_add_current_container_to_db_network(network_name)
Expand Down Expand Up @@ -272,3 +272,4 @@ def remove_container(conf):
if container_name:
remove_docker_container([container_name])
conf.remove(AILabConfig.itde_container)

35 changes: 35 additions & 0 deletions test/unit/test_itde_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
NAME_SERVER_ADDRESS,
bring_itde_up,
take_itde_down,
ItdeContainerStatus,
)

TEST_CONTAINER_NAME = "the_new_container"
Expand Down Expand Up @@ -106,3 +107,37 @@ def test_take_itde_down(mock_util1, mock_util2, mock_util3, secrets):
assert secrets.get(CKey.bfs_user) is None
assert secrets.get(CKey.bfs_password) is None
assert secrets.get(CKey.bfs_port) is None


@pytest.mark.parametrize("status", [
ItdeContainerStatus.RUNNING,
ItdeContainerStatus.READY,
])
def test_status_running(status):
assert ItdeContainerStatus.RUNNING in status


@pytest.mark.parametrize("status", [
ItdeContainerStatus.ABSENT,
ItdeContainerStatus.STOPPED,
ItdeContainerStatus.VISIBLE,
])
def test_status_not_running(status):
assert ItdeContainerStatus.RUNNING not in status


@pytest.mark.parametrize("status", [
ItdeContainerStatus.VISIBLE,
ItdeContainerStatus.READY,
])
def test_status_visible(status):
assert ItdeContainerStatus.VISIBLE in status


@pytest.mark.parametrize("status", [
ItdeContainerStatus.ABSENT,
ItdeContainerStatus.STOPPED,
ItdeContainerStatus.RUNNING,
])
def test_status_not_visible(status):
assert ItdeContainerStatus.VISIBLE not in status

0 comments on commit 90df9a0

Please sign in to comment.