Skip to content

Instantly share code, notes, and snippets.

View maxcountryman's full-sized avatar
👶

Max Countryman maxcountryman

👶
View GitHub Profile
(defn get-access-token
"Retrieves an access token."
[this & [req]]
(let [client-creds {:client_id (:client-id this)
:client_secret (:client-secret this)}
url (:access-token-url this)
method (or (:method req) "POST") ;; default to "POST"
is-entity-method (in? method entity-methods)
req (merge req (if is-entity-method
{:form-params client-creds}
@maxcountryman
maxcountryman / closures.py
Last active December 14, 2015 05:29
Some notes on closures in Python.
>>> foo = []
>>> for i in range(10):
... foo.append(lambda: i)
>>> bar = []
>>> for i in range(10):
... # `bar.append(lambda j=i: j)` may be easier to see
... bar.append(lambda i=i: i)
# -*- coding: utf-8 -*-
'''
rauth.test_service
------------------
Test suite for rauth.service.
'''
from base import RauthTestCase
# -*- coding: utf-8 -*-
'''
rauth.test_service
------------------
Test suite for rauth.service.
'''
from datetime import datetime
from rauth.service import OAuth2Service
import re
import webbrowser
# Get a real consumer key & secret from:
# https://developers.facebook.com/apps
facebook = OAuth2Service(
client_id='440483442642551',
@maxcountryman
maxcountryman / oo.py
Created February 22, 2013 02:22
A snippet from the rauth 0.5.0 test_service test suite.
class OflyServiceTestCase(RauthTestCase, HttpMixin):
app_id = '000'
def setUp(self):
RauthTestCase.setUp(self)
self.authorize_url = 'http://example.com/authorize'
self.base_url = 'http://example.com/api/'
self.service = OflyService('000',
@maxcountryman
maxcountryman / test_service.py
Created February 21, 2013 15:41
Improved test suite for rauth.service.
# -*- coding: utf-8 -*-
'''
rauth.test_service
------------------
Test suite for rauth.service.
'''
from base import RauthTestCase
def request(self,
method,
uri,
access_token=None,
access_token_secret=None,
header_auth=False,
allow_redirects=False,
**kwargs):
'''Makes a proper OAuth 1.0/a request.
@maxcountryman
maxcountryman / request.py
Created February 12, 2013 21:00
Forthcoming Requests v1.x support in Rauth.
# -*- coding: utf-8 -*-
'''
rauth.request
-------------
Provides a wrapper around the requests.Request object for OAuth and Ofly
parameter injection.
'''
import time
diff --git a/test_classy/test_blueprints.py b/test_classy/test_blueprints.py
index 6ea0284..71f079c 100644
--- a/test_classy/test_blueprints.py
+++ b/test_classy/test_blueprints.py
@@ -65,8 +65,10 @@ def test_bp_custom_http_method():
resp = client.post("/basic/route3/")
eq_("Custom HTTP Method", resp.data)
+def test_bp_url_prefix():
+ foo = Blueprint('foo', __name__)