Browsed by
Tag: tdd

Passing custom HTTP headers using Flask’s test_client

Passing custom HTTP headers using Flask’s test_client

Passing custon HTTP headers using Flask’s test_client object should have been as easy as doing this:

For some reason this didn’t work in my Flask project. In case others have the same issue as I did, maybe the solution I found to work may work for others too:

 

Mocking SQLAlchemy models in Python

Mocking SQLAlchemy models in Python

I’m developing an API using Python’s Flask framework. The API uses SQLAlchemy, which means that database rows are made available as regular Python classes (referred to as database models) in my Python code. One of my models looks something like this:

My Data Access Object (DAO) for communicating with the database models looks like this:

While writing tests for the API, I wanted to mock out the database models, so that my tests wouldn’t depend on an actual…

Read More Read More