@@ -48,59 +48,46 @@ def test_scielo_basic():
4848 logger .warning ("❌ No articles found" )
4949
5050 except Exception as e :
51- logger .error (f"❌ Test 1 failed: { e } " )
52- return False
51+ assert False , f"Test 1 failed: { e } "
5352
5453 # Test 2: Main scielo method
5554 logger .info ("Test 2: Main scielo method with CSV output" )
56- try :
57- results = scielo .scielo (
58- query = "climate change" , cutoff_size = 2 , makecsv = True , makehtml = True
59- )
60- logger .info (
61- f"✅ Main method completed. Found { results ['total_results' ]} articles"
62- )
63- logger .info (f"✅ Generated CSV and HTML outputs" )
64-
65- except Exception as e :
66- logger .error (f"❌ Test 2 failed: { e } " )
67- return False
55+ results = scielo .scielo (
56+ query = "climate change" , cutoff_size = 2 , makecsv = True , makehtml = True
57+ )
58+ assert isinstance (results , dict ), "Results should be a dictionary"
59+ assert "total_results" in results , "Results should contain total_results"
60+ logger .info (
61+ f"✅ Main method completed. Found { results ['total_results' ]} articles"
62+ )
63+ logger .info (f"✅ Generated CSV and HTML outputs" )
6864
6965 # Test 3: Noexecute method
7066 logger .info ("Test 3: Noexecute method" )
71- try :
72- query_namespace = {"query" : "climate change" , "limit" : 2 }
73- scielo .noexecute (query_namespace )
74- logger .info ("✅ Noexecute method completed" )
75-
76- except Exception as e :
77- logger .error (f"❌ Test 3 failed: { e } " )
78- return False
67+ query_namespace = {"query" : "climate change" , "limit" : 2 }
68+ assert hasattr (scielo , "noexecute" ), "SciELO should have noexecute method"
69+ scielo .noexecute (query_namespace )
70+ logger .info ("✅ Noexecute method completed" )
7971
8072 # Test 4: Article download
8173 logger .info ("Test 4: Article download" )
82- try :
83- if articles :
84- # Download first article
85- first_article_url = articles [0 ].get ("url" )
86- if first_article_url :
87- output_dir = "temp/scielo_test_downloads"
88- success = scielo .download_article (first_article_url , output_dir )
89- if success :
90- logger .info (f"✅ Article downloaded to { output_dir } " )
91- else :
92- logger .warning ("⚠️ Article download failed" )
74+ if articles :
75+ # Download first article
76+ first_article_url = articles [0 ].get ("url" )
77+ if first_article_url :
78+ output_dir = "temp/scielo_test_downloads"
79+ assert hasattr (scielo , "download_article" ), "SciELO should have download_article method"
80+ success = scielo .download_article (first_article_url , output_dir )
81+ if success :
82+ logger .info (f"✅ Article downloaded to { output_dir } " )
9383 else :
94- logger .warning ("⚠️ No article URL available for download test " )
84+ logger .warning ("⚠️ Article download failed " )
9585 else :
96- logger .warning ("⚠️ No articles available for download test" )
97-
98- except Exception as e :
99- logger .error (f"❌ Test 4 failed: { e } " )
100- return False
86+ logger .warning ("⚠️ No article URL available for download test" )
87+ else :
88+ logger .warning ("⚠️ No articles available for download test" )
10189
10290 logger .info ("=== All Basic Tests Completed ===" )
103- return True
10491
10592
10693def test_scielo_metadata_extraction ():
@@ -127,15 +114,14 @@ def test_scielo_metadata_extraction():
127114 logger .info (f" DOI: { metadata .get ('doi' , 'No DOI' )} " )
128115 logger .info (f" PDF URLs: { len (metadata .get ('pdf_urls' , []))} " )
129116 logger .info (f" Collection: { metadata .get ('collection' , 'Unknown' )} " )
130-
131- return True
117+
118+ assert metadata is not None , "Metadata should be extracted"
119+ assert isinstance (metadata , dict ), "Metadata should be a dictionary"
132120 else :
133- logger .error ("❌ Failed to get article page" )
134- return False
121+ assert False , "Failed to get article page"
135122
136123 except Exception as e :
137- logger .error (f"❌ Metadata extraction test failed: { e } " )
138- return False
124+ assert False , f"Metadata extraction test failed: { e } "
139125
140126
141127def main ():
0 commit comments