pyrelukko 0.2.0__py3-none-any.whl → 0.3.0__py3-none-any.whl

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.

Potentially problematic release.


This version of pyrelukko might be problematic. Click here for more details.

pyrelukko/pyrelukko.py CHANGED
@@ -151,7 +151,7 @@ class RelukkoClient:
151
151
 
152
152
  def _setup_ws_url(self, ws_url: str) -> Url:
153
153
  url = ws_url.replace("http", "ws", 1)
154
- return parse_url(f"{url}/deletions")
154
+ return parse_url(f"{url}/ws/broadcast")
155
155
 
156
156
  def _setup_base_url(self, base_url: Union[Url, str]) -> Url:
157
157
  if isinstance(base_url, str):
@@ -0,0 +1,90 @@
1
+ # pylint: skip-file
2
+ """
3
+ Testcontainers to be used in PyTests, for a fixture see tests/conftest.py
4
+ (relukko_backend):
5
+
6
+ @pytest.fixture(scope="session")
7
+ def relukko_backend():
8
+ with Network() as rl_net:
9
+ with RelukkoDbContainer(net=rl_net, initdb_dir=INITDB_DIR,
10
+ image="postgres:16", hostname="relukkodb") as _db:
11
+ db_url = "postgresql://relukko:relukko@relukkodb/relukko"
12
+ with RelukkoContainer(rl_net, db_url=db_url) as backend:
13
+ relukko = RelukkoClient(
14
+ base_url=backend.get_api_url(), api_key="somekey")
15
+ yield relukko, backend
16
+ """
17
+ import socket
18
+ from pathlib import Path
19
+
20
+ from testcontainers.core.network import Network
21
+ from testcontainers.core.waiting_utils import wait_container_is_ready
22
+ from testcontainers.generic import ServerContainer
23
+ from testcontainers.postgres import PostgresContainer
24
+
25
+
26
+ class RelukkoContainer(ServerContainer):
27
+ def __init__(self, net: Network,
28
+ image="registry.gitlab.com/relukko/relukko:0.10.0", db_url=None):
29
+ self.db_url = db_url
30
+ self.net = net
31
+ super(RelukkoContainer, self).__init__(image=image, port=3000)
32
+
33
+ def _configure(self):
34
+ self.with_env("DATABASE_URL", self.db_url)
35
+ self.with_env("RELUKKO_API_KEY", "somekey")
36
+ self.with_env("RELUKKO_USER", "relukko")
37
+ self.with_env("RELUKKO_PASSWORD", "relukko")
38
+ self.with_env("RELUKKO_BIND_ADDR", "0.0.0.0")
39
+ self.with_network(self.net)
40
+
41
+ def get_api_url(self) -> str:
42
+ return f"http://localhost:{self.get_exposed_port(3000)}"
43
+
44
+ def _create_connection_url(self) -> str:
45
+ return f"{self.get_api_url()}/healthchecker"
46
+
47
+
48
+ class RelukkoDbContainer(PostgresContainer):
49
+ def __init__(
50
+ self, net: Network,
51
+ initdb_dir: Path,
52
+ image: str = "postgres:latest",
53
+ port: int = 5432,
54
+ username: str | None = None,
55
+ password: str | None = None,
56
+ dbname: str | None = None,
57
+ driver: str | None = "psycopg2",
58
+ **kwargs) -> None:
59
+ self.net = net
60
+ self.initdb_dir = initdb_dir
61
+ super().__init__(image, port, username, password, dbname, driver, **kwargs)
62
+
63
+ def _configure(self) -> None:
64
+ self.with_volume_mapping(self.initdb_dir, "/docker-entrypoint-initdb.d", "Z")
65
+ self.with_env("POSTGRES_USER", "relukko")
66
+ self.with_env("POSTGRES_PASSWORD", "relukko")
67
+ self.with_env("POSTGRES_DB", "relukko")
68
+ self.with_network(self.net)
69
+
70
+ @wait_container_is_ready()
71
+ def _connect(self) -> None:
72
+ packet = bytes([
73
+ 0x00, 0x00, 0x00, 0x52, 0x00, 0x03, 0x00, 0x00,
74
+ 0x75, 0x73, 0x65, 0x72, 0x00, 0x72, 0x65, 0x6c,
75
+ 0x75, 0x6b, 0x6b, 0x6f, 0x00, 0x64, 0x61, 0x74,
76
+ 0x61, 0x62, 0x61, 0x73, 0x65, 0x00, 0x72, 0x65,
77
+ 0x6c, 0x75, 0x6b, 0x6b, 0x6f, 0x00, 0x61, 0x70,
78
+ 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f,
79
+ 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x00, 0x70,
80
+ 0x73, 0x71, 0x6c, 0x00, 0x63, 0x6c, 0x69, 0x65,
81
+ 0x6e, 0x74, 0x5f, 0x65, 0x6e, 0x63, 0x6f, 0x64,
82
+ 0x69, 0x6e, 0x67, 0x00, 0x55, 0x54, 0x46, 0x38,
83
+ 0x00, 0x00
84
+ ])
85
+ port = self.get_exposed_port(self.port)
86
+ with socket.create_connection(("localhost", port)) as sock:
87
+ sock.send(packet)
88
+ buf = sock.recv(40)
89
+ if len(buf) == 0 and "SCRAM-SHA" not in buf:
90
+ raise ConnectionError
pyrelukko/version.py CHANGED
@@ -1,2 +1,2 @@
1
1
  # pylint: disable=all
