diff --git a/CHANGELOG.md b/CHANGELOG.md index 42272ed5..86db50a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [PEP 440](https://www.python.org/dev/peps/pep-0440/) and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] +### Fixed +* [679](https://github.com/dbekaert/RAiDER/pull/679) - Fixed a bug causing test_updateTrue to falsely pass. + ## [0.5.3] ### Fixed * Updates dem-stitcher to 2.5.8 to ensure new (ARIA-managed) url for reading the Geoid EGM 2008. See this [issue](https://github.com/ACCESS-Cloud-Based-InSAR/dem-stitcher/issues/96). diff --git a/test/credentials/test_envVars.py b/test/credentials/test_envVars.py index 9c8bcd07..1ec3ec28 100644 --- a/test/credentials/test_envVars.py +++ b/test/credentials/test_envVars.py @@ -90,19 +90,19 @@ def test_envVars( rc_path = rc_path.expanduser() rc_path.unlink(missing_ok=True) + # Give the rc file mock contents + rc_path.write_text(template.format(uid=random_string(), key=random_string())) + test_uid = random_string() test_key = random_string() with monkeypatch.context() as mp: mp.setenv(env_var_name_uid, test_uid) mp.setenv(env_var_name_key, test_key) - credentials.check_api(model_name, None, None, './', update_rc_file=False) + credentials.check_api(model_name, None, None, './', update_rc_file=True) expected_content = template.format(uid=test_uid, key=test_key) actual_content = rc_path.read_text() rc_path.unlink() - assert ( - expected_content == actual_content, - f'{rc_path} was not updated correctly' - ) + assert expected_content == actual_content, f'{rc_path} was not created correctly' diff --git a/test/credentials/test_updateTrue.py b/test/credentials/test_updateTrue.py index 9ed65fbc..5b31dbfc 100644 --- a/test/credentials/test_updateTrue.py +++ b/test/credentials/test_updateTrue.py @@ -77,15 +77,16 @@ def test_updateTrue(model_name, template): return rc_path = Path('./') / (hidden_ext + rc_filename) + # Give the rc file mock contents + rc_path.write_text(template.format(uid=random_string(), key=random_string())) + + # Use check_api to update the rc file test_uid = random_string() test_key = random_string() credentials.check_api(model_name, test_uid, test_key, './', update_rc_file=True) + # Check that the rc file was properly updated expected_content = template.format(uid=test_uid, key=test_key) actual_content = rc_path.read_text() rc_path.unlink() - - assert ( - expected_content == actual_content, - f'{rc_path} was not updated correctly' - ) + assert expected_content == actual_content, f'{rc_path} was not updated correctly' diff --git a/tools/RAiDER/models/credentials.py b/tools/RAiDER/models/credentials.py index 70900bca..e6c238cc 100644 --- a/tools/RAiDER/models/credentials.py +++ b/tools/RAiDER/models/credentials.py @@ -151,8 +151,8 @@ def check_api(model: str, # one that belongs to this URL. import netrc rc_path.touch() - netrc_credentials = netrc.netrc(rc_path) - netrc_credentials.hosts[url] = (uid, None, key) + netrc_credentials = netrc.netrc(str(rc_path)) + netrc_credentials.hosts[url] = (uid, '', key) rc_path.write_text(str(netrc_credentials)) rc_path.chmod(0o000600)