1{ lib
2, arangodb
3, buildPythonPackage
4, fetchFromGitHub
5, pythonOlder
6, pytestCheckHook
7, pyjwt
8, pytest
9, mock
10, requests
11, requests-toolbelt
12}:
13
14let
15 testDBOpts = {
16 host = "127.0.0.1";
17 port = "8529";
18 password = "test";
19 secret = "secret";
20 };
21in
22
23buildPythonPackage rec {
24 pname = "python-arango";
25 version = "7.5.7";
26 format = "setuptools";
27
28 disabled = pythonOlder "3.7";
29
30 src = fetchFromGitHub {
31 owner = "ArangoDB-Community";
32 repo = "python-arango";
33 rev = "refs/tags/${version}";
34 hash = "sha256-cd2xE5rYLl3NOv/DZjmHRPCe224k4XyPjo9aXV1ZhvU=";
35 };
36
37 propagatedBuildInputs = [
38 requests
39 requests-toolbelt
40 pyjwt
41 ];
42
43 nativeCheckInputs = [
44 arangodb
45 mock
46 pytestCheckHook
47 ];
48
49 # arangodb is compiled only for particular target architectures
50 # (i.e. "haswell"). Thus, these tests may not pass reproducibly,
51 # failing with: `166: Illegal instruction` if not run on arangodb's
52 # specified architecture.
53 #
54 # nonetheless, the client library should remain in nixpkgs - since
55 # the client library will talk to arangodb across the network and
56 # architecture issues will be irrelevant.
57 doCheck = false;
58
59 preCheck = lib.optionalString doCheck ''
60 # Start test DB
61 mkdir -p .nix-test/{data,work}
62
63 ICU_DATA=${arangodb}/share/arangodb3 \
64 GLIBCXX_FORCE_NEW=1 \
65 TZ=UTC \
66 TZ_DATA=${arangodb}/share/arangodb3/tzdata \
67 ARANGO_ROOT_PASSWORD=${testDBOpts.password} \
68 ${arangodb}/bin/arangod \
69 --server.uid=$(id -u) \
70 --server.gid=$(id -g) \
71 --server.authentication=true \
72 --server.endpoint=http+tcp://${testDBOpts.host}:${testDBOpts.port} \
73 --server.descriptors-minimum=4096 \
74 --server.jwt-secret=${testDBOpts.secret} \
75 --javascript.app-path=.nix-test/app \
76 --log.file=.nix-test/log \
77 --database.directory=.nix-test/data \
78 --foxx.api=false &
79 '';
80
81 pytestFlagsArray = [
82 "--host"
83 testDBOpts.host
84 "--port"
85 testDBOpts.port
86 "--passwd"
87 testDBOpts.password
88 "--secret"
89 testDBOpts.secret
90 ];
91
92 disabledTests = [
93 # AssertionError geo-related - try enabling later
94 "test_document_find_in_box"
95
96 # maybe arangod misconfig - try enabling later
97 # arango.exceptions.JWTAuthError: [HTTP 401][ERR 401] Wrong credentials
98 "test_auth_jwt"
99
100 # ValueError - try enabling later
101 # maybe missed 3.9.3->3.10.0 changes
102 # most caused by key change: isNewlyCreated->new
103 "test_add_hash_index"
104 "test_add_skiplist_index"
105 "test_add_persistent_index"
106 "test_add_ttl_index"
107 "test_delete_index"
108 "test_pregel_management"
109
110 # formatting error - try enabling later
111 # maybe missed 3.9.3->3.10.0 changes
112 # caused by: body["computedValues"] = None
113 "test_permission_management"
114 "test_collection_misc_methods"
115 "test_collection_management"
116 "test_replication_inventory"
117
118 # want outgoing network to update foxx apis
119 # so foxx.api disabled in arangod startup
120 "test_foxx_service_management_file"
121 "test_foxx_service_management_json"
122 "test_foxx_config_management"
123 "test_foxx_dependency_management"
124 "test_foxx_development_toggle"
125 "test_foxx_misc_functions"
126
127 # no replication configured via arangod invocation
128 "test_replication_applier"
129 ];
130
131 pythonImportsCheck = [
132 "arango"
133 ];
134
135 meta = with lib; {
136 description = "Python Driver for ArangoDB";
137 homepage = "https://github.com/ArangoDB-Community/python-arango";
138 changelog = "https://github.com/ArangoDB-Community/python-arango/releases/tag/${version}";
139 license = licenses.mit;
140 maintainers = with maintainers; [ jsoo1 ];
141 };
142}