• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

dbekaert / RAiDER / 07570d2f-2174-4f46-b35a-1bf8a5be889a

10 Jun 2025 01:17AM UTC coverage: 94.415%. Remained the same
07570d2f-2174-4f46-b35a-1bf8a5be889a

Pull #726

circleci

garlic-os
Add note to existing users about CDS API changes
Pull Request #726: Update RAiDER for CDS API changes

10 of 13 new or added lines in 4 files covered. (76.92%)

9 existing lines in 4 files now uncovered.

3246 of 3438 relevant lines covered (94.42%)

0.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.0
/test/credentials/test_updateTrue.py
1
'''
2
When update_rc_file is True, the RC file should be:
3
- updated if it already exists,
4
- created if it doesn't,
5
- and for .netrc files, it should ONLY update the set of credentials related to
6
  the given weather model's API URL.
7
'''
8
import pytest
1✔
9

10
from pathlib import Path
1✔
11
from platform import system
1✔
12
from RAiDER.models import credentials
1✔
13
from test import random_string
1✔
14

15

16
@pytest.mark.parametrize(
1✔
17
    'model_name,template',
18
    [
19
        (
20
            'ERA5', (
21
                'url: https://cds.climate.copernicus.eu/api/v2\n'
22
                'key: {uid}:{key}\n'
23
            )
24
        ),
25
        (
26
            'ERA5T', (
27
                'url: https://cds.climate.copernicus.eu/api/v2\n'
28
                'key: {uid}:{key}\n'
29
            )
30
        ),
31
        (
32
            'HRES', (
33
                '{{\n'
34
                '    "url"   : "https://api.ecmwf.int/v1",\n'
35
                '    "key"   : "{key}",\n'
36
                '    "email" : "{uid}"\n'
37
                '}}\n'
38
            )
39
        ),
40
        (
41
            # Simulate a .netrc file with multiple sets of credentials.
42
            # The ones not for urs.earthdata.nasa.gov should NOT be touched.
43
            # Indentation is done with TABS, as that is what the netrc package
44
            # generates.
45
            'GMAO', (
46
                'machine example.com\n'
47
                '        login johndoe\n'
48
                '        password hunter2\n'
49
                'machine urs.earthdata.nasa.gov\n'
50
                '        login {uid}\n'
51
                '        password {key}\n'
52
                'machine 127.0.0.1\n'
53
                '        login bobsmith\n'
54
                '        password dolphins\n'
55
            )
56
        ),
57
        (
58
            'MERRA2', (
59
                'machine example.com\n'
60
                '        login johndoe\n'
61
                '        password hunter2\n'
62
                'machine urs.earthdata.nasa.gov\n'
63
                '        login {uid}\n'
64
                '        password {key}\n'
65
                'machine 127.0.0.1\n'
66
                '        login bobsmith\n'
67
                '        password dolphins\n'
68
            )
69
        ),
70
    ]
71
)
72
def test_updateTrue(model_name, template):
1✔
73
    # Get the rc file's path
74
    hidden_ext = '_' if system() == "Windows" else '.'
1✔
75
    rc_filename = credentials.RC_FILENAMES[model_name]
1✔
76
    if rc_filename is None:
1✔
UNCOV
77
        return
×
78
    rc_path = Path('./') / (hidden_ext + rc_filename)
1✔
79

80
    # Give the rc file mock contents
81
    rc_path.write_text(template.format(uid=random_string(), key=random_string()))
1✔
82

83
    # Use check_api to update the rc file
84
    test_uid = random_string()
1✔
85
    test_key = random_string()
1✔
86
    credentials.check_api(model_name, test_uid, test_key, './', update_rc_file=True)
1✔
87

88
    # Check that the rc file was properly updated
89
    expected_content = template.format(uid=test_uid, key=test_key)
1✔
90
    actual_content = rc_path.read_text()
1✔
91
    rc_path.unlink()
1✔
92
    assert expected_content == actual_content, f'{rc_path} was not updated correctly'
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc