From 04a07a655256c935749d8269b4fe4a357ee92c5e Mon Sep 17 00:00:00 2001 From: Kyle Villegas <86266231+kylevillegas93@users.noreply.github.com> Date: Mon, 18 Nov 2024 10:15:30 -0500 Subject: [PATCH] NO-REF: Refactoring statics (#448) --- constants/get_constants.py | 17 +++++++++++ {static => constants}/hathitrust.json | 0 {static => constants}/iso639.json | 0 {static => constants}/lc.json | 0 {static => constants}/marc.json | 0 mappings/base_mapping.py | 4 +-- mappings/csv.py | 4 +-- mappings/doab.py | 4 +-- mappings/gutenberg.py | 6 ++-- mappings/hathitrust.py | 12 ++++---- mappings/json.py | 4 +-- mappings/marc.py | 4 +-- mappings/nypl.py | 6 ++-- mappings/oclcCatalog.py | 4 +-- mappings/sql.py | 4 +-- mappings/xml.py | 4 +-- processes/cluster.py | 6 ++-- processes/core.py | 3 +- processes/ingest/doab.py | 5 +++- processes/ingest/gutenberg.py | 5 +++- processes/ingest/hathi_trust.py | 5 +++- .../local_development/seed_local_data.py | 4 ++- services/sources/nypl_bib_service.py | 6 ++-- static/manager.py | 29 ------------------- tests/unit/constants/__init__.py | 0 tests/unit/constants/test_get_constants.py | 10 +++++++ .../processes/frbr/test_catalog_process.py | 2 +- .../processes/ingest/test_doab_process.py | 2 +- .../ingest/test_gutenberg_process.py | 2 +- .../ingest/test_hathi_trust_process.py | 2 +- tests/unit/processes/test_cluster_process.py | 2 +- tests/unit/test_base_mapping_mapping.py | 6 ++-- tests/unit/test_csv_mapping.py | 4 +-- tests/unit/test_gutenberg_mapping.py | 6 ++-- tests/unit/test_hathitrust_mapping.py | 6 ++-- tests/unit/test_json_mapping.py | 4 +-- tests/unit/test_marc_mapping.py | 6 ++-- tests/unit/test_nypl_mapping.py | 6 ++-- tests/unit/test_oclcCatalog_mapping.py | 2 +- 39 files changed, 103 insertions(+), 93 deletions(-) create mode 100644 constants/get_constants.py rename {static => constants}/hathitrust.json (100%) rename {static => constants}/iso639.json (100%) rename {static => constants}/lc.json (100%) rename {static => constants}/marc.json (100%) delete mode 100644 static/manager.py create mode 100644 tests/unit/constants/__init__.py create mode 100644 tests/unit/constants/test_get_constants.py diff --git a/constants/get_constants.py b/constants/get_constants.py new file mode 100644 index 0000000000..3c3fd6de8a --- /dev/null +++ b/constants/get_constants.py @@ -0,0 +1,17 @@ +from glob import glob +import json +import re + + +def get_constants(): + constants = {} + + for path in glob('./constants/*.json'): + file_name = re.search(r'\/([a-z0-9]+)\.json', path).group(1) + + with open(path, 'r') as constants_file: + file_constants = json.load(constants_file) + + constants[file_name] = file_constants + + return constants diff --git a/static/hathitrust.json b/constants/hathitrust.json similarity index 100% rename from static/hathitrust.json rename to constants/hathitrust.json diff --git a/static/iso639.json b/constants/iso639.json similarity index 100% rename from static/iso639.json rename to constants/iso639.json diff --git a/static/lc.json b/constants/lc.json similarity index 100% rename from static/lc.json rename to constants/lc.json diff --git a/static/marc.json b/constants/marc.json similarity index 100% rename from static/marc.json rename to constants/marc.json diff --git a/mappings/base_mapping.py b/mappings/base_mapping.py index 568b7441a5..850a642d07 100644 --- a/mappings/base_mapping.py +++ b/mappings/base_mapping.py @@ -7,11 +7,11 @@ class BaseMapping(RecordMapping): - def __init__(self, source, statics): + def __init__(self, source, constants): self.mapping = {} self.source = source self.record = None - self.staticValues = statics + self.constants = constants self.formatter = CustomFormatter() diff --git a/mappings/csv.py b/mappings/csv.py index b518ab8514..c96a5faa78 100644 --- a/mappings/csv.py +++ b/mappings/csv.py @@ -4,8 +4,8 @@ logger = create_log(__name__) class CSVMapping(BaseMapping): - def __init__(self, source, statics): - super().__init__(source, statics) + def __init__(self, source, constants): + super().__init__(source, constants) def applyMapping(self): newRecord = self.initEmptyRecord() diff --git a/mappings/doab.py b/mappings/doab.py index 26a784af26..b435cc6095 100644 --- a/mappings/doab.py +++ b/mappings/doab.py @@ -4,8 +4,8 @@ class DOABMapping(XMLMapping): DOI_REGEX = r'doabooks.org\/handle\/([0-9]+\.[0-9]+\.[0-9]+\/[0-9]+)' - def __init__(self, source, namespace, statics): - super(DOABMapping, self).__init__(source, namespace, statics) + def __init__(self, source, namespace, constants): + super(DOABMapping, self).__init__(source, namespace, constants) self.mapping = self.createMapping() def createMapping(self): diff --git a/mappings/gutenberg.py b/mappings/gutenberg.py index 84d1873603..d35e9465f2 100644 --- a/mappings/gutenberg.py +++ b/mappings/gutenberg.py @@ -4,8 +4,8 @@ from mappings.xml import XMLMapping class GutenbergMapping(XMLMapping): - def __init__(self, source, namespace, statics): - super(GutenbergMapping, self).__init__(source, namespace, statics) + def __init__(self, source, namespace, constants): + super(GutenbergMapping, self).__init__(source, namespace, constants) self.mapping = self.createMapping() def createMapping(self): @@ -69,7 +69,7 @@ def applyFormatting(self): # Parse contributors to set proper roles for i, contributor in enumerate(self.record.contributors): contribComponents = contributor.split('|') - lcRelation = self.staticValues['lc']['relators'].get(contribComponents[-1], 'Contributor') + lcRelation = self.constants['lc']['relators'].get(contribComponents[-1], 'Contributor') self.record.contributors[i] = '{}|{}|{}|{}'.format( *contribComponents[:-1], lcRelation ) diff --git a/mappings/hathitrust.py b/mappings/hathitrust.py index 96ecb0f25c..8f24925886 100644 --- a/mappings/hathitrust.py +++ b/mappings/hathitrust.py @@ -5,8 +5,8 @@ class HathiMapping(CSVMapping): - def __init__(self, source, statics): - super(HathiMapping, self).__init__(source, statics) + def __init__(self, source, constants): + super(HathiMapping, self).__init__(source, constants) self.mapping = self.createMapping() def createMapping(self): @@ -67,15 +67,15 @@ def applyFormatting(self): self.record.contributors = self.record.contributors or [] for i, contributor in enumerate(self.record.contributors): contribElements = contributor.lower().split('|') - fullContribName = self.staticValues['hathitrust']['sourceCodes'].get(contribElements[0], contribElements[0]) + fullContribName = self.constants['hathitrust']['sourceCodes'].get(contribElements[0], contribElements[0]) self.record.contributors[i] = contributor.replace(contribElements[0], fullContribName) # Parse rights codes rightsElements = self.record.rights.split('|') if self.record.rights else [''] * 5 - rightsMetadata = self.staticValues['hathitrust']['rightsValues'].get(rightsElements[1], {'license': 'und', 'statement': 'und'}) + rightsMetadata = self.constants['hathitrust']['rightsValues'].get(rightsElements[1], {'license': 'und', 'statement': 'und'}) self.record.rights = 'hathitrust|{}|{}|{}|{}'.format( rightsMetadata['license'], - self.staticValues['hathitrust']['rightsReasons'].get(rightsElements[2], rightsElements[2]), + self.constants['hathitrust']['rightsReasons'].get(rightsElements[2], rightsElements[2]), rightsMetadata['statement'], rightsElements[4] ) @@ -102,4 +102,4 @@ def applyFormatting(self): # Parse spatial (pub place) codes self.record.spatial = self.record.spatial or '' - self.record.spatial = self.staticValues['marc']['countryCodes'].get(self.record.spatial.strip(), 'xx') \ No newline at end of file + self.record.spatial = self.constants['marc']['countryCodes'].get(self.record.spatial.strip(), 'xx') \ No newline at end of file diff --git a/mappings/json.py b/mappings/json.py index d249594971..300e94afbf 100644 --- a/mappings/json.py +++ b/mappings/json.py @@ -2,8 +2,8 @@ class JSONMapping(BaseMapping): - def __init__(self, source, statics): - super().__init__(source, statics) + def __init__(self, source, constants): + super().__init__(source, constants) def applyMapping(self): self.record = self.initEmptyRecord() diff --git a/mappings/marc.py b/mappings/marc.py index 17ff7e78e4..27972e808d 100644 --- a/mappings/marc.py +++ b/mappings/marc.py @@ -7,8 +7,8 @@ class MARCMapping(BaseMapping): - def __init__(self, source, statics): - super().__init__(source, statics) + def __init__(self, source, constants): + super().__init__(source, constants) def applyMapping(self): newRecord = self.initEmptyRecord() diff --git a/mappings/nypl.py b/mappings/nypl.py index 1896d97d88..d296711e9e 100644 --- a/mappings/nypl.py +++ b/mappings/nypl.py @@ -3,8 +3,8 @@ from .sql import SQLMapping class NYPLMapping(SQLMapping): - def __init__(self, source, bibItems, statics, locationCodes): - super().__init__(source, statics) + def __init__(self, source, bibItems, constants, locationCodes): + super().__init__(source, constants) self.mapping = self.createMapping() self.locationCodes = locationCodes self.bibItems = bibItems @@ -119,7 +119,7 @@ def applyFormatting(self): # Parse contributors to set proper roles for i, contributor in enumerate(self.record.contributors): contribComponents = contributor.split('|') - lcRelation = self.staticValues['lc']['relators'].get(contribComponents[-1], 'Contributor') + lcRelation = self.constants['lc']['relators'].get(contribComponents[-1], 'Contributor') self.record.contributors[i] = '{}|{}|{}|{}'.format( *contribComponents[:-1], lcRelation ) diff --git a/mappings/oclcCatalog.py b/mappings/oclcCatalog.py index 1a6d21338a..e738f4c8ca 100644 --- a/mappings/oclcCatalog.py +++ b/mappings/oclcCatalog.py @@ -16,8 +16,8 @@ class CatalogMapping(XMLMapping): 'hathitrust': r'catalog.hathitrust.org\/api\/volumes\/([a-z]{3,6}\/[a-zA-Z0-9]+)\.html' } - def __init__(self, source, namespace, statics): - super(CatalogMapping, self).__init__(source, namespace, statics) + def __init__(self, source, namespace, constants): + super(CatalogMapping, self).__init__(source, namespace, constants) self.mapping = self.createMapping() def createMapping(self): diff --git a/mappings/sql.py b/mappings/sql.py index 22e4869d0d..ddeeded0a0 100644 --- a/mappings/sql.py +++ b/mappings/sql.py @@ -5,8 +5,8 @@ class SQLMapping(BaseMapping): - def __init__(self, source, statics): - super().__init__(source, statics) + def __init__(self, source, constants): + super().__init__(source, constants) def applyMapping(self): newRecord = self.initEmptyRecord() diff --git a/mappings/xml.py b/mappings/xml.py index 72714bcfaa..c1b59336e0 100644 --- a/mappings/xml.py +++ b/mappings/xml.py @@ -8,8 +8,8 @@ class XMLMapping(BaseMapping): - def __init__(self, source, namespace, statics): - super().__init__(source, statics) + def __init__(self, source, namespace, constants): + super().__init__(source, constants) self.namespace = namespace def applyMapping(self): diff --git a/processes/cluster.py b/processes/cluster.py index 77b3d86fbf..3b604fb4e8 100644 --- a/processes/cluster.py +++ b/processes/cluster.py @@ -3,12 +3,12 @@ from sqlalchemy.exc import DataError from typing import Optional +from constants.get_constants import get_constants from .core import CoreProcess from managers import SFRRecordManager, KMeansManager, SFRElasticRecordManager, ElasticsearchManager, RedisManager from model import Record, Work from logger import create_log - logger = create_log(__name__) @@ -35,6 +35,8 @@ def __init__(self, *args): self.elastic_search_manager.createElasticSearchIngestPipeline() self.elastic_search_manager.createElasticSearchIndex() + self.constants = get_constants() + def runProcess(self): try: if self.process == 'daily': @@ -219,7 +221,7 @@ def get_matched_records(self, identifiers: list[str], already_matched_record_ids return matched_records def create_work_from_editions(self, editions, records): - record_manager = SFRRecordManager(self.session, self.statics['iso639']) + record_manager = SFRRecordManager(self.session, self.constants['iso639']) work_data = record_manager.buildWork(records, editions) diff --git a/processes/core.py b/processes/core.py index fb5c07870c..21723f84ab 100644 --- a/processes/core.py +++ b/processes/core.py @@ -1,6 +1,5 @@ from managers import DBManager, S3Manager from model import Record -from static.manager import StaticManager from logger import create_log @@ -8,7 +7,7 @@ logger = create_log(__name__) -class CoreProcess(DBManager, StaticManager, S3Manager): +class CoreProcess(DBManager, S3Manager): def __init__(self, process, customFile, ingestPeriod, singleRecord, batchSize=500): super(CoreProcess, self).__init__() self.process = process diff --git a/processes/ingest/doab.py b/processes/ingest/doab.py index beb88d8303..4622c27e13 100644 --- a/processes/ingest/doab.py +++ b/processes/ingest/doab.py @@ -4,6 +4,7 @@ import os import requests +from constants.get_constants import get_constants from ..core import CoreProcess from logger import create_log from mappings.doab import DOABMapping @@ -44,6 +45,8 @@ def __init__(self, *args): self.rabbitmq_manager.createRabbitConnection() self.rabbitmq_manager.createOrConnectQueue(self.fileQueue, self.fileRoute) + self.constants = get_constants() + def runProcess(self): if self.process == 'daily': self.importOAIRecords() @@ -61,7 +64,7 @@ def runProcess(self): def parseDOABRecord(self, oaiRec): try: - doabRec = DOABMapping(oaiRec, self.OAI_NAMESPACES, self.statics) + doabRec = DOABMapping(oaiRec, self.OAI_NAMESPACES, self.constants) doabRec.applyMapping() except MappingError as e: raise DOABError(e.message) diff --git a/processes/ingest/gutenberg.py b/processes/ingest/gutenberg.py index 40afe8333e..77c454ba8e 100644 --- a/processes/ingest/gutenberg.py +++ b/processes/ingest/gutenberg.py @@ -4,6 +4,7 @@ import os import re +from constants.get_constants import get_constants from ..core import CoreProcess from managers import GutenbergManager, RabbitMQManager from mappings.gutenberg import GutenbergMapping @@ -41,6 +42,8 @@ def __init__(self, *args): self.s3Bucket = os.environ['FILE_BUCKET'] + self.constants = get_constants() + def runProcess(self): if self.process == 'daily': self.importRDFRecords() @@ -89,7 +92,7 @@ def processGutenbergBatch(self, dataFiles): gutenbergRec = GutenbergMapping( gutenbergRDF, self.GUTENBERG_NAMESPACES, - self.statics + self.constants ) gutenbergRec.applyMapping() diff --git a/processes/ingest/hathi_trust.py b/processes/ingest/hathi_trust.py index 820150a2d5..9787297f1d 100644 --- a/processes/ingest/hathi_trust.py +++ b/processes/ingest/hathi_trust.py @@ -6,6 +6,7 @@ import requests from requests.exceptions import ReadTimeout, HTTPError +from constants.get_constants import get_constants from ..core import CoreProcess from mappings.hathitrust import HathiMapping from logger import create_log @@ -23,6 +24,8 @@ def __init__(self, *args): self.generateEngine() self.createSession() + self.constants = get_constants() + def runProcess(self): if self.process == 'daily': date_time = datetime.now(timezone.utc).replace(tzinfo=None) - timedelta(hours=24) @@ -47,7 +50,7 @@ def importFromSpecificFile(self, file_path): self.readHathiFile(hathiReader) def parseHathiDataRow(self, data_row): - hathiRec = HathiMapping(data_row, self.statics) + hathiRec = HathiMapping(data_row, self.constants) hathiRec.applyMapping() self.addDCDWToUpdateList(hathiRec) diff --git a/processes/local_development/seed_local_data.py b/processes/local_development/seed_local_data.py index 7b3758d880..3aa6014f17 100644 --- a/processes/local_development/seed_local_data.py +++ b/processes/local_development/seed_local_data.py @@ -4,6 +4,7 @@ import os import requests +from constants.get_constants import get_constants from ..core import CoreProcess from logger import create_log from managers import RedisManager @@ -18,6 +19,7 @@ def __init__(self, *args): super(SeedLocalDataProcess, self).__init__(*args[:4]) self.redis_manager = RedisManager() + self.constants = get_constants() def runProcess(self): try: @@ -86,7 +88,7 @@ def import_from_hathi_trust_data_file(self): book_right = book[2] if book_right not in in_copyright_statuses: - hathi_record = HathiMapping(book, self.statics) + hathi_record = HathiMapping(book, self.constants) hathi_record.applyMapping() self.addDCDWToUpdateList(hathi_record) diff --git a/services/sources/nypl_bib_service.py b/services/sources/nypl_bib_service.py index 1357c0b903..c5223d59f8 100644 --- a/services/sources/nypl_bib_service.py +++ b/services/sources/nypl_bib_service.py @@ -3,9 +3,9 @@ import requests from typing import Optional +from constants.get_constants import get_constants from logger import create_log from managers.db import DBManager -from static.manager import StaticManager from managers.nyplApi import NyplApiManager from mappings.nypl import NYPLMapping from .source_service import SourceService @@ -32,7 +32,7 @@ def __init__(self): self.location_codes = self.load_location_codes() self.cce_api = os.environ['BARDO_CCE_API'] - self.static_manager = StaticManager() + self.constants = get_constants() def get_records( self, @@ -79,7 +79,7 @@ def parse_nypl_bib(self, bib) -> Optional[NYPLMapping]: if self.is_pd_research_bib(dict(bib)): bib_items = self.fetch_bib_items(dict(bib)) - nypl_record = NYPLMapping(bib, bib_items, self.static_manager.statics, self.location_codes) + nypl_record = NYPLMapping(bib, bib_items, self.constants, self.location_codes) nypl_record.applyMapping() return nypl_record diff --git a/static/manager.py b/static/manager.py deleted file mode 100644 index 4afc078b9c..0000000000 --- a/static/manager.py +++ /dev/null @@ -1,29 +0,0 @@ -from glob import glob -import json -import re - - -class StaticManager: - def __init__(self): - super(StaticManager, self).__init__() - self.statics = {} - self.loadStaticFiles() - - def loadStaticFiles(self): - for staticPath in glob('./static/*.json'): - self.parseStaticPath(staticPath) - - def parseStaticPath(self, staticPath): - staticName = re.search(r'\/([a-z0-9]+)\.json', staticPath).group(1) - - with open(staticPath, 'r') as staticFile: - staticJSON = json.load(staticFile) - self.setStaticValues(staticJSON, staticName) - - def setStaticValues(self, staticJSON, staticName): - staticValDict = {} - - for key, value in staticJSON.items(): - staticValDict[key] = value - - self.statics[staticName] = staticValDict diff --git a/tests/unit/constants/__init__.py b/tests/unit/constants/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/unit/constants/test_get_constants.py b/tests/unit/constants/test_get_constants.py new file mode 100644 index 0000000000..2971f2c6b5 --- /dev/null +++ b/tests/unit/constants/test_get_constants.py @@ -0,0 +1,10 @@ +from constants.get_constants import get_constants + +def test_get_constants(): + constants = get_constants() + + assert constants is not None + assert constants.get('iso639', None) is not None + assert constants.get('lc', None) is not None + assert constants.get('hathitrust', None) is not None + assert constants.get('marc', None) is not None diff --git a/tests/unit/processes/frbr/test_catalog_process.py b/tests/unit/processes/frbr/test_catalog_process.py index eb32ebbd1d..5948114c01 100644 --- a/tests/unit/processes/frbr/test_catalog_process.py +++ b/tests/unit/processes/frbr/test_catalog_process.py @@ -18,7 +18,7 @@ def teardown_class(cls): def test_instance(self, mocker): class TestCatalogProcess(CatalogProcess): def __init__(self): - self.statics = {} + self.constants = {} self.oclc_catalog_manager = mocker.MagicMock() self.records = [] self.rabbitmq_manager = mocker.MagicMock() diff --git a/tests/unit/processes/ingest/test_doab_process.py b/tests/unit/processes/ingest/test_doab_process.py index 013b53ac7b..683e9134bd 100644 --- a/tests/unit/processes/ingest/test_doab_process.py +++ b/tests/unit/processes/ingest/test_doab_process.py @@ -27,7 +27,7 @@ def __init__(self): self.s3Bucket = 'test_aws_bucket' self.fileQueue = 'test_file_queue' self.fileRoute = 'test_file_key' - self.statics = {} + self.constants = {} self.ingestOffset = 0 self.ingestLimit = 10000 diff --git a/tests/unit/processes/ingest/test_gutenberg_process.py b/tests/unit/processes/ingest/test_gutenberg_process.py index 3d86fb8575..984164f71f 100644 --- a/tests/unit/processes/ingest/test_gutenberg_process.py +++ b/tests/unit/processes/ingest/test_gutenberg_process.py @@ -20,7 +20,7 @@ def teardown_class(cls): def testInstance(self, mocker): class TestGutenbergProcess(GutenbergProcess): def __init__(self, process, customFile, ingestPeriod): - self.statics = {} + self.constants = {} self.ingestOffset = 0 self.ingestLimit = 5000 self.s3Bucket = os.environ['FILE_BUCKET'] diff --git a/tests/unit/processes/ingest/test_hathi_trust_process.py b/tests/unit/processes/ingest/test_hathi_trust_process.py index d7044f84e1..311d083958 100644 --- a/tests/unit/processes/ingest/test_hathi_trust_process.py +++ b/tests/unit/processes/ingest/test_hathi_trust_process.py @@ -22,7 +22,7 @@ def teardown_class(cls): def testInstance(self, mocker): class TestHathiProcess(HathiTrustProcess): def __init__(self, process, customFile, ingestPeriod): - self.statics = {} + self.constants = {} self.records = [] self.ingest_limit = None diff --git a/tests/unit/processes/test_cluster_process.py b/tests/unit/processes/test_cluster_process.py index c72686c126..20745c1f45 100644 --- a/tests/unit/processes/test_cluster_process.py +++ b/tests/unit/processes/test_cluster_process.py @@ -21,7 +21,7 @@ def testInstance(self, mocker): class TestClusterProcess(ClusterProcess): def __init__(self): self.records = [] - self.statics = { 'iso639': {} } + self.constants = { 'iso639': {} } self.session = mocker.Mock() self.engine = mocker.Mock() diff --git a/tests/unit/test_base_mapping_mapping.py b/tests/unit/test_base_mapping_mapping.py index 19fa2100fb..74d4574c43 100644 --- a/tests/unit/test_base_mapping_mapping.py +++ b/tests/unit/test_base_mapping_mapping.py @@ -7,8 +7,8 @@ class TestCoreMapping: @pytest.fixture def testMapping(self, mocker): class TestCore(BaseMapping): - def ___init__(self, source, statics): - super(self, TestCore).__init__(source, statics) + def ___init__(self, source, constants): + super(self, TestCore).__init__(source, constants) def createMapping(self): pass @@ -21,7 +21,7 @@ def test_initializer(self, testMapping): assert testMapping.mapping == {} assert testMapping.source == 'test' assert testMapping.record == None - assert testMapping.staticValues == {'static': 'values'} + assert testMapping.constants == {'static': 'values'} assert testMapping.formatter == 'mockFormatter' def test_initEmptyRecord(self, testMapping, mocker): diff --git a/tests/unit/test_csv_mapping.py b/tests/unit/test_csv_mapping.py index 089a72cc3e..c89349cdd6 100644 --- a/tests/unit/test_csv_mapping.py +++ b/tests/unit/test_csv_mapping.py @@ -28,10 +28,10 @@ def testSource_missing(self): @pytest.fixture def testMapper(self, testMapping, mocker): class TestCSV(CSVMapping): - def __init__(self, source, mapping, statics): + def __init__(self, source, mapping, constants): self.source = source self.mapping = mapping - self.statics = statics + self.constants = constants def createMapping(self): pass diff --git a/tests/unit/test_gutenberg_mapping.py b/tests/unit/test_gutenberg_mapping.py index 3d3b268a4f..03799ebd57 100644 --- a/tests/unit/test_gutenberg_mapping.py +++ b/tests/unit/test_gutenberg_mapping.py @@ -5,12 +5,12 @@ class TestGutenbergMapping: @pytest.fixture - def testMapping(self, testStatics): + def testMapping(self, test_constants): class TestGutenberg(GutenbergMapping): def __init__(self): self.source = None self.mapping = None - self.staticValues = testStatics + self.constants = test_constants self.namespace = None def applyMapping(self): @@ -28,7 +28,7 @@ def testRecord_standard(self, mocker): ) @pytest.fixture - def testStatics(self): + def test_constants(self): return { 'lc': { 'relators': {'tst': 'Tester'} diff --git a/tests/unit/test_hathitrust_mapping.py b/tests/unit/test_hathitrust_mapping.py index 5b0758fe0c..0598a2e969 100644 --- a/tests/unit/test_hathitrust_mapping.py +++ b/tests/unit/test_hathitrust_mapping.py @@ -5,12 +5,12 @@ class TestHathingMapping: @pytest.fixture - def testMapping(self, testStatics): + def testMapping(self, test_constants): class TestHathi(HathiMapping): def __init__(self): self.source = None self.mapping = None - self.staticValues = testStatics + self.constants = test_constants def applyMapping(self): pass @@ -28,7 +28,7 @@ def testRecord_standard(self, mocker): ) @pytest.fixture - def testStatics(self): + def test_constants(self): return { 'hathitrust': { 'sourceCodes': {'contr': 'Contributor'}, diff --git a/tests/unit/test_json_mapping.py b/tests/unit/test_json_mapping.py index fe6f98c99f..d19cfcd80d 100644 --- a/tests/unit/test_json_mapping.py +++ b/tests/unit/test_json_mapping.py @@ -32,10 +32,10 @@ def testDocument(self): @pytest.fixture def testMapper(self, testMapping, testDocument, mocker): class TestJSON(JSONMapping): - def __init__(self, source, mapping, statics): + def __init__(self, source, mapping, constants): self.source = source self.mapping = mapping - self.statics = statics + self.constants = constants def createMapping(self): pass diff --git a/tests/unit/test_marc_mapping.py b/tests/unit/test_marc_mapping.py index 589feebeec..ff3d007106 100644 --- a/tests/unit/test_marc_mapping.py +++ b/tests/unit/test_marc_mapping.py @@ -26,11 +26,11 @@ def testRecord(self, mocker): @pytest.fixture def testMapper(self, testFields, testRecord): class TestMARC(MARCMapping): - def __init__(self, source, mapping, statics): - super().__init__(source, statics) + def __init__(self, source, mapping, constants): + super().__init__(source, constants) self.source = source self.mapping = mapping - self.statics = statics + self.constants = constants def createMapping(self): pass diff --git a/tests/unit/test_nypl_mapping.py b/tests/unit/test_nypl_mapping.py index 366509a10b..2bc1c1185a 100644 --- a/tests/unit/test_nypl_mapping.py +++ b/tests/unit/test_nypl_mapping.py @@ -5,17 +5,17 @@ class TestNYPLMapping: @pytest.fixture - def testMapping(self, testStatics): + def testMapping(self, test_constants): class TestNYPL(NYPLMapping): def __init__(self): self.source = None self.mapping = None - self.staticValues = testStatics + self.constants = test_constants return TestNYPL() @pytest.fixture - def testStatics(self): + def test_constants(self): return { 'lc': { 'relators': {'tst': 'Tester'} diff --git a/tests/unit/test_oclcCatalog_mapping.py b/tests/unit/test_oclcCatalog_mapping.py index 7cf44de024..c56426366b 100644 --- a/tests/unit/test_oclcCatalog_mapping.py +++ b/tests/unit/test_oclcCatalog_mapping.py @@ -12,7 +12,7 @@ class TestOCLCCatalog(CatalogMapping): def __init__(self): self.source = None self.mapping = None - self.staticValues = None + self.constants = None self.namespace = None def applyMapping(self):