Skip to content
This repository was archived by the owner on Apr 15, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion consul/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ def deregister(self, service_id):
take care of deregistering the service with the Catalog. If
there is an associated check, that is also deregistered.
"""
return self.agent.http.get(
return self.agent.http.put(
CB.bool(), '/v1/agent/service/deregister/%s' % service_id)

def maintenance(self, service_id, enable, reason=None):
Expand Down
36 changes: 36 additions & 0 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,39 @@ def test_docker_check(self, container_id, shell, script, interval,
def test_ttl_check(self):
ch = consul.base.Check.ttl('1m')
assert ch == {'ttl': '1m'}


@pytest.fixture()
def consul_client():
return Consul()


class TestAgentService(object):
def test_list(self, consul_client):
ch = consul_client.agent.services()
assert ch == Request(method='get', path='/v1/agent/services',
params=None, data=None)

def test_register(self, consul_client):
ch = consul_client.agent.service.register('test_service')
assert ch == Request(method='put', params={},
path='/v1/agent/service/register',
data='{"name": "test_service"}')

def test_deregister(self, consul_client):
ch = consul_client.agent.service.deregister('testservice')
assert ch == Request(method='put',
path='/v1/agent/service/deregister/testservice',
params=None, data='')

def test_mm_enable(self, consul_client):
ch = consul_client.agent.service.maintenance('testservice', True)
assert ch == Request(method='put',
path='/v1/agent/service/maintenance/testservice',
params={"enable": True}, data='')

def test_mm_disable(self, consul_client):
ch = consul_client.agent.service.maintenance('testservice', False)
assert ch == Request(method='put',
path='/v1/agent/service/maintenance/testservice',
params={"enable": False}, data='')