synchronicity

Constructing meaning from coincidence

Testing Flask Application with Basic Authentication

01/10/2012@14:20:52

import base64
from myapplication import app

class MyTestCase(unittest.TestCase):
    def setUp(self):    
        self.app = app.test_client()

    def tearDown(self):
        pass

    def open_with_auth(self, url, method, username, password):
        return self.app.open(url,
            method=method,
            headers={
                'Authorization': 'Basic ' + base64.b64encode(username + \
                ":" + password)
            }
        )

    def test_login(self):
        res = self.open_with_auth('/user/login', 'GET', 'username',
                                  'password')

My name is David Watson. I'm a creative person from a small town in Western Pennsylvania called Fallston. I went to school in the Beaver and New Brighton school districts before graduating from Duquesne University in Pittsburgh.

I met my wife, Wendy teaching at Mars High School where I taught the drum line and she taught the color guard. After graduation, we lived in Boston and Seattle before returning to the Pittsburgh area, where I earn my living making software.

This site chronicles my ideas, photographs, music, and technology. I hope you find something of value here. If you'd like to collaborate, please contact me on Linked In or at the email address above. Thanks for visiting!