Skip to content

Commit

Permalink
Use opentopography in place of open_topography
Browse files Browse the repository at this point in the history
Squished together is closer to the org name.
  • Loading branch information
mdpiper committed Jan 25, 2022
1 parent 7ea9502 commit 35dd04a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-test-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:

- name: Test
env:
OPEN_TOPOGRAPHY_API_KEY: ${{ secrets.OPEN_TOPOGRAPHY_API_KEY }}
OPENTOPOGRAPHY_API_KEY: ${{ secrets.OPENTOPOGRAPHY_API_KEY }}
run: |
pytest --cov=bmi_topography --cov-report=xml:./coverage.xml --cov-config=./setup.cfg -vvv
bmi-test bmi_topography:BmiTopography --config-file=./examples/config.yaml --root-dir=./examples -vvv
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ dmypy.json
.pyre/

# OpenTopography API key file
.open_topography.txt
.opentopography.txt
4 changes: 2 additions & 2 deletions bmi_topography/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def main(quiet, dem_type, south, north, west, east, output_format, no_fetch):
Once you have received your key, you can pass it to the *bmi-topography*
command in one of two ways:
1. As the environment variable, OPEN_TOPOGRAPHY_API_KEY.
2. As the contents of an *.open_topography.txt* file located either in
1. As the environment variable, OPENTOPOGRAPHY_API_KEY.
2. As the contents of an *.opentopography.txt* file located either in
your current directory or you home directory.
"""
topo = Topography(dem_type, south, north, west, east, output_format)
Expand Down
6 changes: 3 additions & 3 deletions bmi_topography/topography.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

def find_api_key():
"""Search for an API key."""
if "OPEN_TOPOGRAPHY_API_KEY" in os.environ:
api_key = os.environ["OPEN_TOPOGRAPHY_API_KEY"]
if "OPENTOPOGRAPHY_API_KEY" in os.environ:
api_key = os.environ["OPENTOPOGRAPHY_API_KEY"]
else:
api_key = read_first_of(
[".open_topography.txt", "~/.open_topography.txt"]
[".opentopography.txt", "~/.opentopography.txt"]
).strip()

return api_key
Expand Down
12 changes: 6 additions & 6 deletions tests/test_api_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@ def copy_environ(exclude=None):

def test_find_api_key_not_found():
"""The API key is not given anywhere"""
env = copy_environ(exclude="OPEN_TOPOGRAPHY_API_KEY")
env = copy_environ(exclude="OPENTOPOGRAPHY_API_KEY")
with mock.patch.dict(os.environ, env, clear=True):
assert find_api_key() == ""


@mock.patch.dict(os.environ, {"OPEN_TOPOGRAPHY_API_KEY": "foo"})
@mock.patch.dict(os.environ, {"OPENTOPOGRAPHY_API_KEY": "foo"})
def test_find_api_key_env(tmpdir):
"""The API key is an environment variable"""
with tmpdir.as_cwd():
with open(".open_topography.txt", "w") as fp:
with open(".opentopography.txt", "w") as fp:
fp.write("bar")
assert find_api_key() == "foo"


@mock.patch.dict(os.environ, {"OPEN_TOPOGRAPHY_API_KEY": "foo"})
@mock.patch.dict(os.environ, {"OPENTOPOGRAPHY_API_KEY": "foo"})
def test_find_api_key_from_file(tmpdir):
"""The API key is in a file"""
env = copy_environ(exclude="OPEN_TOPOGRAPHY_API_KEY")
env = copy_environ(exclude="OPENTOPOGRAPHY_API_KEY")
with tmpdir.as_cwd():
with open(".open_topography.txt", "w") as fp:
with open(".opentopography.txt", "w") as fp:
fp.write("bar")

with mock.patch.dict(os.environ, env, clear=True):
Expand Down

0 comments on commit 35dd04a

Please sign in to comment.