infrahub-testcontainers 1.5.0b2__tar.gz → 1.5.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (16) hide show
  1. {infrahub_testcontainers-1.5.0b2 → infrahub_testcontainers-1.5.1}/PKG-INFO +1 -1
  2. {infrahub_testcontainers-1.5.0b2 → infrahub_testcontainers-1.5.1}/infrahub_testcontainers/container.py +31 -5
  3. {infrahub_testcontainers-1.5.0b2 → infrahub_testcontainers-1.5.1}/infrahub_testcontainers/helpers.py +19 -4
  4. {infrahub_testcontainers-1.5.0b2 → infrahub_testcontainers-1.5.1}/infrahub_testcontainers/models.py +8 -6
  5. {infrahub_testcontainers-1.5.0b2 → infrahub_testcontainers-1.5.1}/infrahub_testcontainers/performance_test.py +6 -4
  6. {infrahub_testcontainers-1.5.0b2 → infrahub_testcontainers-1.5.1}/pyproject.toml +8 -2
  7. {infrahub_testcontainers-1.5.0b2 → infrahub_testcontainers-1.5.1}/README.md +0 -0
  8. {infrahub_testcontainers-1.5.0b2 → infrahub_testcontainers-1.5.1}/infrahub_testcontainers/__init__.py +0 -0
  9. {infrahub_testcontainers-1.5.0b2 → infrahub_testcontainers-1.5.1}/infrahub_testcontainers/constants.py +0 -0
  10. {infrahub_testcontainers-1.5.0b2 → infrahub_testcontainers-1.5.1}/infrahub_testcontainers/docker-compose-cluster.test.yml +0 -0
  11. {infrahub_testcontainers-1.5.0b2 → infrahub_testcontainers-1.5.1}/infrahub_testcontainers/docker-compose.test.yml +0 -0
  12. {infrahub_testcontainers-1.5.0b2 → infrahub_testcontainers-1.5.1}/infrahub_testcontainers/haproxy.cfg +0 -0
  13. {infrahub_testcontainers-1.5.0b2 → infrahub_testcontainers-1.5.1}/infrahub_testcontainers/host.py +0 -0
  14. {infrahub_testcontainers-1.5.0b2 → infrahub_testcontainers-1.5.1}/infrahub_testcontainers/measurements.py +0 -0
  15. {infrahub_testcontainers-1.5.0b2 → infrahub_testcontainers-1.5.1}/infrahub_testcontainers/plugin.py +0 -0
  16. {infrahub_testcontainers-1.5.0b2 → infrahub_testcontainers-1.5.1}/infrahub_testcontainers/prometheus.yml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: infrahub-testcontainers
3
- Version: 1.5.0b2
3
+ Version: 1.5.1
4
4
  Summary: Testcontainers instance for Infrahub to easily build integration tests
5
5
  License: Apache-2.0
6
6
  Author: OpsMill
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  import os
2
4
  import shutil
3
5
  import time
@@ -72,7 +74,10 @@ class InfrahubDockerCompose(DockerCompose):
72
74
 
73
75
  @classmethod
74
76
  def init(
75
- cls, directory: Path | None = None, version: str | None = None, deployment_type: str | None = None
77
+ cls,
78
+ directory: Path | None = None,
79
+ version: str | None = None,
80
+ deployment_type: str | None = None,
76
81
  ) -> Self:
77
82
  if not directory:
78
83
  directory = Path.cwd()
@@ -84,7 +89,11 @@ class InfrahubDockerCompose(DockerCompose):
84
89
  if version == "local" and infrahub_image_version:
85
90
  version = infrahub_image_version
86
91
 
87
- compose = cls(project_name=cls.generate_project_name(), context=directory, deployment_type=deployment_type)
92
+ compose = cls(
93
+ project_name=cls.generate_project_name(),
94
+ context=directory,
95
+ deployment_type=deployment_type,
96
+ )
88
97
  compose.create_docker_file(directory=directory)
89
98
  compose.create_env_file(directory=directory, version=version)
90
99
 
@@ -240,7 +249,10 @@ class InfrahubDockerCompose(DockerCompose):
240
249
  }
