2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
buildPythonPackage,
|
|
|
|
pythonOlder,
|
|
|
|
fetchFromGitHub,
|
|
|
|
poetry-core,
|
|
|
|
pymongo,
|
|
|
|
pytestCheckHook,
|
2023-10-09 19:29:22 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "pymongo-inmemory";
|
2024-06-05 15:53:02 +00:00
|
|
|
version = "0.4.2";
|
2023-10-09 19:29:22 +00:00
|
|
|
format = "pyproject";
|
|
|
|
|
|
|
|
disabled = pythonOlder "3.7";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "kaizendorks";
|
|
|
|
repo = "pymongo_inmemory";
|
|
|
|
rev = "refs/tags/v${version}";
|
2024-06-05 15:53:02 +00:00
|
|
|
hash = "sha256-FDHHf9x62EqNcHjDF2vH8w8WG/15efEe+fDqGiiOe4A=";
|
2023-10-09 19:29:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
# move cache location from nix store to home
|
|
|
|
substituteInPlace pymongo_inmemory/context.py \
|
2024-05-15 15:35:15 +00:00
|
|
|
--replace-fail \
|
2023-10-09 19:29:22 +00:00
|
|
|
'CACHE_FOLDER = path.join(path.dirname(__file__), "..", ".cache")' \
|
|
|
|
'CACHE_FOLDER = os.environ.get("XDG_CACHE_HOME", os.environ["HOME"] + "/.cache") + "/pymongo-inmemory"'
|
|
|
|
|
|
|
|
# fix a broken assumption arising from the above fix
|
|
|
|
substituteInPlace pymongo_inmemory/_utils.py \
|
2024-05-15 15:35:15 +00:00
|
|
|
--replace-fail \
|
2023-10-09 19:29:22 +00:00
|
|
|
'os.mkdir(current_path)' \
|
|
|
|
'os.makedirs(current_path)'
|
|
|
|
'';
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
nativeBuildInputs = [ poetry-core ];
|
2023-10-09 19:29:22 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
dependencies = [ pymongo ];
|
2023-10-09 19:29:22 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
nativeCheckInputs = [ pytestCheckHook ];
|
2023-10-09 19:29:22 +00:00
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
disabledTestPaths = [
|
|
|
|
# new test with insufficient monkey patching, try to remove on next bump
|
|
|
|
"tests/unit/test_mongod.py"
|
|
|
|
];
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
preCheck = ''
|
|
|
|
export HOME="$(mktemp -d)"
|
|
|
|
'';
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
pythonImportsCheck = [ "pymongo_inmemory" ];
|
2023-10-09 19:29:22 +00:00
|
|
|
|
|
|
|
meta = {
|
|
|
|
homepage = "https://github.com/kaizendorks/pymongo_inmemory";
|
|
|
|
description = "A mongo mocking library with an ephemeral MongoDB running in memory";
|
|
|
|
maintainers = with lib.maintainers; [ pbsds ];
|
|
|
|
license = lib.licenses.mit;
|
|
|
|
};
|
|
|
|
}
|