summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/dockerflow/default.nix
blob: 0567f69ceaf5418afff4211086bac4385b22ff3f (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
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,

  # build-system
  setuptools,
  setuptools-scm,

  # optional dependencies
  asgiref,
  blinker,
  django,
  fastapi,
  flask,
  sanic,

  # tests
  django-redis,
  pytest-django,
  httpx,
  fakeredis,
  jsonschema,
  pytestCheckHook,
  pytest-cov-stub,
  pytest-mock,
  redis,
  redisTestHook,
}:

buildPythonPackage rec {
  pname = "dockerflow";
  version = "2024.04.2";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "mozilla-services";
    repo = "python-dockerflow";
    tag = version;
    hash = "sha256-5Ov605FyhX+n6vFks2sdtviGqkrgDIMXpcvgqR85jmQ=";
  };

  build-system = [
    setuptools
    setuptools-scm
  ];

  optional-dependencies = {
    django = [ django ];
    flask = [
      blinker
      flask
    ];
    sanic = [ sanic ];
    fastapi = [
      asgiref
      fastapi
    ];
  };

  nativeCheckInputs = [
    fakeredis
    jsonschema
    pytestCheckHook
    pytest-cov-stub
    pytest-mock
    redis
    redisTestHook

    # django
    django-redis
    pytest-django

    # fastapi
    httpx
  ]
  ++ lib.concatAttrValues optional-dependencies;

  disabledTests = [
    # AssertionError: assert 'c7a05e2b-8a21-4255-a3ed-92cea1e74a62' is None
    "test_mozlog_without_correlation_id_middleware"
  ];

  disabledTestPaths = [
    # missing flask-redis dependency
    "tests/flask/test_flask.py"
    # missing sanic-redis dependency
    "tests/sanic/test_sanic.py"
  ];

  preCheck = ''
    export DJANGO_SETTINGS_MODULE=tests.django.settings
  '';

  pythonImportsCheck = [
    "dockerflow"
  ];

  meta = {
    changelog = "https://github.com/mozilla-services/python-dockerflow/releases/tag/${src.tag}";
    description = "Python package to implement tools and helpers for Mozilla Dockerflow";
    homepage = "https://github.com/mozilla-services/python-dockerflow";
    license = lib.licenses.mpl20;
  };
}