From cc79ffafa40ea5615ce7619f2108f419472509d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20Knau=C3=9F?= Date: Mon, 28 Dec 2020 01:31:42 +0100 Subject: [PATCH 1/4] weblate/test_merge_canonical_changes: Fix the last failing test. (sysadmin#17745) I still do not understand what is going on, why we logger is not catched by unittests. AS the test in it self successfully end if called as only test: python3 -m nose --tests tests.test_merge_canonical_changes:TestMCCMain.test_nothing_to_do In the end one test influence others. This patch gives us at least a working workaround. --- .../weblate/scripts/tests/test_merge_canonical_changes.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/files/weblate/scripts/tests/test_merge_canonical_changes.py b/files/weblate/scripts/tests/test_merge_canonical_changes.py index 74f7fef6..2db0d67a 100644 --- a/files/weblate/scripts/tests/test_merge_canonical_changes.py +++ b/files/weblate/scripts/tests/test_merge_canonical_changes.py @@ -1,5 +1,6 @@ import contextlib import functools +import logging import nose import os import pathlib @@ -242,16 +243,17 @@ class TestMCCMain(unittest.TestCase): cls.tempdir.cleanup() def merge_message(self, lines): - head = "merge with main git using update-weblate-git.\n\n" + head = "merge with main git using merge_canonical_changes.\n\n" return (head+"\n".join(lines)).strip() def test_nothing_to_do(self): """remote and master are on the same commit""" if sys.version_info < (3,7): raise nose.SkipTest('Cannot get logs for this tests with Python < 3.7.') - with self.assertLogs("merge_canonical_changes", level="DEBUG") as cm: + mcc.logger = logging.getLogger() + with self.assertLogs(level="DEBUG") as cm: mcc.main(self.repopath, "master", "remote-1", "remote-1") - self.assertEqual(cm.output[-1], "INFO:merge_canonical_changes:remote and local are on the same commit, nothing to do.") + self.assertEqual(cm.output[-1], "INFO:root:remote and local are on the same commit, nothing to do.") def test_remote_deleted_nonWikiPo(self): """remote deleted a nonWikiPo file, local don't -> fast-forward.""" -- GitLab From 98c32ff70d581082be155b874647a05504f48f54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20Knau=C3=9F?= Date: Mon, 28 Dec 2020 01:41:35 +0100 Subject: [PATCH 2/4] Revert "weblate/scripts: Skip test for Python < 3.7 (sysadmin#17745)" This reverts commit c9ec0651b8d4ae52e7e0cc2a9607f817c611ac25. --- files/weblate/scripts/HACKING | 2 -- files/weblate/scripts/tests/test_merge_canonical_changes.py | 4 ---- 2 files changed, 6 deletions(-) diff --git a/files/weblate/scripts/HACKING b/files/weblate/scripts/HACKING index 776fd9a2..9e1ff80d 100644 --- a/files/weblate/scripts/HACKING +++ b/files/weblate/scripts/HACKING @@ -45,8 +45,6 @@ tests were renamed in b8eac8c79aab489d553f3a939a7d3686f010c203 to `test_merge_canonical_changes.py` and `merge_canonical_changes.py` respectivelly. -NOTE (hefee 2020-11-24): skip the failing test for Python 3.5. They are worknig for my sid system with Python 3.8. Let's recheck when we run the tests on a Buster system. - Updating the source code being tested and the test suite -------------------------------------------------------- diff --git a/files/weblate/scripts/tests/test_merge_canonical_changes.py b/files/weblate/scripts/tests/test_merge_canonical_changes.py index 2db0d67a..0c7afd0f 100644 --- a/files/weblate/scripts/tests/test_merge_canonical_changes.py +++ b/files/weblate/scripts/tests/test_merge_canonical_changes.py @@ -1,12 +1,10 @@ import contextlib import functools import logging -import nose import os import pathlib import tempfile import unittest -import sys from unittest.mock import patch, Mock, call import git @@ -248,8 +246,6 @@ class TestMCCMain(unittest.TestCase): def test_nothing_to_do(self): """remote and master are on the same commit""" - if sys.version_info < (3,7): - raise nose.SkipTest('Cannot get logs for this tests with Python < 3.7.') mcc.logger = logging.getLogger() with self.assertLogs(level="DEBUG") as cm: mcc.main(self.repopath, "master", "remote-1", "remote-1") -- GitLab From 253e124fa3948bdc554097133cf3f794043b6833 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20Knau=C3=9F?= Date: Mon, 28 Dec 2020 01:43:25 +0100 Subject: [PATCH 3/4] weblate: Update HACKING file, as all tests are now successful. --- files/weblate/scripts/HACKING | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/files/weblate/scripts/HACKING b/files/weblate/scripts/HACKING index 9e1ff80d..7ae5c27a 100644 --- a/files/weblate/scripts/HACKING +++ b/files/weblate/scripts/HACKING @@ -26,25 +26,6 @@ Run the tests in a Vagrant VM You may also run `python3 -m nose --with-coverage --cover-html` to get a html coverage report for all files. -NOTE (hefee 2019-07-14): One test fails on the VM, but passes for me locally with a Buster system. -It seems like the nose on Stretch can't capture existing logs correctly, as I also miss all logs -triggered by the scripts. - -====================================================================== -FAIL: remote and master are on the same commit ----------------------------------------------------------------------- -Traceback (most recent call last): - File "/home/vagrant/puppet-tails/files/weblate/scripts/tests/test_update_weblate_git.py", line 249, in test_nothing_to_do - mcc.main(self.repopath, "master", "remote-1", "remote-1") -AssertionError: no logs of level DEBUG or higher triggered on update_weblate_git - ----------------------------------------------------------------------- - -NOTE (zen 2020-02-22): the test mentioned in the error above and the script it -tests were renamed in b8eac8c79aab489d553f3a939a7d3686f010c203 to -`test_merge_canonical_changes.py` and `merge_canonical_changes.py` -respectivelly. - Updating the source code being tested and the test suite -------------------------------------------------------- -- GitLab From 7da7bdfa3a788dda20fb36e9b6b13379b623f682 Mon Sep 17 00:00:00 2001 From: Zen Fu Date: Thu, 19 Nov 2020 12:26:42 -0300 Subject: [PATCH 4/4] Add Weblate scripts tests to the GitLab CI (sysadmin#17745) This uses a Docker executor to run Weblate script tests in a Debian 10 Docker container. Close: #17745 --- .gitlab-ci.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5fcaae2b..fb24338a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,12 +1,34 @@ image: debian:buster + before_script: - 'export DEBIAN_FRONTEND=noninteractive && apt-get update -qq && apt-get -qy install python3-nose python3-git python3-pytest puppet puppet-lint ruby' + test-weblate-update-hook: script: - cd files/gitolite/hooks - pytest-3 --verbose + +test-weblate-scripts: + services: + - redis:6-alpine + script: + - git clone --depth 1 --branch weblate-3.11.3 https://github.com/WeblateOrg/weblate.git /usr/local/share/weblate + - cp /usr/local/share/weblate/weblate/settings_example.py /usr/local/share/weblate/weblate/settings.py + - "sed -i 's%\"NAME\": \"weblate\"%\"NAME\": \"/tmp/weblate.sqlite3\"%' /usr/local/share/weblate/weblate/settings.py" + - "sed -i 's%\"ENGINE\": \"django.db.backends.postgresql\"%\"ENGINE\": \"django.db.backends.sqlite3\"%' /usr/local/share/weblate/weblate/settings.py" + - "sed -i 's%\"LOCATION\": \"redis://127.0.0.1:6379/1\"%\"LOCATION\": \"redis://redis:6379/1\"%' /usr/local/share/weblate/weblate/settings.py" + - "sed -i 's%\"redis://localhost:6379\"%\"redis://redis:6379\"%' /usr/local/share/weblate/weblate/settings.py" + - apt-get -qy install python3-pip python3-nose gettext pkg-config libglib2.0-dev libgirepository1.0-dev libcairo2-dev libxml2-dev libxslt1-dev gir1.2-pango-1.0 libssl-dev libacl1-dev postgresql-common postgresql-server-dev-all libpq-dev python3-gi python3-gi-cairo gir1.2-gtk-3.0 + - pip3 install -r /usr/local/share/weblate/requirements.txt kombu\<4.7 psycopg2 + - pip3 install -e /usr/local/share/weblate/ + - python3 /usr/local/share/weblate/manage.py migrate + - python3 /usr/local/share/weblate/manage.py shell -c "from weblate.trans.models.project import Project; Project(name='Tails', slug='tails', web='https://tails.boum.org').save()" + - python3 /usr/local/share/weblate/manage.py import_project --language-regex "^(de|fr)$" tails https://git.tails.boum.org/tails.git master "wiki/src/**.*.po" + - cd files/weblate/scripts + - python3 -m nose + check-puppet-code: script: - find . -name .git -prune -o \( -type f -name '*.pp' -exec puppet parser validate '{}' \; \) -- GitLab