Skip to content
Snippets Groups Projects
Commit d85dcb45 authored by Florian Jochens's avatar Florian Jochens
Browse files

made test_acs.py executable

parent be58b180
Branches
No related tags found
No related merge requests found
from input.test.test_input import *
from input.publication import Publication
\ No newline at end of file
This diff is collapsed.
import unittest
from input.get.journal_fetcher import JournalFetcher
from input.publication import Publication
"""
Testing the Publication fetcher
Publication 1: 'https://doi.org/10.1021/acs.jcim.1c00203'
Publication 2: 'doi.org/10.1021/acs.jcim.1c00917'
Publication 3: '10.1038/nchem.1781'
Publication 4: '11.12/jaj'
Publication 5: '11.12/'
Publication 6: 'https://doi.org/10.1021/acs.jmedchem.0c01332' # Paper is a PDF
"""
# TODO: Testcases for:
# - Specific Journals: Inherit from FetcherTestCase
# - interface module-importer (test case)
# - Error detection
# - wrong/no Journal_fetchers
# - wrong urls
# - correct Types in publication
# - Edgecases (i.e. paper as pdf, no connection, etc)
class InterfaceTestCase(unittest.TestCase):
pass
class FetcherTestCase(unittest.TestCase):
def can_use_url_test(self, fetcher : JournalFetcher, test_url: str, expected_res: bool):
# Tests the 'can_use_url'-method
self.assertEqual(fetcher.can_use_url(test_url), expected_res)
def get_publication_test(self, fetcher : JournalFetcher, test_url: str, expected_res: Publication):
"""
this test asserts that every variable is equals to the expected result
"""
actual_res = fetcher.get_publication(test_url)
self.assertEqual(actual_res.doi_url, expected_res.doi_url)
self.assertEqual(actual_res.title, expected_res.title)
self.assertEqual(actual_res.contributors, expected_res.contributors)
self.assertEqual(actual_res.journal, expected_res.journal)
self.assertEqual(actual_res.publication_date, expected_res.publication_date)
self.assertEqual(actual_res.subjects, expected_res.subjects)
# self.assertEqual(actual_res.num_citations, expected_res.num_citations)
# Checking for all references
self.assertEquals(len(actual_res.references), len(expected_res.references))
num_references = len(expected_res.references)
for i in range(num_references):
self.assertEqual(actual_res.references[i].doi_url, expected_res.references[i].doi_url)
self.assertEqual(actual_res.references[i].journal, expected_res.references[i].journal)
self.assertEqual(actual_res.references[i].contributors, expected_res.references[i].contributors)
self.assertEqual(actual_res.references[i].cit_type, expected_res.references[i].cit_type)
# Checking for all citations
self.assertEquals(len(actual_res.citations), len(expected_res.citations))
num_citations = len(expected_res.citations)
for i in range(num_citations):
self.assertEqual(actual_res.citations[i].doi_url, expected_res.citations[i].doi_url)
self.assertEqual(actual_res.citations[i].journal, expected_res.citations[i].journal)
self.assertEqual(actual_res.citations[i].contributors, expected_res.citations[i].contributors)
self.assertEqual(actual_res.citations[i].cit_type, expected_res.citations[i].cit_type)
if __name__=="__main__":
print("test")
unittest.main()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment