def test_delete_success(self): registration = Registration() registration._get_param = Mock(side_effect=self.generate_valid_params) registration.post('foo') response, response_code = registration.delete('foo', '10.10.10.10') assert response_code == 200 assert response == {}
def test_post_valid_params(self): registration = Registration() registration._get_param = Mock(side_effect=self.generate_valid_params) response, response_code = registration.post('foo') expected = {} assert response_code == 200 assert response == expected
def test_get_with_hosts(self, get_hosts): expected_hosts = [ { 'service': 'foo', 'ip_address': '10.10.10.10', 'service_repo_name': 'bar', 'port': 10, 'revision': 'blah', 'last_check_in': 'timestamp', 'tags': { 'az': 'woot', 'instance_id': 'wooooooooot' } }, { 'service': 'foo', 'ip_address': '11.11.11.11', 'service_repo_name': None, 'port': 11, 'revision': 'blah', 'last_check_in': 'timestamp2', 'tags': { 'az': 'woot', 'instance_id': 'wooooooooot' } }, ] get_hosts.return_value = expected_hosts registration = Registration() registration._get_param = Mock(side_effect=self.generate_valid_params) response, response_code = registration.get('foo') expected = { "hosts": expected_hosts, "service": "foo", "env": "development" } assert response_code == 200 assert response == expected