Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock file maintenance Python dependencies #465

Merged
merged 2 commits into from
Jun 4, 2024
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
600 changes: 300 additions & 300 deletions poetry.lock

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ repository = "https://github.com/canonical/postgresql-k8s-operator"
[tool.poetry.dependencies]
python = "^3.10"
ops = "^2.12.0"
cryptography = "^42.0.5"
boto3 = "^1.34.95"
cryptography = "^42.0.7"
boto3 = "^1.34.118"
pgconnstr = "^1.0.1"
requests = "^2.31.0"
tenacity = "^8.2.3"
requests = "^2.32.3"
tenacity = "^8.3.0"
cosl = "^0.0.11"
pydantic = "^1.10.15"
poetry-core = "^1.9.0"
jsonschema = "^4.22.0"
jinja2 = "^3.1.3"
jinja2 = "^3.1.4"
lightkube = "^0.15.2"
lightkube-models = "^1.28.1.4"
psycopg2 = "^2.9.9"
Expand All @@ -43,21 +43,21 @@ cosl = "*"
optional = true

[tool.poetry.group.format.dependencies]
ruff = "^0.4.2"
ruff = "^0.4.7"

[tool.poetry.group.lint]
optional = true

[tool.poetry.group.lint.dependencies]
codespell = "^2.2.6"
codespell = "^2.3.0"

[tool.poetry.group.unit]
optional = true

[tool.poetry.group.unit.dependencies]
coverage = {extras = ["toml"], version = "^7.5.0"}
coverage = {extras = ["toml"], version = "^7.5.3"}
pydantic = "^1.10.15"
pytest = "^8.2.0"
pytest = "^8.2.2"
pytest-mock = "^3.14.0"
pytest-asyncio = "*"
parameterized = "^0.9.0"
Expand All @@ -67,16 +67,16 @@ optional = true

[tool.poetry.group.integration.dependencies]
lightkube = "^0.15.2"
pytest = "^8.2.0"
pytest = "^8.2.2"
pytest-github-secrets = {git = "https://github.com/canonical/data-platform-workflows", tag = "v13.1.1", subdirectory = "python/pytest_plugins/github_secrets"}
pytest-operator = "^0.35.0"
pytest-operator-cache = {git = "https://github.com/canonical/data-platform-workflows", tag = "v13.1.1", subdirectory = "python/pytest_plugins/pytest_operator_cache"}
pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v13.1.1", subdirectory = "python/pytest_plugins/pytest_operator_groups"}
# renovate caret doesn't work: https://github.com/renovatebot/renovate/issues/26940
juju = "<=3.4.0.0"
juju = "<=3.5.0.0"
psycopg2-binary = "^2.9.9"
boto3 = "^1.34.95"
tenacity = "^8.2.3"
boto3 = "^1.34.118"
tenacity = "^8.3.0"
allure-pytest = "^2.13.5"

[build-system]
Expand Down
29 changes: 14 additions & 15 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_on_leader_elected(harness):
Endpoints, name=f"patroni-{harness.charm.app.name}", namespace=harness.charm.model.name
)
_client.return_value.patch.assert_not_called()
tc.assertIn("cluster_initialised", harness.get_relation_data(rel_id, harness.charm.app))
assert "cluster_initialised" in harness.get_relation_data(rel_id, harness.charm.app)

# Trigger a new leader election and check that the password is still the same, and that the charm
# fixes the missing "leader" key in the endpoint annotations.
Expand Down Expand Up @@ -397,8 +397,9 @@ def test_on_update_status_with_error_on_get_primary(harness):

with tc.assertLogs("charm", "ERROR") as logs:
harness.charm.on.update_status.emit()
tc.assertIn(
"ERROR:charm:failed to get primary with error RetryError[fake error]", logs.output
assert (
"ERROR:charm:failed to get primary with error RetryError[fake error]"
in logs.output
)


Expand Down Expand Up @@ -694,7 +695,7 @@ def test_on_stop(harness):
)
_client.return_value.list.assert_not_called()
_client.return_value.apply.assert_not_called()
tc.assertIn("failed to get first pod info", "".join(logs.output))
assert "failed to get first pod info" in "".join(logs.output)

