3 files changed +60
-3
lines changed Original file line number Diff line number Diff line change @@ -2,3 +2,26 @@ services:
2
2
sync :
3
3
build : .
4
4
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
Original file line number Diff line number Diff line change 8
8
HERE = Path (__file__ ).parent
9
9
10
10
11
- def send_pulse_message (pulse_config , payload ):
11
+ def send_pulse_message (pulse_config , payload , ssl = True ):
12
12
"""Send a pulse message
13
13
The routing key will be constructed from the repository URL.
14
14
The Pulse message will be constructed from the specified payload
@@ -29,7 +29,7 @@ def send_pulse_message(pulse_config, payload):
29
29
userid = userid ,
30
30
password = password ,
31
31
connect_timeout = 100 ,
32
- ssl = True ,
32
+ ssl = ssl ,
33
33
)
34
34
connection .connect ()
35
35
@@ -55,7 +55,7 @@ def send_pulse_message(pulse_config, payload):
55
55
"exchange" : exchange ,
56
56
"routing_key" : routing_key ,
57
57
"serializer" : "json" ,
58
- "sent" : datetime .utcnow (). isoformat (),
58
+ "sent" : datetime .now (),
59
59
},
60
60
}
61
61
Original file line number Diff line number Diff line change
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