Spaces:
Running
Running
File size: 1,515 Bytes
7ef1abc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
import sys
import os
import asyncio
# Add project root to path
sys.path.append(os.getcwd())
from app.services.doaj_service import DOAJService
from app.services.arxiv_service import ArXivService
def test_doaj_search():
print("Testing DOAJ search...")
service = DOAJService()
results = service.fetch_papers("quantum computing", max_results=5)
print(f"Found {len(results)} results from DOAJ")
for r in results:
print(f"- {r['title']} (Has PDF: {r['has_pdf']})")
if r['has_pdf']:
print(f" URL: {r['url']}")
def test_merged_search():
print("\nTesting Merged search logic simulation...")
# Simulate the logic in discovery.py
arxiv_service = ArXivService()
doaj_service = DOAJService()
query = "CRISPR"
max_results = 5
arxiv_data = arxiv_service.fetch_papers(query, max_results)
doaj_data = doaj_service.fetch_papers(query, max_results)
print(f"ArXiv: {len(arxiv_data)} papers")
print(f"DOAJ: {len(doaj_data)} papers")
merged = []
seen = set()
for p in arxiv_data:
merged.append(p["title"])
seen.add(p["title"].lower().strip())
dupes = 0
for p in doaj_data:
if p["title"].lower().strip() in seen:
dupes += 1
else:
merged.append(p["title"])
print(f"Total unique papers: {len(merged)}")
print(f"Duplicates found: {dupes}")
if __name__ == "__main__":
test_doaj_search()
test_merged_search()
|