summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/aiosonic/default.nix
blob: 89b92f98844967bea882364bee03c7536c26b1b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
{
  lib,
  stdenv,
  aiohttp,
  buildPythonPackage,
  charset-normalizer,
  fetchFromGitHub,
  h2,
  httpx,
  onecache,
  pkgs,
  poetry-core,
  pytest-aiohttp,
  pytest-cov-stub,
  pytest-mock,
  pytestCheckHook,
  requests,
  uvicorn,
}:

buildPythonPackage rec {
  pname = "aiosonic";
  version = "0.30.1";
  pyproject = true;

  __darwinAllowLocalNetworking = true;

  src = fetchFromGitHub {
    owner = "sonic182";
    repo = "aiosonic";
    tag = version;
    hash = "sha256-VqtPl/dZmxjB7z9AjwBfmYmcxFae2NhWEnsw4l9+IYg=";
  };

  postPatch = ''
    substituteInPlace pytest.ini --replace-fail \
      "addopts = --black " \
      "addopts = "
  '';

  build-system = [ poetry-core ];

  dependencies = [
    charset-normalizer
    h2
    onecache
  ];

  nativeCheckInputs = [
    aiohttp
    httpx
    pkgs.nodejs
    pytest-aiohttp
    pytest-cov-stub
    pytest-mock
    pytestCheckHook
    requests
    uvicorn
  ];

  pythonImportsCheck = [ "aiosonic" ];

  disabledTests =
    lib.optionals stdenv.hostPlatform.isLinux [
      # Tests require network access
      "test_close_connection"
      "test_close_old_keeped_conn"
      "test_connect_timeout"
      "test_delete_2"
      "test_delete"
      "test_get_body_deflate"
      "test_get_body_gzip"
      "test_get_chunked_response_and_not_read_it"
      "test_get_chunked_response"
      "test_get_http2"
      "test_get_image_chunked"
      "test_get_image"
      "test_get_keepalive"
      "test_get_python"
      "test_get_redirect"
      "test_get_with_cookies"
      "test_get_with_params_in_url"
      "test_get_with_params_tuple"
      "test_get_with_params"
      "test_keep_alive_cyclic_pool"
      "test_keep_alive_smart_pool"
      "test_max_conn_idle_ms"
      "test_max_redirects"
      "test_method_lower"
      "test_multipart_backward_compatibility"
      "test_pool_acquire_timeout"
      "test_post_chunked"
      "test_post_form_urlencoded"
      "test_post_http2"
      "test_post_json"
      "test_post_multipart_with_class"
      "test_post_multipart_with_metadata"
      "test_post_multipart_with_multipartfile_class"
      "test_post_multipart_with_multipartfile_path"
      "test_post_multipart"
      "test_post_tuple_form_urlencoded"
      "test_put_patch"
      "test_read_chunks_by_text_method"
      "test_read_timeout"
      "test_simple_get"
      "test_timeouts_overriden"
      "test_wrapper_delete_http_serv"
      "test_wrapper_get_http_serv"
      # Tests can't trigger server
      "test_ws"
      # Test requires proxy
      "test_proxy_request"
    ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin [
      # "FAILED tests/test_proxy.py::test_proxy_request - Exception: port 8865 never got active"
      "test_proxy_request"
    ];

  disabledTestPaths = [
    # tests hang
    "tests/test_sse.py"
  ];

  meta = {
    changelog = "https://github.com/sonic182/aiosonic/blob/${src.tag}/CHANGELOG.md";
    description = "Very fast Python asyncio http client";
    license = lib.licenses.mit;
    homepage = "https://github.com/sonic182/aiosonic";
    maintainers = with lib.maintainers; [ geraldog ];
  };
}