Skip to content

Commit

Permalink
fix(tests): fix test problems
Browse files Browse the repository at this point in the history
- Constraints isort>=6.0.0 to make sure tests pass and fixes code style errors.
- Constraints black version to pass tests.
- Constraints babel version to fix date_filter comma problem.
- Fixes unwanted warning annotations in github actions
with `pytest-github-actions-annotate-failures`>0.3.0.

Co-Authored-by: Pascal Repond <[email protected]>
  • Loading branch information
PascalRepond committed Feb 5, 2025
1 parent 9d7de8c commit fb5d7c4
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 54 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/continuous-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ jobs:

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 2.0.1

# - name: Use Cache
# uses: actions/cache@v2
Expand Down
85 changes: 48 additions & 37 deletions poetry.lock

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,14 @@ dependencies = [
"flask-wiki (>=0.3.1)",
"dnspython (>2.4.2)",
"cryptography (>41.0.7)",
"babel (>2.14.0)",
"babel (>2.16.0)",
"rero-invenio-files (>=1.0.0,<2.0.0)",
"levenshtein (>=0.26.0)",
"unidecode (>=1.3.8)",
"flask-menu (<2.0.0)",
"poethepoet",
"isort (>=6.0.0)",
"black (>=25.1.0,<26.0.0)",
]

[project.optional-dependencies]
Expand Down Expand Up @@ -476,7 +478,7 @@ update = {cmd = "./scripts/update", help = "Runs update"}
profile = "black"

[tool.pytest]
addopts = "--color=yes --black --isort --pydocstyle --doctest-glob=\"*.rst\" --doctest-modules --cov=rero_ils --cov-report=term-missing --ignore=setup.py --ignore=docs/conf.py --ignore=rero_ils/config.py -m \"not external\""
addopts = "--color=yes --black --isort --exclude-warning-annotations --pydocstyle --doctest-glob=\"*.rst\" --doctest-modules --cov=rero_ils --cov-report=term-missing --ignore=setup.py --ignore=docs/conf.py --ignore=rero_ils/config.py -m \"not external\""
testpaths = "docs tests rero_ils"
# custom markers
markers = "external: mark a test as dealing with external services."
Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

[pytest]
live_server_scope = module
addopts = --color=yes --black --isort --pydocstyle --doctest-glob="*.rst" --doctest-modules --cov=rero_ils --cov-report=term-missing --ignore=setup.py --ignore=docs/conf.py --ignore=rero_ils/config.py -m "not external"
addopts = --color=yes --black --isort --exclude-warning-annotations --pydocstyle --doctest-glob="*.rst" --doctest-modules --cov=rero_ils --cov-report=term-missing --ignore=setup.py --ignore=docs/conf.py --ignore=rero_ils/config.py -m "not external"
testpaths = docs tests rero_ils

# custom markers
Expand Down
2 changes: 1 addition & 1 deletion rero_ils/dojson/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def remove_trailing_punctuation(data, punctuation=",", spaced_punctuation=":;/-"
).rstrip()


def remove_special_characters(value, chars=["\u0098", "\u009C"]):
def remove_special_characters(value, chars=["\u0098", "\u009c"]):
"""Remove special characters from a string.
:params value: string to clean.
Expand Down
4 changes: 3 additions & 1 deletion rero_ils/modules/serializers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

"""RERO ILS Record serialization."""

from invenio_records_rest.serializers.response import record_responsify
from invenio_records_rest.serializers.response import (
record_responsify,
)
from invenio_records_rest.serializers.response import (
search_responsify as _search_responsify,
)
Expand Down
2 changes: 1 addition & 1 deletion rero_ils/modules/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,7 @@ def get_objects(record_class, query):

def strip_chars(string, extra=""):
"""Remove control characters from string."""
remove_re = re.compile("[\x00-\x08\x0B-\x0C\x0E-\x1F\x7F%s]" % extra)
remove_re = re.compile("[\x00-\x08\x0b-\x0c\x0e-\x1f\x7f%s]" % extra)
new_string, _ = remove_re.subn("", string)
return new_string

Expand Down
4 changes: 3 additions & 1 deletion rero_ils/modules/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
manage_role_permissions,
)
from .permissions import permission_management as permission_management_action
from .permissions import record_permissions
from .permissions import (
record_permissions,
)

api_blueprint = Blueprint("api_blueprint", __name__, url_prefix="")

Expand Down
4 changes: 2 additions & 2 deletions tests/ui/locations/test_locations_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

"""Other location Record tests.
Some tests cannot be added in other files for several reason such as
scope level fixtures.
Some tests cannot be added in other files for several reason such as
scope level fixtures.
"""

from rero_ils.modules.items.api import ItemsSearch
Expand Down
4 changes: 3 additions & 1 deletion tests/ui/patron_transactions/test_patron_transactions_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@

import pytest

from rero_ils.modules.patron_transactions.api import PatronTransaction
from rero_ils.modules.patron_transactions.api import (
PatronTransaction,
)
from rero_ils.modules.patron_transactions.api import (
patron_transaction_id_fetcher as fetcher,
)
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_get_record_by_ref(document_data, document):
def test_date_filter_format_timestamp_en(app):
"""Test full english date and tile filter."""
datestring = format_date_filter("2018-06-06T09:29:55.947149+00:00")
assert "Wednesday 6 June 2018, 11:29:55" in datestring
assert "Wednesday, 6 June 2018, 11:29:55" in datestring

datestring = format_date_filter("2018-06-06T09:29:55.947149+00:00", locale="fr")
assert "mercredi 6 juin 2018, 11:29:55" in datestring
Expand All @@ -59,7 +59,7 @@ def test_date_filter_timezone(app):
datestring = format_date_filter(
"2018-06-06T09:29:55.947149+00:00", timezone="Europe/Helsinki"
)
assert "Wednesday 6 June 2018, 12:29:55" in datestring
assert "Wednesday, 6 June 2018, 12:29:55" in datestring


def test_date_filter_format_medium_date_en(app):
Expand All @@ -73,7 +73,7 @@ def test_date_filter_format_medium_date_en(app):
def test_date_filter_format_full_en(app):
"""Test full english date filter."""
datestring = format_date_filter("1950-01-01", date_format="full", time_format=None)
assert "Sunday 1 January 1950" in datestring
assert "Sunday, 1 January 1950" in datestring


def test_date_filter_format_full_fr(app):
Expand Down Expand Up @@ -111,7 +111,7 @@ def test_time_filter_format_fr(app):
def test_time_filter_format_delimiter(app):
"""Test default time."""
datestring = format_date_filter("2018-06-06T09:29:55.947149+00:00", delimiter=" - ")
assert datestring == "Wednesday 6 June 2018 - 11:29:55"
assert datestring == "Wednesday, 6 June 2018 - 11:29:55"


def test_to_pretty():
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/test_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

""""Test permissions."""
"""Test permissions."""
from utils import login_user_for_view

from rero_ils.modules.permissions import has_superuser_access
Expand Down

0 comments on commit fb5d7c4

Please sign in to comment.