Skip to content

Commit

Permalink
SFR-2478: Make MUSE urls constant (#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
kylevillegas93 authored Jan 14, 2025
1 parent 3f7b7cf commit bd3c774
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 21 deletions.
3 changes: 0 additions & 3 deletions config/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ GITHUB_API_KEY: xxx
# Bardo CCE API URL
BARDO_CCE_API: xxx

# Project MUSE MARC endpoint
MUSE_MARC_URL: xxx

# Allowed sources of CORS requests to proxy endpoint
API_PROXY_CORS_ALLOWED: (?:Source1:Source2)

Expand Down
4 changes: 0 additions & 4 deletions config/production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ DRB_API_PORT: '80'
# Bardo CCE API URL
BARDO_CCE_API: http://sfr-c-ecsal-14v3injrieoy5-258691445.us-east-1.elb.amazonaws.com/search/

# Project MUSE MARC endpoint
MUSE_MARC_URL: https://about.muse.jhu.edu/lib/metadata?format=marc&content=book&include=oa&filename=open_access_books&no_auth=1
MUSE_CSV_URL: https://about.muse.jhu.edu/static/org/local/holdings/muse_book_metadata.csv

# Google Books API
# GOOGLE_BOOKS_KEY must be configured as a secret

Expand Down
4 changes: 0 additions & 4 deletions config/qa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ DRB_API_PORT: '80'
# Bardo CCE API URL
BARDO_CCE_API: http://sfr-c-ecsal-14v3injrieoy5-258691445.us-east-1.elb.amazonaws.com/search/

# Project MUSE MARC endpoint
MUSE_MARC_URL: https://about.muse.jhu.edu/lib/metadata?format=marc&content=book&include=oa&filename=open_access_books&no_auth=1
MUSE_CSV_URL: https://about.muse.jhu.edu/static/org/local/holdings/muse_book_metadata.csv

# Google Books API
# GOOGLE_BOOKS_KEY must be configured as a secret

Expand Down
10 changes: 4 additions & 6 deletions processes/ingest/muse.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@


class MUSEProcess(CoreProcess):
MARC_URL = 'https://about.muse.jhu.edu/lib/metadata?format=marc&content=book&include=oa&filename=open_access_books&no_auth=1'
MARC_CSV_URL = 'https://about.muse.jhu.edu/static/org/local/holdings/muse_book_metadata.csv'
MUSE_ROOT_URL = 'https://muse.jhu.edu'

def __init__(self, *args):
Expand Down Expand Up @@ -115,10 +117,8 @@ def importMARCRecords(self, full=False, startTimestamp=None, recID=None):
logger.debug(e)

def downloadMARCRecords(self):
marcURL = os.environ['MUSE_MARC_URL']

try:
museResponse = requests.get(marcURL, stream=True, timeout=30)
museResponse = requests.get(MUSEProcess.MARC_URL, stream=True, timeout=30)
museResponse.raise_for_status()
except(ReadTimeout, HTTPError) as e:
logger.error('Unable to load MUSE MARC records')
Expand All @@ -132,10 +132,8 @@ def downloadMARCRecords(self):
return BytesIO(content)

def downloadRecordUpdates(self):
marcCSVURL = os.environ['MUSE_CSV_URL']

try:
csvResponse = requests.get(marcCSVURL, stream=True, timeout=30)
csvResponse = requests.get(MUSEProcess.MARC_CSV_URL, stream=True, timeout=30)
csvResponse.raise_for_status()
except(ReadTimeout, HTTPError) as e:
logger.error('Unable to load MUSE CSV records')
Expand Down
2 changes: 0 additions & 2 deletions tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ class TestHelpers:
'NYPL_API_CLIENT_TOKEN_URL': 'test_api_token_url',
'GITHUB_API_KEY': 'test_github_key',
'BARDO_CCE_API': 'test_cce_url',
'MUSE_MARC_URL': 'test_muse_url',
'MUSE_CSV_URL': 'test_muse_csv',
'ENVIRONMENT': 'test'
}

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/processes/ingest/test_muse_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def test_downloadMARCRecords_success(self, testProcess, mocker):
testRecords = testProcess.downloadMARCRecords()

assert testRecords.read() == b'marc'
mockGet.assert_called_once_with('test_muse_url', stream=True, timeout=30)
mockGet.assert_called_once_with(MUSEProcess.MARC_URL, stream=True, timeout=30)

def test_downloadMARCRecords_failure(self, testProcess, mocker):
mockGet = mocker.patch.object(requests, 'get')
Expand All @@ -210,7 +210,7 @@ def test_downloadRecordUpdates_success(self, testProcess, testBookCSV, mocker):
testProcess.downloadRecordUpdates()

assert testProcess.updateDates == {'row1': datetime(2020, 1, 1), 'row3': datetime(2020, 1, 1)}
mockGet.assert_called_once_with('test_muse_csv', stream=True, timeout=30)
mockGet.assert_called_once_with(MUSEProcess.MARC_CSV_URL, stream=True, timeout=30)
mockResp.iter_lines.assert_called_once_with(decode_unicode=True)
mockCSV.assert_called_once_with('testFile', skipinitialspace=True)

Expand Down

0 comments on commit bd3c774

Please sign in to comment.