# Test when the charm fails to get the k8s resources created by the charm and Patroni.
_client.return_value.get.side_effect = None
Expand All @@ -708,9 +709,8 @@ def test_on_stop(harness):
labels={"app.juju.is/created-by": harness.charm.app.name},
)
_client.return_value.apply.assert_not_called()
tc.assertIn(
"failed to get the k8s resources created by the charm and Patroni",
"".join(logs.output),
assert "failed to get the k8s resources created by the charm and Patroni" in "".join(
logs.output
)

# Test when the charm fails to patch a k8s resource.
Expand All @@ -724,8 +724,8 @@ def test_on_stop(harness):
_client.return_value.apply.side_effect = [None, _FakeApiError]
with tc.assertLogs("charm", "ERROR") as logs:
harness.charm.on.stop.emit()
tc.assertEqual(_client.return_value.apply.call_count, 2)
tc.assertIn("failed to patch k8s MagicMock", "".join(logs.output))
assert _client.return_value.apply.call_count == 2
assert "failed to patch k8s MagicMock" in "".join(logs.output)


def test_client_relations(harness):
Expand Down Expand Up @@ -1433,11 +1433,10 @@ def test_handle_postgresql_restart_need(harness):

harness.charm._handle_postgresql_restart_need()
_reload_patroni_configuration.assert_called_once()
(
tc.assertIn("tls", harness.get_relation_data(rel_id, harness.charm.unit))
if values[0]
else tc.assertNotIn("tls", harness.get_relation_data(rel_id, harness.charm.unit))
)
if values[0]:
assert "tls" in harness.get_relation_data(rel_id, harness.charm.unit)
else:
assert "tls" not in harness.get_relation_data(rel_id, harness.charm.unit)
if (values[0] != values[1]) or values[2]:
_generate_metrics_jobs.assert_called_once_with(values[0])
_restart.assert_called_once()
Expand Down Expand Up @@ -1501,4 +1500,4 @@ def test_set_active_status(harness):
_get_primary.side_effect = values[0]
_get_primary.return_value = None
harness.charm._set_active_status()
tc.assertIsInstance(harness.charm.unit.status, MaintenanceStatus)
assert isinstance(harness.charm.unit.status, MaintenanceStatus)
2 changes: 1 addition & 1 deletion tests/unit/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def test_on_relation_departed(harness):
event.relation.data = {harness.charm.app: {}, harness.charm.unit: {}}
event.departing_unit = harness.charm.unit
harness.charm.legacy_db_relation._on_relation_departed(event)
tc.assertIn("departing", harness.get_relation_data(peer_rel_id, harness.charm.unit))
assert "departing" in harness.get_relation_data(peer_rel_id, harness.charm.unit)

# Test when this unit is departing the relation (due to the relation being broken between the apps).
with harness.hooks_disabled():
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_patroni.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@ def test_render_patroni_yml_file(harness, patroni):

# Also, ensure the right parameters are in the expected content
# (as it was already validated with the above render file call).
tc.assertIn("ssl: on", expected_content_with_tls)
tc.assertIn("ssl_ca_file: /var/lib/postgresql/data/ca.pem", expected_content_with_tls)
tc.assertIn("ssl_cert_file: /var/lib/postgresql/data/cert.pem", expected_content_with_tls)
tc.assertIn("ssl_key_file: /var/lib/postgresql/data/key.pem", expected_content_with_tls)
assert "ssl: on" in expected_content_with_tls
assert "ssl_ca_file: /var/lib/postgresql/data/ca.pem" in expected_content_with_tls
assert "ssl_cert_file: /var/lib/postgresql/data/cert.pem" in expected_content_with_tls
assert "ssl_key_file: /var/lib/postgresql/data/key.pem" in expected_content_with_tls


def test_primary_endpoint_ready(harness, patroni):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_postgresql_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def test_on_relation_departed(harness):
event.relation.data = {harness.charm.app: {}, harness.charm.unit: {}}
event.departing_unit = harness.charm.unit
harness.charm.postgresql_client_relation._on_relation_departed(event)
tc.assertIn("departing", harness.get_relation_data(peer_rel_id, harness.charm.unit))
assert "departing" in harness.get_relation_data(peer_rel_id, harness.charm.unit)

# Test when this unit is departing the relation (due to the relation being broken between the apps).
with harness.hooks_disabled():
Expand Down
Loading