241
250
 
242
251
  def database_create_backup(
243
- self, backup_name: str = "neo4j_database.backup", dest_dir: Path | None = None, compress: bool = False
252
+ self,
253
+ backup_name: str = "neo4j_database.backup",
254
+ dest_dir: Path | None = None,
255
+ compress: bool = False,
244
256
  ) -> None:
245
257
  assert self.use_neo4j_enterprise
246
258
 
@@ -283,7 +295,14 @@ class InfrahubDockerCompose(DockerCompose):
283
295
  self.start_container(service_name=service_name)
284
296
 
285
297
  self.exec_in_container(
286
- command=["cypher-shell", "-u", "neo4j", "-p", "admin", "STOP DATABASE neo4j;"],
298
+ command=[
299
+ "cypher-shell",
300
+ "-u",
301
+ "neo4j",
302
+ "-p",
303
+ "admin",
304
+ "STOP DATABASE neo4j;",
305
+ ],
287
306
  service_name=service_name,
288
307
  )
289
308
 
@@ -368,7 +387,14 @@ class InfrahubDockerCompose(DockerCompose):
368
387
  time.sleep(10)
369
388
 
370
389
  self.exec_in_container(
371
- command=["cypher-shell", "-u", "neo4j", "-p", "admin", "DROP DATABASE neo4j;"],
390
+ command=[
391
+ "cypher-shell",
392
+ "-u",
393
+ "neo4j",
394
+ "-p",
395
+ "admin",
396
+ "DROP DATABASE neo4j;",
397
+ ],
372
398
  service_name=service_name,
373
399
  )
374
400
 
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  import os
2
4
  import subprocess # noqa: S404
3
5
  import uuid
@@ -24,13 +26,21 @@ class TestInfrahubDocker:
24
26
  env["INFRAHUB_API_TOKEN"] = PROJECT_ENV_VARIABLES["INFRAHUB_TESTING_INITIAL_ADMIN_TOKEN"]
25
27
  env["INFRAHUB_MAX_CONCURRENT_EXECUTION"] = "1"
26
28
  result = subprocess.run( # noqa: S602
27
- f"infrahubctl run {script}", shell=True, capture_output=True, text=True, env=env, check=False
29
+ f"infrahubctl run {script}",
30
+ shell=True,
31
+ capture_output=True,
32
+ text=True,
33
+ env=env,
34
+ check=False,
28
35
  )
29
36
  return result.stdout
30
37
 
31
38
  @staticmethod
32
39
  def execute_command(
33
- command: str, address: str, concurrent_execution: int = 10, pagination_size: int = 50
40
+ command: str,
41
+ address: str,
42
+ concurrent_execution: int = 10,
43
+ pagination_size: int = 50,
34
44
  ) -> subprocess.CompletedProcess[str]:
35
45
  env = os.environ.copy()
36
46
  env["INFRAHUB_ADDRESS"] = address
@@ -79,7 +89,9 @@ class TestInfrahubDocker:
79
89
  deployment_type: str | None,
80
90
  ) -> InfrahubDockerCompose:
81
91
  return InfrahubDockerCompose.init(
82
- directory=tmp_directory, version=infrahub_version, deployment_type=deployment_type
92
+ directory=tmp_directory,
93
+ version=infrahub_version,
94
+ deployment_type=deployment_type,
83
95
  )
84
96
 
85
97
  @pytest.fixture(scope="class")
@@ -90,7 +102,10 @@ class TestInfrahubDocker:
90
102
  tests_failed_during_class = request.session.testsfailed - tests_failed_before_class
91
103
  if tests_failed_during_class > 0:
92
104
  stdout, stderr = infrahub_compose.get_logs("infrahub-server", "task-worker")
93
- warnings.warn(f"Container logs:\nStdout:\n{stdout}\nStderr:\n{stderr}", stacklevel=2)
105
+ warnings.warn(
106
+ f"Container logs:\nStdout:\n{stdout}\nStderr:\n{stderr}",
107
+ stacklevel=2,
108
+ )
94
109
  infrahub_compose.stop()
95
110
 
96
111
  request.addfinalizer(cleanup)
