From 3f82ec7431c708bb5c3d20bf2eff96258fc22459 Mon Sep 17 00:00:00 2001 From: Julian Rother <julian@cccv.de> Date: Mon, 15 Aug 2022 23:24:25 +0200 Subject: [PATCH] Cleanup CI tests and LDAP remnants Unittest jobs now fail if any test fails. Unittests on Bullseye no longer fail due to jinja2 import errors. Linter jobs run faster. --- .gitlab-ci.yml | 27 +++++---------------------- .pylintrc | 2 +- tests/test_mail.py | 2 +- tests/test_role.py | 2 +- tests/test_signup.py | 2 +- uffd/__init__.py | 1 - 6 files changed, 9 insertions(+), 27 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 968e49a5..2fbcc48c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,7 +3,6 @@ image: registry.git.cccv.de/uffd/docker-images/buster variables: DEBIAN_FRONTEND: noninteractive GIT_SUBMODULE_STRATEGY: normal - PYTHONPATH: deps/ldapalchemy APT_API_URL: https://packages.cccv.de APT_REPO: uffd PYLINT_PIN: pylint~=2.10.0 @@ -62,9 +61,7 @@ linter:buster: stage: test script: - pip3 install $PYLINT_PIN pylint-gitlab pylint-flask-sqlalchemy # this force-updates jinja2 and some other packages! - - python3 -m pylint --exit-zero --rcfile .pylintrc --output-format=pylint_gitlab.GitlabCodeClimateReporter uffd > codeclimate.json - - python3 -m pylint --exit-zero --rcfile .pylintrc --output-format=pylint_gitlab.GitlabPagesHtmlReporter uffd > pylint.html - - python3 -m pylint --rcfile .pylintrc --output-format=text uffd + - python3 -m pylint --output-format=pylint_gitlab.GitlabCodeClimateReporter:codeclimate.json,pylint_gitlab.GitlabPagesHtmlReporter:pylint.html,colorized uffd artifacts: when: always paths: @@ -77,9 +74,7 @@ linter:bullseye: stage: test script: - pip3 install $PYLINT_PIN pylint-gitlab pylint-flask-sqlalchemy # this force-updates jinja2 and some other packages! - - python3 -m pylint --exit-zero --rcfile .pylintrc --output-format=pylint_gitlab.GitlabCodeClimateReporter uffd > codeclimate.json - - python3 -m pylint --exit-zero --rcfile .pylintrc --output-format=pylint_gitlab.GitlabPagesHtmlReporter uffd > pylint.html - - python3 -m pylint --rcfile .pylintrc --output-format=text uffd + - python3 -m pylint --output-format=pylint_gitlab.GitlabCodeClimateReporter:codeclimate.json,pylint_gitlab.GitlabPagesHtmlReporter:pylint.html,colorized uffd artifacts: when: always paths: @@ -91,11 +86,11 @@ unittests:buster: image: registry.git.cccv.de/uffd/docker-images/buster stage: test script: - - service slapd start - - UNITTEST_OPENLDAP=1 python3-coverage run --include 'uffd/*.py' -m pytest --junitxml=report.xml || true + - python3-coverage run --include 'uffd/*.py' -m pytest --junitxml=report.xml || touch failed - python3-coverage report -m - python3-coverage html - python3-coverage xml + - test ! -e failed artifacts: when: always paths: @@ -113,23 +108,11 @@ unittests:bullseye: image: registry.git.cccv.de/uffd/docker-images/bullseye stage: test script: - - service slapd start - - UNITTEST_OPENLDAP=1 python3-coverage run --include 'uffd/*.py' -m pytest --junitxml=report.xml || true - #- python3-coverage report -m - - python3-coverage html - #- python3-coverage xml + - python3 -m pytest --junitxml=report.xml artifacts: when: always - paths: - - htmlcov/index.html - - htmlcov - expose_as: 'Coverage Report' reports: - #coverage_report: - # coverage_format: cobertura - # path: coverage.xml junit: report.xml - #coverage: '/^TOTAL.*\s+(\d+\%)$/' html5validator: stage: test diff --git a/.pylintrc b/.pylintrc index 00c3ae55..f3f57828 100644 --- a/.pylintrc +++ b/.pylintrc @@ -11,7 +11,7 @@ ignore=CVS # Add files or directories matching the regex patterns to the blacklist. The # regex matches against base names, not paths. -ignore-patterns=ldapalchemy +ignore-patterns= # Python code to execute, usually for sys.path manipulation such as # pygtk.require(). diff --git a/tests/test_mail.py b/tests/test_mail.py index f794486b..6660b3be 100644 --- a/tests/test_mail.py +++ b/tests/test_mail.py @@ -65,7 +65,7 @@ class TestMailViews(UffdTestCase): self.assertEqual(sorted(m.receivers), ['foo@bar.com', 'test@bar.com']) self.assertEqual(sorted(m.destinations), ['testadmin@mail.example.com', 'testuser@mail.example.com']) - @unittest.skip('We do not catch LDAP errors at the moment!') # TODO: Not sure if necessary + @unittest.skip('We do not catch DB errors at the moment!') # TODO def test_create_error(self): r = self.client.post(path=url_for('mail.update'), data={'mail-uid': 'test', 'mail-receivers': 'foo@bar.com\ntest@bar.com', diff --git a/tests/test_role.py b/tests/test_role.py index 7061d393..c02b862c 100644 --- a/tests/test_role.py +++ b/tests/test_role.py @@ -186,7 +186,7 @@ class TestRoleViews(UffdTestCase): self.assertEqual(role.name, 'base1') self.assertEqual(role.description, 'Base role description1') self.assertSetEqual(set(role.groups), {self.get_access_group(), self.get_users_group()}) - # TODO: verify that group memberships are updated (currently not possible with ldap mock!) + # TODO: verify that group memberships are updated def test_create(self): self.assertIsNone(Role.query.filter_by(name='base').first()) diff --git a/tests/test_signup.py b/tests/test_signup.py index 5979da3b..e77c7c46 100644 --- a/tests/test_signup.py +++ b/tests/test_signup.py @@ -147,7 +147,7 @@ class TestSignupModel(UffdTestCase): self.assert_finish_failure(signup, 'wrongpassword') self.assert_finish_failure(refetch_signup(signup), 'wrongpassword') - def test_finish_ldaperror(self): + def test_finish_duplicate(self): signup = Signup(loginname='testuser', displayname='New User', mail='test@example.com', password='notsecret') self.assert_finish_failure(signup, 'notsecret') self.assert_finish_failure(refetch_signup(signup), 'notsecret') diff --git a/uffd/__init__.py b/uffd/__init__.py index 6f48d7a0..d178c85f 100644 --- a/uffd/__init__.py +++ b/uffd/__init__.py @@ -84,7 +84,6 @@ def create_app(test_config=None): # pylint: disable=too-many-locals,too-many-sta @app.shell_context_processor def push_request_context(): #pylint: disable=unused-variable - app.test_request_context().push() # LDAP ORM requires request context return {'db': db} | {name: getattr(models, name) for name in models.__all__} babel = Babel(app) -- GitLab