Skip to content

Commit 7dfacbc

Browse files
committedJul 26, 2024
add rabbitMQ in docker-compose
1 parent 34a2698 commit 7dfacbc

File tree

3 files changed

+60
-3
lines changed

3 files changed

+60
-3
lines changed
 

‎docker-compose.yaml

+23
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,26 @@ services:
22
sync:
33
build: .
44
command: ['pytest', 'tests', '-p', 'no:cacheprovider']
5+
environment:
6+
- RABBITMQ=true
7+
depends_on:
8+
pulse:
9+
condition: service_healthy
10+
networks:
11+
- pulse_network
12+
13+
pulse:
14+
image: rabbitmq:3-management-alpine
15+
healthcheck:
16+
test: rabbitmq-diagnostics -q ping
17+
interval: 5s
18+
timeout: 2s
19+
retries: 1
20+
ports:
21+
- 15672:15672
22+
networks:
23+
- pulse_network
24+
25+
networks:
26+
pulse_network:
27+
driver: bridge

‎tests/pulse_utils.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
HERE = Path(__file__).parent
99

1010

11-
def send_pulse_message(pulse_config, payload):
11+
def send_pulse_message(pulse_config, payload, ssl=True):
1212
"""Send a pulse message
1313
The routing key will be constructed from the repository URL.
1414
The Pulse message will be constructed from the specified payload
@@ -29,7 +29,7 @@ def send_pulse_message(pulse_config, payload):
2929
userid=userid,
3030
password=password,
3131
connect_timeout=100,
32-
ssl=True,
32+
ssl=ssl,
3333
)
3434
connection.connect()
3535

@@ -55,7 +55,7 @@ def send_pulse_message(pulse_config, payload):
5555
"exchange": exchange,
5656
"routing_key": routing_key,
5757
"serializer": "json",
58-
"sent": datetime.utcnow().isoformat(),
58+
"sent": datetime.now(),
5959
},
6060
}
6161

‎tests/test_integration.py

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import os
2+
import pytest
3+
4+
import pulse_utils
5+
6+
NO_RABBITMQ = not (os.getenv("RABBITMQ") == "true")
7+
8+
9+
@pytest.fixture
10+
def pulse_config():
11+
return {
12+
"userid": "guest",
13+
"host": "pulse",
14+
"port": 5672,
15+
"exchange": "exchange/guest/test",
16+
"routing_key": "#",
17+
"queue": "queue/guest/test",
18+
"password": "guest",
19+
}
20+
21+
22+
@pytest.mark.skipif(NO_RABBITMQ, reason="Test doesn't work without rabbitMq")
23+
def test_send(pulse_config):
24+
payload = {
25+
"type": "tag",
26+
"repo_url": "repo.git",
27+
"tag": "Tag",
28+
"commit": "sha",
29+
"time": 0,
30+
"pushid": 0,
31+
"user": "user",
32+
"push_json_url": "push_json_url",
33+
}
34+
pulse_utils.send_pulse_message(pulse_config, payload, ssl=False)

0 commit comments

Comments
 (0)
Failed to load comments.