|
21 | 21 | pytest.skip("Install mock for the casda tests.", allow_module_level=True) |
22 | 22 |
|
23 | 23 | DATA_FILES = {'CIRCLE': 'cone.xml', 'RANGE': 'box.xml', 'DATALINK': 'datalink.xml', 'RUN_JOB': 'run_job.xml', |
24 | | - 'COMPLETED_JOB': 'completed_job.xml'} |
| 24 | + 'COMPLETED_JOB': 'completed_job.xml', 'DATALINK_NOACCESS': 'datalink_noaccess.xml'} |
25 | 25 |
|
26 | 26 |
|
27 | 27 | class MockResponse: |
@@ -59,7 +59,10 @@ def get_mockreturn(self, method, url, data=None, timeout=10, |
59 | 59 | else: |
60 | 60 | raise ValueError("Unexpected SODA async {} call to url {}".format(method, url)) |
61 | 61 | elif 'datalink' in str(url): |
62 | | - key = 'DATALINK' |
| 62 | + if 'cube-244' in str(url): |
| 63 | + key = 'DATALINK' |
| 64 | + else: |
| 65 | + key = 'DATALINK_NOACCESS' |
63 | 66 | else: |
64 | 67 | key = params['POS'].split()[0] if params['POS'] else None |
65 | 68 | filename = data_path(DATA_FILES[key]) |
@@ -257,6 +260,19 @@ def test_stage_data_invalid_credentials(patch_get): |
257 | 260 | casda.stage_data(table) |
258 | 261 |
|
259 | 262 |
|
| 263 | +def test_stage_data_no_link(patch_get): |
| 264 | + prefix = 'https://somewhere/casda/datalink/links?' |
| 265 | + access_urls = [prefix + 'cube-240'] |
| 266 | + table = Table([Column(data=access_urls, name='access_url')]) |
| 267 | + casda = Casda('user', 'password') |
| 268 | + casda.POLL_INTERVAL = 1 |
| 269 | + |
| 270 | + with pytest.raises(ValueError) as excinfo: |
| 271 | + casda.stage_data(table) |
| 272 | + |
| 273 | + assert "You do not have access to any of the requested data files." in str(excinfo.value) |
| 274 | + |
| 275 | + |
260 | 276 | def test_stage_data(patch_get): |
261 | 277 | prefix = 'https://somewhere/casda/datalink/links?' |
262 | 278 | access_urls = [prefix + 'cube-244'] |
|
0 commit comments