'Flask mock abstract classes when testing
I'm using flask for my REST API. But currently, I have a problem with mocking providers. Let's take the example below. In this case, I'm trying to test route /auth, but I don't want to use the real firebase login service and I would mock the service by utilizing some abstract class. But how do I do that when not using class for routes? Should I pass it as a parameter for a function def login()?
Example of a route:
@app.route('/auth', methods=['POST'])
def login():
firebase_service.login()
Example of a route test:
def test_auth_returns_200(self, client):
# When
response = client.post("/auth")
# Then
assert response.status_code == 200
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
