Merge lp:~soren/surveilr/db-connection into lp:surveilr

Proposed by Soren Hansen
Status: Merged
Approved by: Soren Hansen
Approved revision: 12
Merged at revision: 12
Proposed branch: lp:~soren/surveilr/db-connection
Merge into: lp:surveilr
Diff against target: 70 lines (+23/-13)
3 files modified
surveilr/api/server.py (+5/-0)
surveilr/defaults.cfg (+8/-4)
surveilr/tests/test_api_server.py (+10/-9)
To merge this branch: bzr merge lp:~soren/surveilr/db-connection
Reviewer Review Type Date Requested Status
Soren Hansen Pending
Review via email: mp+83906@code.launchpad.net

Commit message

Make the API server actually connect to Riak

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'surveilr/api/server.py'
2--- surveilr/api/server.py 2011-11-30 09:32:31 +0000
3+++ surveilr/api/server.py 2011-11-30 09:59:24 +0000
4@@ -35,6 +35,7 @@
5 from webob.dec import wsgify
6 from webob.exc import HTTPNotFound
7
8+from surveilr import config
9 from surveilr import messaging
10 from surveilr import models
11 from surveilr import utils
12@@ -184,6 +185,10 @@
13
14
15 def main():
16+ riak_host = config.get_str('riak', 'host')
17+ riak_port = config.get_int('riak', 'port')
18+
19+ riakalchemy.connect(host=riak_host, port=riak_port)
20 socket = eventlet.listen(('', 9877))
21 eventlet.wsgi.server(socket, application)
22
23
24=== modified file 'surveilr/defaults.cfg'
25--- surveilr/defaults.cfg 2011-11-29 23:41:46 +0000
26+++ surveilr/defaults.cfg 2011-11-30 09:59:24 +0000
27@@ -1,7 +1,11 @@
28 # This is where we stick defaults for various things
29
30 [sms]
31-username =
32-password =
33-api_id =
34-sender =
35+username =
36+password =
37+api_id =
38+sender =
39+
40+[riak]
41+host = 127.0.0.1
42+port = 8098
43
44=== modified file 'surveilr/tests/test_api_server.py'
45--- surveilr/tests/test_api_server.py 2011-11-30 09:27:57 +0000
46+++ surveilr/tests/test_api_server.py 2011-11-30 09:59:24 +0000
47@@ -126,13 +126,14 @@
48 resp = application(req)
49 self.assertEquals(resp.status_int, 404)
50
51- def test_main(self):
52- with mock.patch('surveilr.api.server.eventlet',
53- spec=['listen', 'wsgi']) as eventlet:
54- socket_sentinel = mock.sentinel.return_value
55- eventlet.listen.return_value = socket_sentinel
56- server.main()
57+ @mock.patch('surveilr.api.server.eventlet', spec=['listen', 'wsgi'])
58+ @mock.patch('surveilr.api.server.riakalchemy', spec=['connect'])
59+ def test_main(self, riakalchemy, eventlet):
60+ socket_sentinel = mock.sentinel.return_value
61+ eventlet.listen.return_value = socket_sentinel
62+ server.main()
63
64- eventlet.listen.assert_called_with(('', 9877))
65- eventlet.wsgi.server.assert_called_with(socket_sentinel,
66- application)
67+ riakalchemy.connect.assert_called_with(host='127.0.0.1', port=8098)
68+ eventlet.listen.assert_called_with(('', 9877))
69+ eventlet.wsgi.server.assert_called_with(socket_sentinel,
70+ application)

Subscribers

People subscribed via source and target branches

to all changes: