Skip to content

Commit 8c34fd6

Browse files
committed
fix(tests): fix tests
* Reorganizes imports with the isort black profile. Co-Authored-by: Johnny Mariéthoz <Johnny.Mariethoz@rero.ch>
1 parent 9751f18 commit 8c34fd6

336 files changed

Lines changed: 14270 additions & 14646 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docker-services.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
# You should have received a copy of the GNU Affero General Public License
1616
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18-
version: '2.3'
1918
services:
2019
app:
2120
build:
@@ -109,7 +108,7 @@ services:
109108
ports:
110109
- "5555:5555"
111110
grobid:
112-
image: lfoppiano/grobid:0.8.0
111+
image: lfoppiano/grobid:latest-crf
113112
ports:
114113
- "8070:8070"
115114
- "8071:8071"

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@ appnope = { version = "*",optional = true }
268268
beautifulsoup4 = "^4.11.1"
269269
requests-mock = "^1.11.0"
270270

271+
[tool.isort]
272+
profile = "black"
273+
271274
[tool.pytest.ini_options]
272275
addopts = "--color=yes --isort --pydocstyle --exclude-warning-annotations --doctest-glob='*.rst' --doctest-modules --cov=sonar --cov-report=term-missing --ignore=setup.py --ignore=docs/conf.py -p celery.contrib.pytest"
273276
testpaths = ["docs", "tests", "sonar"]

sonar/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121

2222
from .version import __version__
2323

24-
__all__ = ('__version__', )
24+
__all__ = ("__version__",)

sonar/affiliations/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121

2222
from .affiliation_resolver import AffiliationResolver
2323

24-
__all__ = ('AffiliationResolver', )
24+
__all__ = ("AffiliationResolver",)

sonar/affiliations/affiliation_resolver.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
from fuzzywuzzy import fuzz
2323
from werkzeug.utils import cached_property
2424

25-
CSV_FILE = './data/affiliations.csv'
25+
CSV_FILE = "./data/affiliations.csv"
2626

2727

28-
class AffiliationResolver():
28+
class AffiliationResolver:
2929
"""Affiliation resolver."""
3030

3131
@cached_property
@@ -36,8 +36,8 @@ def affiliations(self):
3636
"""
3737
affiliations = []
3838

39-
with open(CSV_FILE, 'r') as file:
40-
reader = csv.reader(file, delimiter='\t')
39+
with open(CSV_FILE, "r") as file:
40+
reader = csv.reader(file, delimiter="\t")
4141
for row in reader:
4242
affiliation = []
4343
for index, value in enumerate(row):
@@ -64,21 +64,24 @@ def resolve(self, searched_affiliation):
6464
standard_form = affiliations[0]
6565
for affiliation in affiliations:
6666
score = fuzz.partial_ratio(searched_affiliation, affiliation)
67-
if (score > 92 and standard_form not in collected_affiliations):
67+
if score > 92 and standard_form not in collected_affiliations:
6868
# handle special case UZH / ZHdK
6969
# TODO: solve this special case by converting the CSV file to JSON
7070
# using rejected forms https://github.com/rero/sonar/issues/824
71-
if (affiliation.lower() == 'zurich university' and
72-
'zurich university of the arts' in searched_affiliation.lower()
71+
if (
72+
affiliation.lower() == "zurich university"
73+
and "zurich university of the arts"
74+
in searched_affiliation.lower()
7375
):
7476
continue
7577
# handle special case CERN/Lucerne
76-
if (affiliation.lower() == 'cern' and
77-
'lucerne' in searched_affiliation.lower()
78+
if (
79+
affiliation.lower() == "cern"
80+
and "lucerne" in searched_affiliation.lower()
7881
):
7982
continue
8083
# handle special case Freiburg im Breisgau
81-
if 'university of freiburg' in searched_affiliation.lower():
84+
if "university of freiburg" in searched_affiliation.lower():
8285
break
8386

8487
collected_affiliations.append(standard_form)

sonar/celery.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@
2626
# load .env and .flaskenv
2727
load_dotenv()
2828

29-
celery = create_celery_app(create_ui(
30-
SENTRY_TRANSPORT='raven.transport.http.HTTPTransport',
31-
RATELIMIT_ENABLED=False,
32-
))
29+
celery = create_celery_app(
30+
create_ui(
31+
SENTRY_TRANSPORT="raven.transport.http.HTTPTransport",
32+
RATELIMIT_ENABLED=False,
33+
)
34+
)
3335
"""Celery application for Invenio.
3436
Overrides SENTRY_TRANSPORT wih synchronous HTTP transport since Celery does not
3537
deal nicely with the default threaded transport.
3638
"""
3739

3840
# Trigger an app log message upon import. This makes Sentry logging
3941
# work with `get_task_logger(__name__)`.
40-
celery.flask_app.logger.info('Created Celery app')
42+
celery.flask_app.logger.info("Created Celery app")

0 commit comments

Comments
 (0)