@@ -1,6 +1,8 @@
1
- from datetime import UTC, datetime
1
+ from __future__ import annotations
2
+
3
+ from datetime import datetime, timezone
2
4
  from enum import Enum
3
- from typing import Any
5
+ from typing import Any, Union
4
6
 
5
7
  from pydantic import BaseModel, Field
6
8
 
@@ -15,24 +17,24 @@ class ContextUnit(str, Enum):
15
17
  class MeasurementDefinition(BaseModel):
16
18
  name: str
17
19
  description: str
18
- dimensions: list[str] = Field(default_factory=dict)
20
+ dimensions: list[str] = Field(default_factory=list)
19
21
  unit: ContextUnit
20
22
 
21
23
 
22
24
  class InfrahubResultContext(BaseModel):
23
25
  name: str
24
- value: int | float | str
26
+ value: Union[int, float, str]
25
27
  unit: ContextUnit
26
28
 
27
29
 
28
30
  class InfrahubActiveMeasurementItem(BaseModel):
29
31
  definition: MeasurementDefinition
30
- start_time: datetime = Field(default_factory=lambda: datetime.now(UTC))
32
+ start_time: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
31
33
  context: dict[str, Any] = Field(default_factory=dict)
32
34
 
33
35
 
34
36
  class InfrahubMeasurementItem(BaseModel):
35
37
  name: str
36
- value: int | float | str
38
+ value: Union[int, float, str]
37
39
  unit: ContextUnit
38
40
  context: dict[str, Any] = Field(default_factory=dict)
@@ -1,6 +1,8 @@
1
+ from __future__ import annotations
2
+
1
3
  import hashlib
2
4
  import json
3
- from datetime import UTC, datetime
5
+ from datetime import datetime, timezone
4
6
  from types import TracebackType
5
7
  from typing import Any
6
8
 
@@ -35,7 +37,7 @@ class InfrahubPerformanceTest:
35
37
  self.env_vars = {}
36
38
  self.project_name = ""
37
39
  self.test_info = {}
38
- self.start_time = datetime.now(UTC)
40
+ self.start_time = datetime.now(timezone.utc)
39
41
  self.end_time: datetime | None = None
40
42
  self.results_url = results_url
41
43
  self.scraper_endpoint = ""
@@ -57,7 +59,7 @@ class InfrahubPerformanceTest:
57
59
 
58
60
  def finalize(self, session: pytest.Session) -> None:
59
61
  if self.initialized:
60
- self.end_time = datetime.now(UTC)
62
+ self.end_time = datetime.now(timezone.utc)
61
63
  self.extract_test_session_information(session)
62
64
  self.send_results()
63
65
 
@@ -129,7 +131,7 @@ class InfrahubPerformanceTest:
129
131
  if not exc_type and self.active_measurements:
130
132
  self.add_measurement(
131
133
  definition=self.active_measurements.definition,
132
- value=(datetime.now(UTC) - self.active_measurements.start_time).total_seconds() * 1000,
134
+ value=(datetime.now(timezone.utc) - self.active_measurements.start_time).total_seconds() * 1000,
133
135
  context=self.active_measurements.context,
134
136
  )
135
137
 
@@ -1,11 +1,11 @@
1
1
  [project]
2
2
  name = "infrahub-testcontainers"
3
- version = "1.5.0b2"
3
+ version = "1.5.1"
4
4
  requires-python = ">=3.9"
5
5
 
6
6
  [tool.poetry]
7
7
  name = "infrahub-testcontainers"
8
- version = "1.5.0b2"
8
+ version = "1.5.1"
9
9
  description = "Testcontainers instance for Infrahub to easily build integration tests"
10
10
  authors = ["OpsMill <info@opsmill.com>"]
11
11
  readme = "README.md"
@@ -43,3 +43,9 @@ prefect-client = "3.4.23"
43
43
 
44
44
  [tool.poetry.group.dev.dependencies]
45
45
  rich = "^13.9.4"
46
+ pytest-cov = "7.0.0"
47
+ pytest-xdist = "~3.4"
48
+
49
+ [tool.ruff]
50
+ line-length = 120
51
+ target-version = "py39"