weblate: run pytest unit tests (#475943)
This commit is contained in:
@@ -130,8 +130,12 @@ let
|
||||
inherit (finalPackage) GI_TYPELIB_PATH;
|
||||
};
|
||||
|
||||
# Packages needed at runtime
|
||||
weblatePath = with pkgs; [
|
||||
gitSVN
|
||||
subversion
|
||||
gettext
|
||||
fontconfig
|
||||
borgbackup
|
||||
|
||||
#optional
|
||||
@@ -141,6 +145,7 @@ let
|
||||
mercurial
|
||||
openssh
|
||||
];
|
||||
|
||||
in
|
||||
{
|
||||
|
||||
|
||||
@@ -9,15 +9,29 @@
|
||||
gdk-pixbuf,
|
||||
glib,
|
||||
gobject-introspection,
|
||||
askalono,
|
||||
borgbackup,
|
||||
writeText,
|
||||
postgresqlTestHook,
|
||||
postgresql,
|
||||
redisTestHook,
|
||||
fontconfig,
|
||||
nixosTests,
|
||||
|
||||
# runtime inputs
|
||||
gitSVN,
|
||||
subversion,
|
||||
|
||||
#optional runtime inputs
|
||||
git-review,
|
||||
tesseract,
|
||||
licensee,
|
||||
mercurial,
|
||||
openssh,
|
||||
}:
|
||||
|
||||
let
|
||||
python = python3.override {
|
||||
packageOverrides = final: prev: {
|
||||
packageOverrides = _final: prev: {
|
||||
django = prev.django_5;
|
||||
};
|
||||
};
|
||||
@@ -40,6 +54,10 @@ python.pkgs.buildPythonApplication rec {
|
||||
hash = "sha256-qNv3aaPyQ/bOrPbK7u9vtq8R1MFqXLJzvLUZfVgjMK0=";
|
||||
};
|
||||
|
||||
postPatch = ''
|
||||
sed -i 's|/bin/true|true|g' weblate/addons/example_pre.py
|
||||
'';
|
||||
|
||||
build-system = with python.pkgs; [ setuptools ];
|
||||
|
||||
nativeBuildInputs = [ gettext ];
|
||||
@@ -54,14 +72,14 @@ python.pkgs.buildPythonApplication rec {
|
||||
# So we don't need postgres dependencies
|
||||
DATABASES = {}
|
||||
'';
|
||||
manage = "DJANGO_SETTINGS_MODULE='weblate.settings_static' ${python.pythonOnBuildForHost.interpreter} manage.py";
|
||||
in
|
||||
''
|
||||
mkdir $static
|
||||
cat weblate/settings_example.py ${staticSettings} > weblate/settings_static.py
|
||||
export DJANGO_SETTINGS_MODULE="weblate.settings_static"
|
||||
${python.pythonOnBuildForHost.interpreter} manage.py compilemessages
|
||||
${python.pythonOnBuildForHost.interpreter} manage.py collectstatic --no-input
|
||||
${python.pythonOnBuildForHost.interpreter} manage.py compress
|
||||
${manage} compilemessages
|
||||
${manage} collectstatic --no-input
|
||||
${manage} compress
|
||||
'';
|
||||
|
||||
pythonRelaxDeps = [
|
||||
@@ -152,8 +170,30 @@ python.pkgs.buildPythonApplication rec {
|
||||
++ urllib3.optional-dependencies.brotli
|
||||
++ urllib3.optional-dependencies.zstd;
|
||||
|
||||
optional-dependencies = {
|
||||
postgres = with python.pkgs; [ psycopg ];
|
||||
# Commented entries are not packaged yet
|
||||
optional-dependencies = with python.pkgs; {
|
||||
alibaba = [
|
||||
aliyun-python-sdk-alimt
|
||||
aliyun-python-sdk-core
|
||||
];
|
||||
amazon = [ boto3 ];
|
||||
# antispam = [ python-akismet ];
|
||||
# gelf = [ logging-gelf ];
|
||||
# gerrit = [ git-review ];
|
||||
google = [
|
||||
google-cloud-storage
|
||||
google-cloud-translate
|
||||
];
|
||||
ldap = [ django-auth-ldap ];
|
||||
# mercurial = [ mercurial ];
|
||||
mysql = [ mysqlclient ];
|
||||
openai = [ openai ];
|
||||
postgres = [ psycopg ];
|
||||
saml = [ python3-saml ];
|
||||
# saml2idp = [ djangosaml2idp ];
|
||||
# wlhosted = [ wlhosted ];
|
||||
wsgi = [ granian ];
|
||||
# zxcvbn = [ django-zxcvbn-password-validator ];
|
||||
};
|
||||
|
||||
# We don't just use wrapGAppsNoGuiHook because we need to expose GI_TYPELIB_PATH
|
||||
@@ -167,6 +207,69 @@ python.pkgs.buildPythonApplication rec {
|
||||
];
|
||||
makeWrapperArgs = [ "--set GI_TYPELIB_PATH \"$GI_TYPELIB_PATH\"" ];
|
||||
|
||||
nativeCheckInputs =
|
||||
with python.pkgs;
|
||||
[
|
||||
pytestCheckHook
|
||||
postgresqlTestHook
|
||||
postgresql
|
||||
redisTestHook
|
||||
pytest-cov-stub
|
||||
pytest-django
|
||||
pytest-xdist
|
||||
responses
|
||||
respx
|
||||
selenium
|
||||
standardwebhooks
|
||||
|
||||
gitSVN
|
||||
subversion
|
||||
gettext
|
||||
fontconfig
|
||||
borgbackup
|
||||
|
||||
#optional
|
||||
git-review
|
||||
tesseract
|
||||
licensee
|
||||
mercurial
|
||||
openssh
|
||||
]
|
||||
++ social-auth-core.optional-dependencies.saml
|
||||
++ (lib.concatLists (builtins.attrValues optional-dependencies));
|
||||
|
||||
env = {
|
||||
CI_DATABASE = "postgresql";
|
||||
DJANGO_SETTINGS_MODULE = "weblate.settings_test";
|
||||
|
||||
# Only needed to make weblate/settings_test.py happy
|
||||
CI_DB_PORT = "";
|
||||
CI_DB_PASSWORD = "";
|
||||
CI_REDIS_HOST = "";
|
||||
CI_REDIS_PORT = "";
|
||||
};
|
||||
|
||||
# pytest-xdist wants to create an additional database per test group
|
||||
postgresqlTestUserOptions = "LOGIN SUPERUSER";
|
||||
|
||||
postgresqlTestSetupPost = ''
|
||||
export CI_DB_HOST="$PGHOST"
|
||||
export CI_DB_USER="$PGUSER"
|
||||
export CI_DB_NAME="$PGDATABASE"
|
||||
|
||||
echo "CACHES[\"avatar\"][\"LOCATION\"] = \"unix://$NIX_BUILD_TOP/run/redis.sock\"" \
|
||||
>> weblate/settings_test.py
|
||||
|
||||
${python.pythonOnBuildForHost.interpreter} manage.py migrate --noinput
|
||||
${python.pythonOnBuildForHost.interpreter} manage.py check
|
||||
'';
|
||||
|
||||
disabledTests = [
|
||||
# Tries to download things from GitHub
|
||||
"test_ocr"
|
||||
"test_ocr_backend"
|
||||
];
|
||||
|
||||
passthru = {
|
||||
inherit python;
|
||||
# We need to expose this so weblate can work outside of calling its bin output
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
{
|
||||
lib,
|
||||
aliyun-python-sdk-core,
|
||||
buildPythonPackage,
|
||||
fetchPypi,
|
||||
setuptools,
|
||||
}:
|
||||
|
||||
buildPythonPackage rec {
|
||||
pname = "aliyun-python-sdk-alimt";
|
||||
version = "3.2.0";
|
||||
format = "pyproject";
|
||||
|
||||
# Upstream doesn't tag releases on Github
|
||||
# https://github.com/aliyun/aliyun-openapi-python-sdk/issues/551
|
||||
src = fetchPypi {
|
||||
inherit pname version;
|
||||
hash = "sha256-oz8PNY/j6xE7pY91F8O5ed2j02q8tFl1A/u9Q5fYbuA=";
|
||||
};
|
||||
|
||||
build-system = [ setuptools ];
|
||||
|
||||
dependencies = [ aliyun-python-sdk-core ];
|
||||
|
||||
# All components are stored in a mono repo
|
||||
doCheck = false;
|
||||
|
||||
pythonImportsCheck = [ "aliyunsdkalimt" ];
|
||||
|
||||
meta = {
|
||||
description = "ALIMT module of Aliyun Python SDK";
|
||||
homepage = "https://github.com/aliyun/aliyun-openapi-python-sdk";
|
||||
changelog = "https://github.com/aliyun/aliyun-openapi-python-sdk/blob/master/aliyun-python-sdk-sts/ChangeLog.txt";
|
||||
license = lib.licenses.asl20;
|
||||
maintainers = with lib.maintainers; [ erictapen ];
|
||||
};
|
||||
}
|
||||
@@ -642,6 +642,8 @@ self: super: with self; {
|
||||
|
||||
alive-progress = callPackage ../development/python-modules/alive-progress { };
|
||||
|
||||
aliyun-python-sdk-alimt = callPackage ../development/python-modules/aliyun-python-sdk-alimt { };
|
||||
|
||||
aliyun-python-sdk-cdn = callPackage ../development/python-modules/aliyun-python-sdk-cdn { };
|
||||
|
||||
aliyun-python-sdk-config = callPackage ../development/python-modules/aliyun-python-sdk-config { };
|
||||
|
||||
Reference in New Issue
Block a user