riad-azz / flask-template Goto Github PK
View Code? Open in Web Editor NEWFlask starter template to help you build a scalable and maintanable project.
Flask starter template to help you build a scalable and maintanable project.
(venvT) karim@Karims-MacBook-Pro flask-template % python3 -m pytest
========================================================= test session starts =========================================================
platform darwin -- Python 3.10.8, pytest-7.4.3, pluggy-1.3.0
rootdir: /Users/karim/Documents/MASTER M2/ML/flask-template
collected 10 items
tests/flask/test_api.py ..F.... [ 70%]
tests/flask/test_cache.py F [ 80%]
tests/flask/test_cors.py . [ 90%]
tests/flask/test_ratelimiter.py E [100%]
=============================================================== ERRORS ================================================================
_________________________________________________ ERROR at setup of test_rate_limiter _________________________________________________
@pytest.fixture
def app():
app = create_app()
limiter.enabled = True
limiter.reset()
tests/flask/test_ratelimiter.py:15:
venvT/lib/python3.10/site-packages/flask_limiter/extension.py:805: in reset
self.storage.reset()
self = <flask_limiter.extension.Limiter object at 0x105b99ff0>
@property
def storage(self) -> Storage:
"""
The backend storage configured for the rate limiter
"""
assert self._storage
E AssertionError
venvT/lib/python3.10/site-packages/flask_limiter/extension.py:815: AssertionError
============================================================== FAILURES ===============================================================
_________________________________________________________ test_api_ratelimit __________________________________________________________
app = <Flask 'app'>
def test_api_ratelimit(app):
with app.test_client() as client:
success_response = client.get("/api/tests/ratelimit")
limited_response = client.get("/api/tests/ratelimit")
assert success_response.status_code == 200
assert success_response.json["status"] == "success"
assert success_response.json["data"]["title"] == "riad-azz"
assert success_response.json["data"]["content"] == "Rate limit API response"
assert limited_response.status_code == 429
E assert 200 == 429
E + where 200 = <WrapperTestResponse streamed [200 OK]>.status_code
tests/flask/test_api.py:41: AssertionError
___________________________________________________________ test_api_cache ____________________________________________________________
app = <Flask 'app'>
def test_api_cache(app):
request_url = "/api/tests/cached"
with app.test_client() as client:
response = client.get(request_url)
assert response.status_code == 200
assert response.headers.get("Is-Cached-Response") is None
assert response.json["status"] == "success"
assert response.json["data"]["title"] == "riad-azz"
assert response.json["data"]["content"] == "Cached API response"
request = response.request
is_cached = get_cached_response(request)
assert bool(is_cached) is True
E assert False is True
E + where False = bool(None)
tests/flask/test_cache.py:29: AssertionError
======================================================= short test summary info =======================================================
FAILED tests/flask/test_api.py::test_api_ratelimit - assert 200 == 429
FAILED tests/flask/test_cache.py::test_api_cache - assert False is True
ERROR tests/flask/test_ratelimiter.py::test_rate_limiter - AssertionError
================================================ 2 failed, 7 passed, 1 error in 1.46s =================================================
(venvT) karim@Karims-MacBook-Pro flask-template %
i've installed flask=2.3 and python=3.9 and it is not working
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.