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
=== modified file 'surveilr/api/server.py'
--- surveilr/api/server.py 2011-11-30 09:32:31 +0000
+++ surveilr/api/server.py 2011-11-30 09:59:24 +0000
@@ -35,6 +35,7 @@
35from webob.dec import wsgify35from webob.dec import wsgify
36from webob.exc import HTTPNotFound36from webob.exc import HTTPNotFound
3737
38from surveilr import config
38from surveilr import messaging39from surveilr import messaging
39from surveilr import models40from surveilr import models
40from surveilr import utils41from surveilr import utils
@@ -184,6 +185,10 @@
184185
185186
186def main():187def main():
188 riak_host = config.get_str('riak', 'host')
189 riak_port = config.get_int('riak', 'port')
190
191 riakalchemy.connect(host=riak_host, port=riak_port)
187 socket = eventlet.listen(('', 9877))192 socket = eventlet.listen(('', 9877))
188 eventlet.wsgi.server(socket, application)193 eventlet.wsgi.server(socket, application)
189194
190195
=== modified file 'surveilr/defaults.cfg'
--- surveilr/defaults.cfg 2011-11-29 23:41:46 +0000
+++ surveilr/defaults.cfg 2011-11-30 09:59:24 +0000
@@ -1,7 +1,11 @@
1# This is where we stick defaults for various things1# This is where we stick defaults for various things
22
3[sms]3[sms]
4username = 4username =
5password = 5password =
6api_id = 6api_id =
7sender = 7sender =
8
9[riak]
10host = 127.0.0.1
11port = 8098
812
=== modified file 'surveilr/tests/test_api_server.py'
--- surveilr/tests/test_api_server.py 2011-11-30 09:27:57 +0000
+++ surveilr/tests/test_api_server.py 2011-11-30 09:59:24 +0000
@@ -126,13 +126,14 @@
126 resp = application(req)126 resp = application(req)
127 self.assertEquals(resp.status_int, 404)127 self.assertEquals(resp.status_int, 404)
128128
129 def test_main(self):129 @mock.patch('surveilr.api.server.eventlet', spec=['listen', 'wsgi'])
130 with mock.patch('surveilr.api.server.eventlet',130 @mock.patch('surveilr.api.server.riakalchemy', spec=['connect'])
131 spec=['listen', 'wsgi']) as eventlet:131 def test_main(self, riakalchemy, eventlet):
132 socket_sentinel = mock.sentinel.return_value132 socket_sentinel = mock.sentinel.return_value
133 eventlet.listen.return_value = socket_sentinel133 eventlet.listen.return_value = socket_sentinel
134 server.main()134 server.main()
135135
136 eventlet.listen.assert_called_with(('', 9877))136 riakalchemy.connect.assert_called_with(host='127.0.0.1', port=8098)
137 eventlet.wsgi.server.assert_called_with(socket_sentinel,137 eventlet.listen.assert_called_with(('', 9877))
138 application)138 eventlet.wsgi.server.assert_called_with(socket_sentinel,
139 application)

Subscribers

People subscribed via source and target branches

to all changes: