Skip to content

Commit 6e113e1

Browse files
Merge pull request #176 from NHSDigital/DTOSS-8794-communicate-with-mesh
[DTOSS-8794] Add testing to Communicate with MESH API
2 parents f347d01 + bc9a513 commit 6e113e1

5 files changed

Lines changed: 74 additions & 2 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
services:
2+
3+
mesh_sandbox:
4+
build:
5+
context: https://github.com/NHSDigital/mesh-sandbox.git#refs/tags/v1.0.4
6+
ports:
7+
- "8700:80"
8+
deploy:
9+
restart_policy:
10+
condition: on-failure
11+
max_attempts: 3
12+
healthcheck:
13+
test: curl -ksf https://localhost/health || exit 1
14+
interval: 3s
15+
timeout: 10s
16+
environment:
17+
- SHARED_KEY=TestKey
18+
- SSL=no
19+
- AUTH_MODE=none
20+
- STORE_MODE=canned
21+
volumes:
22+
- ./store/mailboxes.jsonl:/app/mesh_sandbox/store/data/mailboxes.jsonl:ro
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{"mailbox_id": "X26ABC1", "mailbox_name": "TESTMB1", "billing_entity": "England", "ods_code": "X26", "org_code": "X26", "password": "password"}
2+
{"mailbox_id": "X26ABC2", "mailbox_name": "TESTMB2", "billing_entity": "Wales", "ods_code": "X26", "org_code": "X26", "password": "password"}
3+
{"mailbox_id": "X26ABC3", "mailbox_name": "TESTMB3", "billing_entity": "England", "ods_code": "X27", "org_code": "X27", "password": "password"}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,31 @@
11
# Create your tests here.
2+
3+
4+
from mesh_client import MeshClient
5+
6+
base_uri = "http://localhost:8700" # Replace with your actual base URI
7+
_CANNED_MAILBOX1 = "X26ABC1"
8+
_PASSWORD = "Password"
9+
_SHARED_KEY = "Testkey"
10+
11+
12+
def test_get_file():
13+
with MeshClient(
14+
url=base_uri,
15+
mailbox=_CANNED_MAILBOX1,
16+
password=_PASSWORD,
17+
shared_key=_SHARED_KEY,
18+
) as client:
19+
client.handshake()
20+
message_ids = client.list_messages()
21+
assert len(message_ids) == 1
22+
23+
assert message_ids[0] == "SIMPLE_MESSAGE"
24+
message = client.retrieve_message(message_ids[0]).read().decode("utf-8")
25+
26+
assert message.startswith(
27+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit."
28+
)
29+
assert message.endswith(
30+
"Pellentesque eget nisi eu ex ullamcorper ultricies molestie ut lorem."
31+
)

poetry.lock

Lines changed: 18 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ dependencies = [
1616
"python-dateutil (>=2.9.0.post0,<3.0.0)",
1717
"psycopg[binary] (>=3.2.7,<4.0.0)",
1818
"azure-identity (>=1.23.0,<2.0.0)",
19+
"mesh-client (>=3.2.3,<4.0.0)",
1920
]
2021

2122
[tool.poetry]

0 commit comments

Comments
 (0)