Repository: ithaka/apiron

Issue:
Option to specify proxies
**Describe the bug**
I can't find a way to define proxy information, e.g. in requests we can say `requests.get('http://example.org', proxies=proxies)`

**To Reproduce**
Steps to reproduce the behavior: NA

**Expected behavior**
There should be an option to pass proxy information.

**What actually happened**
NA

**Screenshots**
NA

**Environment:**
 - OS: Any
 - Python version 3.7.5
 - `apiron` version 5.0.0

**Additional context**
I'm happy to contribute if you could walk me through the project.

Discussion:

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f4342a7..7bb833f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
+## Unreleased
+### Added
+- Ability to specify `proxies` for a `Service` definition so all calls to the service use the defined proxies
+
 ## [5.0.0] - 2019-12-02
 ### Removed
 - Support for Python 3.4 and 3.5 has been removed based on official Python support timelines and usage statistics
diff --git a/src/apiron/client.py b/src/apiron/client.py
index 2072201..9f6437f 100644
--- a/src/apiron/client.py
+++ b/src/apiron/client.py
@@ -246,6 +246,7 @@ def call(
         timeout=(timeout_spec.connection_timeout, timeout_spec.read_timeout),
         stream=getattr(endpoint, "streaming", False),
         allow_redirects=allow_redirects,
+        proxies=session.proxies or service.proxies,
     )
 
     logger.info(
diff --git a/src/apiron/service/base.py b/src/apiron/service/base.py
index dce776a..7847d85 100644
--- a/src/apiron/service/base.py
+++ b/src/apiron/service/base.py
@@ -19,6 +19,7 @@ class ServiceMeta(type):
 
 class ServiceBase(metaclass=ServiceMeta):
     required_headers = {}
+    proxies = {}
 
     @classmethod
     def get_hosts(cls):


Test patch:
diff --git a/tests/test_client.py b/tests/test_client.py
index 901b67a..e841289 100644
--- a/tests/test_client.py
+++ b/tests/test_client.py
@@ -128,6 +128,7 @@ class TestClient:
 
         mock_session = MockSession()
         mock_session.send.return_value = mock_response
+        mock_session.proxies = {}
         mock_get_adapted_session.return_value = mock_session
 
         client.call(service, mock_endpoint, timeout_spec=mock_timeout, logger=mock_logger)
@@ -138,6 +139,7 @@ class TestClient:
             timeout=(mock_timeout.connection_timeout, mock_timeout.read_timeout),
             stream=mock_endpoint.streaming,
             allow_redirects=True,
+            proxies=service.proxies,
         )
 
         mock_logger.info.assert_any_call("GET http://host1.biz/foo/")
@@ -153,6 +155,7 @@ class TestClient:
             timeout=(mock_timeout.connection_timeout, mock_timeout.read_timeout),
             stream=mock_endpoint.streaming,
             allow_redirects=True,
+            proxies=service.proxies,
         )
 
         mock_logger.info.assert_any_call("GET http://host1.biz/foo/")
@@ -169,6 +172,7 @@ class TestClient:
             timeout=(mock_timeout.connection_timeout, mock_timeout.read_timeout),
             stream=mock_endpoint.streaming,
             allow_redirects=True,
+            proxies=service.proxies,
         )
 
     @mock.patch("apiron.client.get_adapted_session")