Skip to content
Snippets Groups Projects
Commit 3f82ec74 authored by Julian's avatar Julian
Browse files

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.
parent ac731bf4
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,6 @@ image: registry.git.cccv.de/uffd/docker-images/buster ...@@ -3,7 +3,6 @@ image: registry.git.cccv.de/uffd/docker-images/buster
variables: variables:
DEBIAN_FRONTEND: noninteractive DEBIAN_FRONTEND: noninteractive
GIT_SUBMODULE_STRATEGY: normal GIT_SUBMODULE_STRATEGY: normal
PYTHONPATH: deps/ldapalchemy
APT_API_URL: https://packages.cccv.de APT_API_URL: https://packages.cccv.de
APT_REPO: uffd APT_REPO: uffd
PYLINT_PIN: pylint~=2.10.0 PYLINT_PIN: pylint~=2.10.0
...@@ -62,9 +61,7 @@ linter:buster: ...@@ -62,9 +61,7 @@ linter:buster:
stage: test stage: test
script: script:
- pip3 install $PYLINT_PIN pylint-gitlab pylint-flask-sqlalchemy # this force-updates jinja2 and some other packages! - 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 --output-format=pylint_gitlab.GitlabCodeClimateReporter:codeclimate.json,pylint_gitlab.GitlabPagesHtmlReporter:pylint.html,colorized uffd
- python3 -m pylint --exit-zero --rcfile .pylintrc --output-format=pylint_gitlab.GitlabPagesHtmlReporter uffd > pylint.html
- python3 -m pylint --rcfile .pylintrc --output-format=text uffd
artifacts: artifacts:
when: always when: always
paths: paths:
...@@ -77,9 +74,7 @@ linter:bullseye: ...@@ -77,9 +74,7 @@ linter:bullseye:
stage: test stage: test
script: script:
- pip3 install $PYLINT_PIN pylint-gitlab pylint-flask-sqlalchemy # this force-updates jinja2 and some other packages! - 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 --output-format=pylint_gitlab.GitlabCodeClimateReporter:codeclimate.json,pylint_gitlab.GitlabPagesHtmlReporter:pylint.html,colorized uffd
- python3 -m pylint --exit-zero --rcfile .pylintrc --output-format=pylint_gitlab.GitlabPagesHtmlReporter uffd > pylint.html
- python3 -m pylint --rcfile .pylintrc --output-format=text uffd
artifacts: artifacts:
when: always when: always
paths: paths:
...@@ -91,11 +86,11 @@ unittests:buster: ...@@ -91,11 +86,11 @@ unittests:buster:
image: registry.git.cccv.de/uffd/docker-images/buster image: registry.git.cccv.de/uffd/docker-images/buster
stage: test stage: test
script: script:
- service slapd start - python3-coverage run --include 'uffd/*.py' -m pytest --junitxml=report.xml || touch failed
- UNITTEST_OPENLDAP=1 python3-coverage run --include 'uffd/*.py' -m pytest --junitxml=report.xml || true
- python3-coverage report -m - python3-coverage report -m
- python3-coverage html - python3-coverage html
- python3-coverage xml - python3-coverage xml
- test ! -e failed
artifacts: artifacts:
when: always when: always
paths: paths:
...@@ -113,23 +108,11 @@ unittests:bullseye: ...@@ -113,23 +108,11 @@ unittests:bullseye:
image: registry.git.cccv.de/uffd/docker-images/bullseye image: registry.git.cccv.de/uffd/docker-images/bullseye
stage: test stage: test
script: script:
- service slapd start - python3 -m pytest --junitxml=report.xml
- 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
artifacts: artifacts:
when: always when: always
paths:
- htmlcov/index.html
- htmlcov
expose_as: 'Coverage Report'
reports: reports:
#coverage_report:
# coverage_format: cobertura
# path: coverage.xml
junit: report.xml junit: report.xml
#coverage: '/^TOTAL.*\s+(\d+\%)$/'
html5validator: html5validator:
stage: test stage: test
......
...@@ -11,7 +11,7 @@ ignore=CVS ...@@ -11,7 +11,7 @@ ignore=CVS
# Add files or directories matching the regex patterns to the blacklist. The # Add files or directories matching the regex patterns to the blacklist. The
# regex matches against base names, not paths. # regex matches against base names, not paths.
ignore-patterns=ldapalchemy ignore-patterns=
# Python code to execute, usually for sys.path manipulation such as # Python code to execute, usually for sys.path manipulation such as
# pygtk.require(). # pygtk.require().
......
...@@ -65,7 +65,7 @@ class TestMailViews(UffdTestCase): ...@@ -65,7 +65,7 @@ class TestMailViews(UffdTestCase):
self.assertEqual(sorted(m.receivers), ['foo@bar.com', 'test@bar.com']) self.assertEqual(sorted(m.receivers), ['foo@bar.com', 'test@bar.com'])
self.assertEqual(sorted(m.destinations), ['testadmin@mail.example.com', 'testuser@mail.example.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): def test_create_error(self):
r = self.client.post(path=url_for('mail.update'), r = self.client.post(path=url_for('mail.update'),
data={'mail-uid': 'test', 'mail-receivers': 'foo@bar.com\ntest@bar.com', data={'mail-uid': 'test', 'mail-receivers': 'foo@bar.com\ntest@bar.com',
......
...@@ -186,7 +186,7 @@ class TestRoleViews(UffdTestCase): ...@@ -186,7 +186,7 @@ class TestRoleViews(UffdTestCase):
self.assertEqual(role.name, 'base1') self.assertEqual(role.name, 'base1')
self.assertEqual(role.description, 'Base role description1') self.assertEqual(role.description, 'Base role description1')
self.assertSetEqual(set(role.groups), {self.get_access_group(), self.get_users_group()}) 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): def test_create(self):
self.assertIsNone(Role.query.filter_by(name='base').first()) self.assertIsNone(Role.query.filter_by(name='base').first())
......
...@@ -147,7 +147,7 @@ class TestSignupModel(UffdTestCase): ...@@ -147,7 +147,7 @@ class TestSignupModel(UffdTestCase):
self.assert_finish_failure(signup, 'wrongpassword') self.assert_finish_failure(signup, 'wrongpassword')
self.assert_finish_failure(refetch_signup(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') signup = Signup(loginname='testuser', displayname='New User', mail='test@example.com', password='notsecret')
self.assert_finish_failure(signup, 'notsecret') self.assert_finish_failure(signup, 'notsecret')
self.assert_finish_failure(refetch_signup(signup), 'notsecret') self.assert_finish_failure(refetch_signup(signup), 'notsecret')
......
...@@ -84,7 +84,6 @@ def create_app(test_config=None): # pylint: disable=too-many-locals,too-many-sta ...@@ -84,7 +84,6 @@ def create_app(test_config=None): # pylint: disable=too-many-locals,too-many-sta
@app.shell_context_processor @app.shell_context_processor
def push_request_context(): #pylint: disable=unused-variable 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__} return {'db': db} | {name: getattr(models, name) for name in models.__all__}
babel = Babel(app) babel = Babel(app)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment