Skip to content

Commit

Permalink
test for sync_app_task
Browse files Browse the repository at this point in the history
  • Loading branch information
smn committed Jul 13, 2015
1 parent d448ee0 commit efc53a4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion consular/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def handle_unknown_event(self, request, event):
'error': 'Event type %s not supported.' % (event_type,)
})

def sync_tasks(self):
def sync_apps(self):
d = self.marathon_request('GET', '/v2/apps')
d.addCallback(lambda response: response.json())
d.addCallback(
Expand Down
17 changes: 17 additions & 0 deletions consular/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,20 @@ def test_already_registered_with_marathon(self):

response = yield d
self.assertEqual(response, True)

@inlineCallbacks
def test_sync_app_task(self):
app = {'id': '/my-app'}
task = {'id': 'my-task-id', 'host': '0.0.0.0', 'ports': [1234]}
d = self.consular.sync_app_task(app, task)
consul_request = yield self.consul_requests.get()
self.assertEqual(consul_request['path'], '/v1/agent/service/register')
self.assertEqual(consul_request['data'], {
'Name': 'my-app',
'ID': 'my-task-id',
'Address': '0.0.0.0',
'Port': 1234,
})
self.assertEqual(consul_request['method'], 'PUT')
consul_request['deferred'].callback('')
yield d

0 comments on commit efc53a4

Please sign in to comment.