@@ -54,12 +54,18 @@ def test_download(self):
5454 self .assertTrue (os .path .isdir (path ))
5555 self .assertTrue (os .path .exists (os .path .join (path , os .pardir , os .pardir , "Original Deposit.zip" )))
5656 self .assertTrue (os .path .exists (os .path .join (path , os .pardir , os .pardir , "Original metadata.json" )))
57-
5857 self .assertTrue (os .path .exists (os .path .join (path , "README_VandeVusse-Mueller.txt" )))
59-
6058 # Try again, we should fail the second time
6159 self .assertIsNone (dataverse .download_dataset (metadata , f .name ))
60+ f .cleanup ()
6261
62+ # try a harder example, with messed up filenames
63+ f = tempfile .TemporaryDirectory ()
64+ metadata = dataverse .get_metadata ("doi:10.5064/F68G8HMM" )
65+ path = dataverse .download_dataset (metadata , f .name )
66+ self .assertTrue (os .path .isdir (path ))
67+ self .assertTrue (os .path .exists (os .path .join (path , os .pardir , os .pardir , "Original Deposit.zip" )))
68+ self .assertTrue (os .path .exists (os .path .join (path , os .pardir , os .pardir , "Original metadata.json" )))
6369 f .cleanup ()
6470
6571class TestGithubAPI (unittest .TestCase ):
@@ -77,10 +83,28 @@ def test_version(self):
7783class TestRename (unittest .TestCase ):
7884
7985 def test_projectname (self ):
86+ # test limiting to before the first colon and removing "Data for:"
8087 metadata = dataverse .get_metadata ("doi:10.5064/F6AQGERV" )
8188 citation = dataverse .get_citation (metadata )
8289 self .assertIsNotNone (citation )
8390 self .assertEqual (rename .project_name (citation ), "Haney - Child Support Adjudication" )
91+ # try the limiting to 5 words feature
92+ metadata = dataverse .get_metadata ("doi:10.5064/F6ZXIJS5" )
93+ citation = dataverse .get_citation (metadata )
94+ self .assertIsNotNone (citation )
95+ self .assertEqual (rename .project_name (citation ), "Guastaferro - Adapting a Selective Parent-Focused Child" )
96+ # test special character removal
97+ metadata = dataverse .get_metadata ("doi:10.5064/F6MBCJ8M" )
98+ citation = dataverse .get_citation (metadata )
99+ self .assertIsNotNone (citation )
100+ self .assertEqual (rename .project_name (citation ), "Berntzen - Monster or Hero Far-right Responses" )
101+ # make a temporary directory named the citation and test it exists
102+ d = tempfile .TemporaryDirectory ()
103+ new_folder_name = rename .project_name (citation )
104+ new_folder_path = os .path .join (d .name , new_folder_name , "QDR Prepared" , "1_extract" )
105+ os .makedirs (new_folder_path )
106+ self .assertTrue (os .path .exists (new_folder_path )) # Ensure it was successfully made
107+ d .cleanup ()
84108
85109 def test_rename (self ):
86110 f = tempfile .TemporaryDirectory ()
0 commit comments