Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile--astralinux_1_7.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ RUN apt install -y time
# RUN apt install -y netcat-traditional

RUN apt install -y git
RUN apt install -y iproute2

# --------------------------------------------- postgres
FROM base1 AS base1_with_dev_tools
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile--std-all.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ARG PYTHON_VERSION=3
# --------------------------------------------- base1
FROM postgres:${PG_VERSION}-alpine AS base1

RUN apk add --no-cache coreutils

# --------------------------------------------- base2_with_python-3
FROM base1 AS base2_with_python-3
RUN apk add --no-cache curl python3 python3-dev build-base musl-dev linux-headers
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile--std.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ARG PYTHON_VERSION=3
# --------------------------------------------- base1
FROM postgres:${PG_VERSION}-alpine AS base1

RUN apk add --no-cache coreutils

# --------------------------------------------- base2_with_python-3
FROM base1 AS base2_with_python-3
RUN apk add --no-cache curl python3 python3-dev build-base musl-dev linux-headers
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile--std2-all.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ARG PYTHON_VERSION=3.12
# --------------------------------------------- base1
FROM postgres:${PG_VERSION}-alpine AS base1

RUN apk add --no-cache coreutils

# --------------------------------------------- base2_with_python-3
FROM base1 AS base2_with_python-3
ENV PYTHON_BINARY=python3
Expand Down
1 change: 1 addition & 0 deletions Dockerfile--ubuntu_24_04.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ RUN apt install -y time
RUN apt install -y netcat-traditional

RUN apt install -y git
RUN apt install -y iproute2

RUN apt update
RUN apt install -y postgresql-common
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ dependencies = [
"six>=1.9.0",
"psutil",
"packaging",
"testgres.os_ops>=2.4.0,<3.0.0",
"testgres.os_ops>=3.1.0,<4.0.0",
]

[project.urls]
Expand Down
166 changes: 166 additions & 0 deletions tests/helpers/local_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# coding: utf-8
from .os_ops_helpers import OsOpsHelpers
from .os_ops_helpers import OsOperations

import os


class LocalCheck:
@staticmethod
def check_path_exists(
os_ops: OsOperations,
path: str,
) -> None:
assert isinstance(os_ops, OsOperations)
assert type(path) is str

if not OsOpsHelpers.is_localhost(os_ops):
return

if os.path.exists(path):
return

err_msg = "[LocalCheck] Local path [{}] does not exist.".format(
path,
)
raise RuntimeError(err_msg)

# --------------------------------------------------------------------
@staticmethod
def check_path_does_not_exists(
os_ops: OsOperations,
path: str,
) -> None:
assert isinstance(os_ops, OsOperations)
assert type(path) is str

if not OsOpsHelpers.is_localhost(os_ops):
return

if not os.path.exists(path):
return

err_msg = "[LocalCheck] Local path [{}] exists.".format(
path,
)
raise RuntimeError(err_msg)

# --------------------------------------------------------------------
@staticmethod
def check_isdir(
os_ops: OsOperations,
path: str,
) -> None:
assert isinstance(os_ops, OsOperations)
assert type(path) is str

if not OsOpsHelpers.is_localhost(os_ops):
return

if os.path.isdir(path):
return

err_msg = "[LocalCheck] Local path [{}] is not dir.".format(
path,
)
raise RuntimeError(err_msg)

# --------------------------------------------------------------------
@staticmethod
def check_not_isdir(
os_ops: OsOperations,
path: str,
) -> None:
assert isinstance(os_ops, OsOperations)
assert type(path) is str

if not OsOpsHelpers.is_localhost(os_ops):
return

if not os.path.isdir(path):
return

err_msg = "[LocalCheck] Local path [{}] is dir.".format(
path,
)
raise RuntimeError(err_msg)

# --------------------------------------------------------------------
@staticmethod
def check_isfile(
os_ops: OsOperations,
path: str,
) -> None:
assert isinstance(os_ops, OsOperations)
assert type(path) is str

if not OsOpsHelpers.is_localhost(os_ops):
return

if os.path.isfile(path):
return

err_msg = "[LocalCheck] Local path [{}] is not file.".format(
path,
)
raise RuntimeError(err_msg)

# --------------------------------------------------------------------
@staticmethod
def check_not_isfile(
os_ops: OsOperations,
path: str,
) -> None:
assert isinstance(os_ops, OsOperations)
assert type(path) is str

if not OsOpsHelpers.is_localhost(os_ops):
return

if not os.path.isfile(path):
return

err_msg = "[LocalCheck] Local path [{}] is file.".format(
path,
)
raise RuntimeError(err_msg)

# --------------------------------------------------------------------
@staticmethod
def check_path_is_abs(
os_ops: OsOperations,
path: str,
) -> None:
assert isinstance(os_ops, OsOperations)
assert type(path) is str

if not OsOpsHelpers.is_localhost(os_ops):
return

if os.path.isabs(path):
return

err_msg = "[LocalCheck] Local path [{}] is not abs.".format(
path,
)
raise RuntimeError(err_msg)

# --------------------------------------------------------------------
@staticmethod
def check_path_is_not_abs(
os_ops: OsOperations,
path: str,
) -> None:
assert isinstance(os_ops, OsOperations)
assert type(path) is str

if not OsOpsHelpers.is_localhost(os_ops):
return

if not os.path.isabs(path):
return

err_msg = "[LocalCheck] Local path [{}] is abs.".format(
path,
)
raise RuntimeError(err_msg)
18 changes: 18 additions & 0 deletions tests/helpers/os_ops_helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# coding: utf-8
from testgres.operations.local_ops import OsOperations


class OsOpsHelpers:
@staticmethod
def is_localhost(os_ops: OsOperations) -> bool:
assert isinstance(os_ops, OsOperations)

host = os_ops.host

if host == "127.0.0.1":
return True

if host == "localhost":
return True

return False
Loading