Skip to content

Commit

Permalink
Refactor pytest fixture naming to comply with PT021
Browse files Browse the repository at this point in the history
  • Loading branch information
drona-gyawali committed Dec 30, 2024
1 parent 471ffcf commit f5467e1
Show file tree
Hide file tree
Showing 100 changed files with 161 additions and 183 deletions.
4 changes: 2 additions & 2 deletions openlibrary/accounts/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

import requests
import web
from validate_email import validate_email

from infogami import config
from infogami.infobase.client import ClientException
from infogami.utils.view import public, render_template
from validate_email import validate_email

from openlibrary.core import helpers, stats
from openlibrary.core.booknotes import Booknotes
from openlibrary.core.bookshelves import Bookshelves
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/admin/code.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os

import web

from infogami.utils.view import render_template

from openlibrary.admin import utils
from openlibrary.core import admin

Expand Down
1 change: 0 additions & 1 deletion openlibrary/admin/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""

import web

from infogami.utils import delegate, features
from infogami.utils.view import render_template

Expand Down
3 changes: 1 addition & 2 deletions openlibrary/app.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
"""Utilities to build the app.
"""

from web.template import TemplateResult

from infogami.utils import app as _app
from infogami.utils.macro import macro
from infogami.utils.view import public, render
from web.template import TemplateResult


class view(_app.page):
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/catalog/add_book/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

import requests
import web

from infogami import config

