decode-elm / test /test.py
mehradans92's picture
Update test/test.py
ae7891a
raw
history blame
2 kB
import unittest
import sys
sys.path.append('../')
from utils import *
import os
import shutil
class Utils(unittest.TestCase):
def test_arXiv_API(self):
search_query = 'Tools for Landscape Analysis of Optimisation Problems in Procedural Content Generation for Games'
pdf_info = "('Tools for Landscape Analysis of Optimisation Problems in Procedural Content Generation for Games', 'http://arxiv.org/pdf/2302.08479v1', ['Vanessa Volz', 'Boris Naujoks', 'Pascal Kerschke', 'Tea Tusar'], ['cs.AI'], 'docs', 'Vanessa Volz, Boris Naujoks, Pascal Kerschke, Tea Tusar, Tools for Landscape Analysis of Optimisation Problems in Procedural Content Generation for Games. arXiv [cs.AI] (2023), (available at http://arxiv.org/pdf/2302.08479v1).')"
max_results = 1
XRxiv_servers = ['rxiv']
search_engines = XRxivQuery(search_query, max_results, XRxiv_servers=XRxiv_servers)
test_pdf_info = search_engines.call_API()
self.assertEqual(pdf_info, str(test_pdf_info[0]))
def test_download_pdf(self):
search_query = 'Serverless Applications: Why, When, and How?'
max_results = 1
XRxiv_servers = ['rxiv']
search_engines = XRxivQuery(search_query, max_results, XRxiv_servers=XRxiv_servers)
test_pdf_info = search_engines.call_API()
search_engines.download_pdf()
dowloaded_dir = 'docs/Serverless Applications Why When and How .pdf'
self.assertTrue(os.path.exists(dowloaded_dir))
shutil.rmtree(f'docs/')
def test_distibute_max_papers(self):
XRxiv_servers = ['rxiv', 'medrxiv']
max_results = 10
max_papers_in_server = distibute_max_papers(max_results, XRxiv_servers)
self.assertEqual(max_results, np.sum(max_papers_in_server))
self.assertEqual(max_papers_in_server[2], 0)
self.assertGreater(max_papers_in_server[0],0)
self.assertGreater(max_papers_in_server[3],0)
if __name__ == '__main__':
unittest.main()