Skip to content

Commit

Permalink
2nd attempt at fixing ci
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-chou committed Jun 1, 2021
1 parent 49d0e0e commit b9ae53e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
10 changes: 4 additions & 6 deletions service/microservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
import falcon
import requests

CLOUDSTORAGE_URL = os.environ.get('CLOUDSTORAGE_URL')
CLOUDSTORAGE_API_KEY = os.environ.get('CLOUDSTORAGE_API_KEY')

def start_service():
"""Start this service
set SENTRY_DSN environmental variable to enable logging with Sentry
Expand All @@ -26,16 +23,17 @@ def cloud_storage_service(_req, resp):
# determine whether to use amazon s3 or azure blob storage
# Use 'az' at beginning of the path to signal that file is from azure
# eg. https://domain.com/az/some_file.pdf
microservice_url = CLOUDSTORAGE_URL # default to s3
microservice_url = os.environ.get('CLOUDSTORAGE_URL') # default to s3

if path[0:3] == 'az/':
microservice_url = CLOUDSTORAGE_URL.replace('1.0', '2.0', 1)
microservice_url = microservice_url.replace('1.0', '2.0', 1)
path = path[3:]

response = requests.get(
microservice_url,
params={
'name':path,
'apikey':CLOUDSTORAGE_API_KEY
'apikey':os.environ.get('CLOUDSTORAGE_API_KEY')
}
)
resp.status = falcon.get_http_status(response.status_code)
Expand Down
11 changes: 8 additions & 3 deletions tests/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
from falcon import testing
import service.microservice

ENV_VARS = {
"CLOUDSTORAGE_URL": "https://endpoint.api.com",
"CLOUDSTORAGE_API_KEY": "1234567"
}

FILES_PATH = 'tests/resources/'

@pytest.fixture()
Expand All @@ -16,10 +21,10 @@ def client():
@pytest.fixture
def mock_env(monkeypatch):
""" mock environment var """
monkeypatch.setenv("CLOUDSTORAGE_URL", "https://endpoint.api.com")
monkeypatch.setenv("CLOUDSTORAGE_API_KEY", "1234567")
for key in ENV_VARS:
monkeypatch.setenv(key, ENV_VARS[key])

def test_endpoint(mock_env, client):
def test_endpoint(client, mock_env):
# pylint: disable=unused-argument
"""Test the endpoint"""

Expand Down

0 comments on commit b9ae53e

Please sign in to comment.