Git Product home page Git Product logo

flask-template's Issues

Error after running test

(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 %

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.