5 files changed +67
-6
lines changed Original file line number Diff line number Diff line change 1
1
clones
2
2
.tox
3
3
** /__pycache__ /
4
- config.ini
4
+ config.toml
5
5
.coverage
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
1
+ import sys
1
2
from datetime import datetime
2
3
from pathlib import Path
3
- import sys
4
4
5
5
import kombu
6
6
9
9
HERE = Path (__file__ ).parent
10
10
11
11
12
- def send_pulse_message (pulse_config , payload ):
12
+ def send_pulse_message (pulse_config , payload , ssl = True ):
13
13
"""Send a pulse message
14
14
The routing key will be constructed from the repository URL.
15
15
The Pulse message will be constructed from the specified payload
@@ -30,7 +30,7 @@ def send_pulse_message(pulse_config, payload):
30
30
userid = userid ,
31
31
password = password ,
32
32
connect_timeout = 100 ,
33
- ssl = True ,
33
+ ssl = ssl ,
34
34
)
35
35
connection .connect ()
36
36
@@ -56,7 +56,7 @@ def send_pulse_message(pulse_config, payload):
56
56
"exchange" : exchange ,
57
57
"routing_key" : routing_key ,
58
58
"serializer" : "json" ,
59
- "sent" : datetime .utcnow (). isoformat (),
59
+ "sent" : datetime .now (),
60
60
},
61
61
}
62
62
Original file line number Diff line number Diff line change
1
+ import os
2
+
3
+ import pulse_utils
4
+ import pytest
5
+
6
+ from git_hg_sync .config import PulseConfig
7
+
8
+ NO_RABBITMQ = not (os .getenv ("RABBITMQ" ) == "true" )
9
+
10
+
11
+ @pytest .fixture
12
+ def pulse_config ():
13
+ return PulseConfig (
14
+ ** {
15
+ "userid" : "guest" ,
16
+ "host" : "pulse" ,
17
+ "port" : 5672 ,
18
+ "exchange" : "exchange/guest/test" ,
19
+ "routing_key" : "#" ,
20
+ "queue" : "queue/guest/test" ,
21
+ "password" : "guest" ,
22
+ }
23
+ )
24
+
25
+
26
+ @pytest .mark .skipif (NO_RABBITMQ , reason = "Test doesn't work without rabbitMq" )
27
+ def test_send (pulse_config ):
28
+ payload = {
29
+ "type" : "tag" ,
30
+ "repo_url" : "repo.git" ,
31
+ "tag" : "Tag" ,
32
+ "commit" : "sha" ,
33
+ "time" : 0 ,
34
+ "pushid" : 0 ,
35
+ "user" : "user" ,
36
+ "push_json_url" : "push_json_url" ,
37
+ }
38
+ pulse_utils .send_pulse_message (pulse_config , payload , ssl = False )
Original file line number Diff line number Diff line change 1
1
import pytest
2
2
3
- from git_hg_sync .config import PulseConfig , MappingConfig
4
3
from git_hg_sync .__main__ import get_connection , get_queue
4
+ from git_hg_sync .config import MappingConfig , PulseConfig
5
5
from git_hg_sync .repo_synchronizer import Push , RepoSynchronyzer
6
6
7
7
0 commit comments