@@ -76,12 +76,14 @@ def callback(request, context):
7676 ) as matcher :
7777 yield matcher
7878
79+
7980@pytest .fixture ()
8081def datalink_cloud1 (mocker ):
81- def callback (request , context ):
82+ def callback (request , context ):
8283 dl_base = parse ('pyvo/dal/tests/data/datalink/datalink.xml' )
8384 dl_base_table = dl_base .get_first_table ().to_table ()
84- cloud_access_str = '{"aws": {"bucket_name": "test", "key":"path/to/cloudfile.fits", "region": "us-west-2"}}'
85+ cloud_access_str = ('{"aws": {"bucket_name": "test", '
86+ '"key":"path/to/cloudfile.fits", "region": "us-west-2"}}' )
8587 dl_base_table .add_column ([cloud_access_str ]* 4 , name = 'cloud_access' )
8688 out = BytesIO ()
8789 votable = from_table (dl_base_table )
@@ -94,14 +96,17 @@ def callback(request, context):
9496 ) as matcher :
9597 yield matcher
9698
99+
97100@pytest .fixture ()
98101def datalink_cloud2 (mocker ):
99- def callback (request , context ):
102+ def callback (request , context ):
100103 dl_base = parse ('pyvo/dal/tests/data/datalink/datalink.xml' )
101104 dl_base_table = dl_base .get_first_table ().to_table ()
102105 cloud_access_str = ('{"aws": '
103- '[{"bucket_name": "test", "key": "path/to/cloudfile.fits", "region": "us-west-2"}, '
104- '{"bucket_name": "test", "key": "path/to/cloudfile2.fits", "region": "us-west-2"}]}' )
106+ '[{"bucket_name": "test", '
107+ '"key": "path/to/cloudfile.fits", "region": "us-west-2"}, '
108+ '{"bucket_name": "test", '
109+ '"key": "path/to/cloudfile2.fits", "region": "us-west-2"}]}' )
105110 dl_base_table .add_column ([cloud_access_str ]* 4 , name = 'cloud_access' )
106111 out = BytesIO ()
107112 votable = from_table (dl_base_table )
@@ -114,6 +119,7 @@ def callback(request, context):
114119 ) as matcher :
115120 yield matcher
116121
122+
117123@pytest .fixture ()
118124def obscore_datalink (mocker ):
119125 def callback (request , context ):
@@ -376,31 +382,32 @@ def test_no_datalink():
376382 with pytest .raises (DALServiceError , match = "No datalink found for record." ):
377383 result .getdatalink ()
378384
385+
379386@pytest .mark .filterwarnings ("ignore::astropy.io.votable.exceptions.E02" )
380387@pytest .mark .usefixtures ('datalink_cloud1' , 'datalink_cloud2' , 'datalink_product' )
381388class TestJsonColumns :
382- """Tests for producing datalinks from tables containing links to
383- datalink documents.
389+ """Tests for parsing JSON in Records and Results columns.
384390 """
385391
386392 res = testing .create_dalresults ([
387- {"name" : "access_url" , "datatype" : "char" , "arraysize" : "*" ,
388- "ucd" : "meta.ref.url" },
389- {"name" : "access_format" , "datatype" : "char" , "arraysize" : "*" ,
390- "utype" : "meta.code.mime" },
391- {"name" : "cloud_access" , "datatype" : "char" , "arraysize" : "*" ,
392- "utype" : "adhoc:cloudstorage" , "ucd" : "meta.ref.cloudstorage" },],
393- [("http://example.com/datalink-cloud1.xml" ,
394- "application/x-votable+xml;content=datalink" ,
395- '{"aws": {"bucket_name": "test", "key":"path/to/file1.fits", "region": "us-west-2"}}' ,),
396- ("http://example.com/datalink-cloud2.xml" ,
397- "application/x-votable+xml;content=datalink" ,
398- '{"aws": {"bucket_name": "test", "key":"path/to/file2.fits", "region": "us-west-2"}}' ,),
399- ("http://example.com/datalink.xml" ,
400- "application/x-votable+xml;content=datalink" ,
401- '{"aws": {"bucket_name": "test", "key":"path/to/file2.fits", "region": "us-west-2"}}' ,),],
402- resultsClass = SIA2Results
403- )
393+ {"name" : "access_url" , "datatype" : "char" , "arraysize" : "*" ,
394+ "ucd" : "meta.ref.url" },
395+ {"name" : "access_format" , "datatype" : "char" , "arraysize" : "*" ,
396+ "utype" : "meta.code.mime" },
397+ {"name" : "cloud_access" , "datatype" : "char" , "arraysize" : "*" ,
398+ "utype" : "adhoc:cloudstorage" , "ucd" : "meta.ref.cloudstorage" },],
399+ [("http://example.com/datalink-cloud1.xml" ,
400+ "application/x-votable+xml;content=datalink" ,
401+ '{"aws": {"bucket_name": "test", "key":"path/to/file1.fits", "region": "us-west-2"}}' ,),
402+ ("http://example.com/datalink-cloud2.xml" ,
403+ "application/x-votable+xml;content=datalink" ,
404+ '{"aws": {"bucket_name": "test", "key":"path/to/file2.fits", "region": "us-west-2"}}' ,),
405+ ("http://example.com/datalink.xml" ,
406+ "application/x-votable+xml;content=datalink" ,
407+ '{"aws": {"bucket_name": "test", "key":"path/to/file2.fits", "region": "us-west-2"}}' ,),],
408+ resultsClass = SIA2Results
409+ )
410+
404411 def test_record_w_json (self ):
405412
406413 jsontxt = '{"aws": {"bucket_name": "test", "key":"path/to/file1.fits", "region": "us-west-2"}}'
@@ -413,11 +420,14 @@ def test_extra_key(self):
413420 # Check that giving extra kwargs matches parameters
414421 jsontxt = '{"aws": {"bucket_name": "test", "key":"path/to/file1.fits", "region": "us-west-2"}}'
415422 parsed_json_matches0 = self .res [0 ].parse_json_params (json_txt = jsontxt , json_key = "aws" )
416- parsed_json_matches1 = self .res [0 ].parse_json_params (json_txt = jsontxt , json_key = "aws" , region = "us-west-2" )
423+ parsed_json_matches1 = self .res [0 ].parse_json_params (json_txt = jsontxt ,
424+ json_key = "aws" , region = "us-west-2" )
417425
418426 assert parsed_json_matches0 == parsed_json_matches1
419427
420- parsed_json_matches2 = self .res [0 ].parse_json_params (json_txt = jsontxt , json_key = "aws" , region = "us-west-1" )
428+ parsed_json_matches2 = self .res [0 ].parse_json_params (json_txt = jsontxt ,
429+ json_key = "aws" ,
430+ region = "us-west-1" )
421431 assert len (parsed_json_matches2 ) == 0
422432
423433 def test_datalink_json (self ):
@@ -444,7 +454,9 @@ def test_existing_colname(self):
444454
445455 def no_column_in_datalink (self , capsys ):
446456 # All column guesses come back empty
447- parsed_cloud_params = self .res [1 ].get_cloud_params (provider = "aws" , colname = "cloud_access" , verbose = True )
457+ parsed_cloud_params = self .res [1 ].get_cloud_params (provider = "aws" ,
458+ colname = "cloud_access" ,
459+ verbose = True )
448460 assert "No column cloud_access" in capsys
449461 assert parsed_cloud_params is None
450462
@@ -463,4 +475,3 @@ def test_iter_datalink_json(self):
463475 assert parsed_json_matches [2 ]["record_row" ] == 1
464476 assert parsed_json_matches [2 ]["datalink_row" ] == 0
465477 assert parsed_json_matches [2 ]["key" ] == "path/to/cloudfile2.fits"
466-
0 commit comments