@@ -13,38 +13,50 @@ def shared_cache_directory(tmp_path_factory):
1313
1414
1515class Test_PDB_Downloader_BaseFunctionality ():
16- """Test Public API of Pdb_Downloader ()"""
16+ """Test Public API of PDBDownloader ()"""
1717
1818 valid_file_formats = ("pdb.gz" , "pdb" )
1919
20- def test_base_functionality (self ):
20+ def test_file_formats (self ):
2121 """Test file_formats and keywords in convert_to_universe()"""
2222
2323 universe_list = []
2424 for file_format in self .valid_file_formats :
2525 downloader = mda .web .PDBDownloader (PDB_ID = working_PDB_ID , file_format = file_format ).download ()
26- universe_list .append (downloader .convert_to_universe (in_memory = True ))
26+ universe_list .append (downloader .convert_to_universe ())
2727
2828 assert all (isinstance (universe , mda .Universe ) for universe in universe_list )
2929
30+ def test_keywords (self ):
31+ """Test keywords download() and convert_to_universe() in PDBDownloader"""
32+
33+ downloader = mda .web .PDBDownloader (PDB_ID = working_PDB_ID ).download (progress_bar = True )
34+ u = downloader .convert_to_universe (in_memory = True )
35+
36+
37+ assert isinstance (u , mda .Universe )
38+
3039 def test_timeout (self ):
31- """Checks requests timeout Exception for fetch_pdb and PdbDownloader """
40+ """Checks requests timeout Exception for fetch_pdb and PDBDownloader """
3241 with pytest .raises (requests .exceptions .ConnectTimeout ):
3342 mda .web .PDBDownloader (PDB_ID = working_PDB_ID ).download (timeout = 0.0000001 )
3443
35- def test_invalid_id (self ):
36- """Test invalid id for PdbDownloader """
44+ def test_invalid_PDB_id (self ):
45+ """Test invalid id for PDBDownloader """
3746
3847 with pytest .raises (mda .web .downloaders .FileDownloadPDBError ):
39- mda .web .PDBDownloader (PDB_ID = 'BananaBoat' ).download ()
48+ mda .web .PDBDownloader (PDB_ID = 'BananaBoat' ).download ()
49+
50+ def test_premature_convert_to_universe (self ):
51+ """Tests if convert_to_universe() was called before download()"""
52+
53+ with pytest .raises (RuntimeError ):
54+ mda .web .PDBDownloader (PDB_ID = 'BananaBoat' ).convert_to_universe ()
4055
4156class Test_Pdb_Downloader_Cache ():
4257 ### Cache Test underneath
4358 file_format = "pdb.gz" # default format for PdbDownloader
4459
45- def test_file_format (self ):
46- assert self .file_format == "pdb.gz"
47-
4860 def test_file_name_cache (self , shared_cache_directory ):
4961 """Test that cache is saved as ID.file_format"""
5062 downloader = mda .web .PDBDownloader (PDB_ID = working_PDB_ID ,)
@@ -54,7 +66,7 @@ def test_file_name_cache(self, shared_cache_directory):
5466 assert shared_cache_directory / f"{ working_PDB_ID } .{ self .file_format } "
5567
5668 def test_loading_cache (self , shared_cache_directory ):
57- """Test that PdbDownloader .download() is reading cache"""
69+ """Test that PDBDownloader .download() is reading cache"""
5870
5971 downloader1 = mda .web .PDBDownloader (PDB_ID = working_PDB_ID ,
6072 file_format = self .file_format )
@@ -89,8 +101,3 @@ def test_universe_keywords(self):
89101
90102
91103
92-
93-
94-
95-
96-
0 commit comments