1{ lib
2, buildPythonPackage
3, fetchFromGitHub
4
5, flask
6, limits
7, rich
8, typing-extensions
9
10, asgiref
11, hiro
12, pymemcache
13, pytest-mock
14, pytestCheckHook
15, redis
16, pymongo
17}:
18
19buildPythonPackage rec {
20 pname = "Flask-Limiter";
21 version = "2.6.2";
22
23 src = fetchFromGitHub {
24 owner = "alisaifee";
25 repo = "flask-limiter";
26 rev = version;
27 sha256 = "sha256-JjksKwSMWzcslXCs977/Wlq1wDMaACxm8e6Ub+r3wPg=";
28 };
29
30 propagatedBuildInputs = [
31 flask
32 limits
33 rich
34 typing-extensions
35 ];
36
37 checkInputs = [
38 asgiref
39 pytest-mock
40 pytestCheckHook
41 hiro
42 redis
43 pymemcache
44 pymongo
45 ];
46
47 postPatch = ''
48 sed -i "/--cov/d" pytest.ini
49
50 # flask-restful is unmaintained and breaks regularly, don't depend on it
51 sed -i "/import flask_restful/d" tests/test_views.py
52 '';
53
54 disabledTests = [
55 # flask-restful is unmaintained and breaks regularly
56 "test_flask_restful_resource"
57
58 # Requires running a docker instance
59 "test_clear_limits"
60 "test_constructor_arguments_over_config"
61 "test_custom_key_prefix"
62 "test_custom_key_prefix_with_headers"
63 "test_fallback_to_memory_backoff_check"
64 "test_fallback_to_memory_config"
65 "test_fallback_to_memory_with_global_override"
66 "test_redis_request_slower_than_fixed_window"
67 "test_redis_request_slower_than_moving_window"
68 "test_reset_unsupported"
69
70 # Requires redis
71 "test_fallback_to_memory"
72 ];
73
74 disabledTestPaths = [
75 # requires running redis/memcached/mongodb
76 "tests/test_storage.py"
77 ];
78
79 pythonImportsCheck = [ "flask_limiter" ];
80
81 meta = with lib; {
82 description = "Rate limiting for flask applications";
83 homepage = "https://flask-limiter.readthedocs.org/";
84 license = licenses.mit;
85 };
86}