Repository: ucfopen/canvasapi

Issue:
Automatically lowercase boolean strings before sending to Canvas
This will resolve any future weirdness like #64.

Discussion:

Patch:
diff --git a/canvasapi/requester.py b/canvasapi/requester.py
index f979866..e989962 100644
--- a/canvasapi/requester.py
+++ b/canvasapi/requester.py
@@ -68,8 +68,12 @@ class Requester(object):
         for i, kwarg in enumerate(_kwargs):
             kw, arg = kwarg
 
+            # Convert boolean objects to a lowercase string.
+            if isinstance(arg, bool):
+                _kwargs[i] = (kw, str(arg).lower())
+
             # Convert any datetime objects into ISO 8601 formatted strings.
-            if isinstance(arg, datetime):
+            elif isinstance(arg, datetime):
                 _kwargs[i] = (kw, arg.isoformat())
 
         # Determine the appropriate request method.


Test patch:
diff --git a/tests/test_requester.py b/tests/test_requester.py
index fb582a7..93e87a0 100644
--- a/tests/test_requester.py
+++ b/tests/test_requester.py
@@ -94,6 +94,24 @@ class TestRequester(unittest.TestCase):
         self.assertLessEqual(len(self.requester._cache), 5)
         self.assertEqual(response, self.requester._cache[0])
 
+    def test_request_lowercase_boolean(self, m):
+        def custom_matcher(request):
+            match_text = 'test=true&test2=false'
+            if request.text == match_text:
+                resp = requests.Response()
+                resp.status_code = 200
+                return resp
+
+        m.add_matcher(custom_matcher)
+
+        response = self.requester.request(
+            'POST',
+            'test',
+            test=True,
+            test2=False
+        )
+        self.assertEqual(response.status_code, 200)
+
     def test_request_400(self, m):
         register_uris({'requests': ['400']}, m)