2
- __version__ = "0.2.0"
2
+ __version__ = "0.3.0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pyrelukko
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Relukko client.
5
5
  Author-email: Reto Zingg <g.d0b3rm4n@gmail.com>
6
6
  Requires-Python: >=3.12
@@ -11,6 +11,7 @@ Classifier: License :: OSI Approved :: MIT License
11
11
  Classifier: Topic :: Internet :: WWW/HTTP
12
12
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
13
13
  Requires-Dist: requests >=2.32.3
14
+ Requires-Dist: websockets >= 13.1
14
15
  Project-URL: Homepage, https://gitlab.com/relukko/pyrelukko
15
16
  Project-URL: Issues, https://gitlab.com/relukko/pyrelukko/-/issues
16
17
 
@@ -0,0 +1,9 @@
1
+ pyrelukko/__init__.py,sha256=n-mTJV7AOfr4bljtDxok3E3gXIBRk-kFa2_Ql3S8Ht0,61
2
+ pyrelukko/pyrelukko.py,sha256=bQDyQOWtsUznSXwdXRLg6Pg6EFomTgRzhlX4jOzHqdI,11438
3
+ pyrelukko/retry.py,sha256=XeCc0trPhAggdEnu2nwtpFderlHaDQFTXH_O1dLeiGQ,1587
4
+ pyrelukko/testcontainers.py,sha256=sJluMF9ImcQDGTB0w6s4ySCzOY5S9OKTpWQ8XQp05Y8,3555
5
+ pyrelukko/version.py,sha256=NnZOmpocvSUCHLODp9u2VznENpXTvQOdCMjMjqqNyf0,44
6
+ pyrelukko-0.3.0.dist-info/LICENSE,sha256=aEI4dThWmRUiEPch0-KaZQmHZgTyuz88Edmp25H6tAw,1089
7
+ pyrelukko-0.3.0.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
8
+ pyrelukko-0.3.0.dist-info/METADATA,sha256=C8SUSQrskczP10ooDzTUYW22z4sS4g1fv2uUlnWsb3k,735
9
+ pyrelukko-0.3.0.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- pyrelukko/__init__.py,sha256=n-mTJV7AOfr4bljtDxok3E3gXIBRk-kFa2_Ql3S8Ht0,61
2
- pyrelukko/pyrelukko.py,sha256=5bDqueUMxbMSxbuSOE9L7aHpAP3bax4DHQqATeuHs1s,11435
3
- pyrelukko/retry.py,sha256=XeCc0trPhAggdEnu2nwtpFderlHaDQFTXH_O1dLeiGQ,1587
4
- pyrelukko/version.py,sha256=5ajVDlNTAW-Ykqh9HwJkug5LWeNtanZQhZox4hNtxio,44
5
- pyrelukko-0.2.0.dist-info/LICENSE,sha256=aEI4dThWmRUiEPch0-KaZQmHZgTyuz88Edmp25H6tAw,1089
6
- pyrelukko-0.2.0.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
7
- pyrelukko-0.2.0.dist-info/METADATA,sha256=0tOto4sHXUD_sFAfTvC6EhV2l4NER-gNyYE66ori8TQ,701
8
- pyrelukko-0.2.0.dist-info/RECORD,,