Repository: castle/castle-python

Issue:
change timeout configuration from seconds to miliseconds

Discussion:

Patch:
diff --git a/HISTORY.md b/HISTORY.md
index c705403..e66e5a4 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -1,3 +1,8 @@
+## master
+
+### Breaking Changes:
+- switched configuration request_timeout from seconds to milliseconds
+
 ## 2.0.0 (2018-02-09)
 
 ### Features:
diff --git a/README.rst b/README.rst
index 5fc110f..1436405 100644
--- a/README.rst
+++ b/README.rst
@@ -29,8 +29,8 @@ import and configure the library with your Castle API secret.
     # For authenticate method you can set failover strategies: allow(default), deny, challenge, throw
     configuration.failover_strategy = 'deny'
 
-    # Castle::RequestError is raised when timing out in seconds (default: 0.5 of the second)
-    configuration.request_timeout = 1
+    # Castle::RequestError is raised when timing out in milliseconds (default: 500 milliseconds)
+    configuration.request_timeout = 1000
 
     # Whitelisted and Blacklisted headers are case insensitive and allow to use _ and - as a separator, http prefixes are removed
     # Whitelisted headers
diff --git a/castle/configuration.py b/castle/configuration.py
index 1a9a6dc..c406191 100644
--- a/castle/configuration.py
+++ b/castle/configuration.py
@@ -19,7 +19,7 @@ WHITELISTED = [
 BLACKLISTED = ['HTTP_COOKIE']
 
 # 500 milliseconds
-REQUEST_TIMEOUT = 0.5
+REQUEST_TIMEOUT = 500
 FAILOVER_STRATEGIES = ['allow', 'deny', 'challenge', 'throw']
 
 
diff --git a/castle/request.py b/castle/request.py
index 7e38c79..230787c 100644
--- a/castle/request.py
+++ b/castle/request.py
@@ -13,7 +13,7 @@ class Request(object):
             method,
             self.build_url(path),
             auth=('', configuration.api_secret),
-            timeout=configuration.request_timeout,
+            timeout=configuration.request_timeout / 1000.0,
             headers=self.headers,
             verify=Request.verify(),
             data=None if params is None else json.dumps(params)


Test patch:
diff --git a/castle/test/configuration_test.py b/castle/test/configuration_test.py
index 67fd056..6c80f05 100644
--- a/castle/test/configuration_test.py
+++ b/castle/test/configuration_test.py
@@ -15,7 +15,7 @@ class ConfigurationTestCase(unittest.TestCase):
                          HeadersFormatter.call(v) for v in WHITELISTED])
         self.assertEqual(config.blacklisted, [
                          HeadersFormatter.call(v) for v in BLACKLISTED])
-        self.assertEqual(config.request_timeout, 0.5)
+        self.assertEqual(config.request_timeout, 500)
         self.assertEqual(config.failover_strategy, 'allow')
 
     def test_api_secret_setter(self):
@@ -70,8 +70,8 @@ class ConfigurationTestCase(unittest.TestCase):
 
     def test_request_timeout_setter(self):
         config = Configuration()
-        config.request_timeout = 5
-        self.assertEqual(config.request_timeout, 5.0)
+        config.request_timeout = 5000
+        self.assertEqual(config.request_timeout, 5000)
 
     def test_failover_strategy_setter_valid(self):
         config = Configuration()