from openlibrary import accounts
from openlibrary.catalog.add_book.load_book import (
InvalidLanguage,
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/catalog/add_book/tests/test_add_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from datetime import datetime

import pytest

from infogami.infobase.client import Nothing
from infogami.infobase.core import Text

from openlibrary.catalog import add_book
from openlibrary.catalog.add_book import (
IndependentlyPublished,
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/catalog/get_ia.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import lxml.etree
import requests
from infogami import config
from lxml import etree

from infogami import config
from openlibrary.catalog.marc.marc_binary import MarcBinary
from openlibrary.catalog.marc.marc_xml import MarcXml
from openlibrary.core import ia
Expand Down
3 changes: 1 addition & 2 deletions openlibrary/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import os
import sys

import yaml

import infogami
import yaml
from infogami import config
from infogami.infobase import server

Expand Down
19 changes: 6 additions & 13 deletions openlibrary/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

import pytest
import web

from infogami.infobase.tests.pytest_wildcard import Wildcard
from infogami.utils import template
from infogami.utils.view import render_template as infobase_render_template

from openlibrary.core import helpers
from openlibrary.i18n import gettext
from openlibrary.mocks.mock_ia import mock_ia # noqa: F401 side effects may be needed
Expand Down Expand Up @@ -88,25 +88,18 @@ def render_template(request):
init_plugin = ol_infobase.init_plugin
ol_infobase.init_plugin = lambda: None

def undo():
ol_infobase.init_plugin = init_plugin

request.addfinalizer(undo)

from openlibrary.plugins.openlibrary import code

web.config.db_parameters = {}
code.setup_template_globals()

def finalizer():
template.disktemplates.clear()
web.ctx.clear()

request.addfinalizer(finalizer)

def render(name, *a, **kw):
as_string = kw.pop("as_string", True)
d = infobase_render_template(name, *a, **kw)
return str(d) if as_string else d

return render
yield render

ol_infobase.init_plugin = init_plugin
template.disktemplates.clear()
web.ctx.clear()
2 changes: 1 addition & 1 deletion openlibrary/core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import requests
import web

from infogami import config

from openlibrary.core import cache


Expand Down
2 changes: 1 addition & 1 deletion openlibrary/core/bookshelves.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from typing import Any, Final, Literal, TypedDict, cast

import web

from infogami.infobase.utils import flatten

from openlibrary.plugins.worksearch.search import get_solr
from openlibrary.utils.dateutil import DATE_ONE_MONTH_AGO, DATE_ONE_WEEK_AGO

Expand Down
2 changes: 1 addition & 1 deletion openlibrary/core/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

import memcache
import web

from infogami import config
from infogami.infobase.client import Nothing
from infogami.utils import stats

from openlibrary.core.helpers import NothingEncoder
from openlibrary.utils import olmemcache
from openlibrary.utils.dateutil import MINUTE_SECS
Expand Down
3 changes: 1 addition & 2 deletions openlibrary/core/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
from sqlite3 import IntegrityError

import web
from psycopg2.errors import UniqueViolation

from infogami.utils import stats
from psycopg2.errors import UniqueViolation


@web.memoize
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/core/edits.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import json
from sqlite3 import IntegrityError

from infogami.utils.view import public
from psycopg2.errors import UniqueViolation

from infogami.utils.view import public
from openlibrary.core import cache
from openlibrary.i18n import gettext as _
from openlibrary.utils import dateutil
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/core/fulltext.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import requests
import web

from infogami import config

from openlibrary.core.lending import get_availability_of_ocaids
from openlibrary.plugins.openlibrary.home import format_book_data

Expand Down
2 changes: 1 addition & 1 deletion openlibrary/core/ia.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

import requests
import web

from infogami import config
from infogami.utils import stats

from openlibrary.core import cache

logger = logging.getLogger('openlibrary.ia')
Expand Down
4 changes: 2 additions & 2 deletions openlibrary/core/lending.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import eventer
import requests
import web
from simplejson.errors import JSONDecodeError

from infogami.utils import delegate
from infogami.utils.view import public
from simplejson.errors import JSONDecodeError

from openlibrary.accounts.model import OpenLibraryAccount
from openlibrary.core import cache
from openlibrary.plugins.upstream.utils import urlencode
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/core/lists/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
from typing import TypedDict, cast

import web

from infogami import config # noqa: F401 side effects may be needed
from infogami.infobase import client, common # noqa: F401 side effects may be needed
from infogami.utils import stats # noqa: F401 side effects may be needed

from openlibrary.core import cache
from openlibrary.core import helpers as h
from openlibrary.core.models import Image, Subject, Thing, ThingKey, ThingReferenceDict
Expand Down
1 change: 0 additions & 1 deletion openlibrary/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import requests
import web

from infogami.infobase import client

# TODO: fix this. openlibrary.core should not import plugins.
Expand Down
1 change: 1 addition & 0 deletions openlibrary/core/observations.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from infogami import config
from infogami.utils.view import public

from openlibrary.utils import extract_numeric_id_from_olid
from openlibrary.utils.dateutil import DATE_ONE_MONTH_AGO, DATE_ONE_WEEK_AGO

Expand Down
1 change: 1 addition & 0 deletions openlibrary/core/olmarkdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import re

from infogami.utils.markdown import markdown

from openlibrary.core import helpers as h

# regexp to match urls and emails.
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/core/processors/invalidation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import datetime

import web

from infogami.infobase import client

from openlibrary.core import helpers as h

__all__ = ["InvalidationProcessor"]
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/core/processors/readableurls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import urllib

import web

from infogami.utils.view import render

from openlibrary.core import helpers as h

logger = logging.getLogger("openlibrary.readableurls")
Expand Down
1 change: 0 additions & 1 deletion openlibrary/core/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""

import web

from infogami.infobase import dbstore


Expand Down
1 change: 0 additions & 1 deletion openlibrary/core/sendmail.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import web

from infogami import config
from infogami.utils.view import render_template

Expand Down
3 changes: 1 addition & 2 deletions openlibrary/core/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@

import logging

from statsd import StatsClient

from infogami import config
from statsd import StatsClient

pystats_logger = logging.getLogger("openlibrary.pystats")

Expand Down
2 changes: 1 addition & 1 deletion openlibrary/core/vendors.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

import requests
from dateutil import parser as isoparser
from infogami.utils.view import public
from paapi5_python_sdk.api.default_api import DefaultApi
from paapi5_python_sdk.get_items_request import GetItemsRequest
from paapi5_python_sdk.get_items_resource import GetItemsResource
from paapi5_python_sdk.partner_type import PartnerType
from paapi5_python_sdk.rest import ApiException
from paapi5_python_sdk.search_items_request import SearchItemsRequest

from infogami.utils.view import public
from openlibrary import accounts
from openlibrary.catalog.add_book import load
from openlibrary.core import cache
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/coverstore/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

import internetarchive as ia
import web

from infogami.infobase import utils

from openlibrary.coverstore import config, db
from openlibrary.coverstore.coverlib import (
find_image_path, # noqa: F401 side effects may be needed
Expand Down
Loading

0 comments on commit f5467e1

Please sign in to comment.