-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdummy_github_message.py
More file actions
70 lines (51 loc) · 1.76 KB
/
dummy_github_message.py
File metadata and controls
70 lines (51 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""
Integration testing for github receive hook.
Assumes that you have a running instance on localhost:8000,
and an api key set up for the instance.
TODO:
Turn this into a nose-attr decorated integration test that relies
on a running ployst.
"""
import requests
from nose.tools import assert_equals
from ployst.core.client import Client
INTEGRATION_TEST_TOKEN = "18c6af5f-7796-4a53-8a1f-041d77dee7eb"
def read_data(filename):
return file(filename).read()
client = Client('http://localhost:8000/', INTEGRATION_TEST_TOKEN)
def setUp():
"""
We need to create:
- A project (integration-test, id=4)
- A team (testers)
- A feature with id 99
- A dummy repo in the database (
with a url of https://github.com/pretenders/dummyrepo)
pointing to the dummy repo on disk.
TODO: create these programatically. Currently these have been done
manually to test the receive hook works.
"""
project_id = 4
client.set_provider_settings(
project_id, 'github', settings={
"branch_finders": ["^master$", ".*(?i){feature_id}.*"]
})
hook_data = read_data('ployst/github/test/data/end-to-end.json')
error_file = '/tmp/error.html'
def main():
setUp()
response = requests.post(
'http://localhost:8000/providers/github/receive-hook/TOKEN/',
data={'payload': hook_data}
)
if response.status_code == 500:
print "500 ERROR OUTPUT TO {}".format(error_file)
with file(error_file, 'w') as f:
f.write(response.content)
return
assert_equals(response.status_code, 200)
features = client.get_features_by_id(99)
branches = features[0]['branches']
assert_equals('my/feature-99', branches[0]['name'])
if __name__ == '__main__':
main()