-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add rpy2 dependency, refactor process_pdfs method, and implement unit…
… tests for OddpubWrapper
- Loading branch information
Showing
3 changed files
with
37 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ dependencies = [ | |
"pdf2doi", | ||
"tqdm", | ||
"pypdf", | ||
"rpy2" | ||
] | ||
|
||
[project.optional-dependencies] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import unittest | ||
from unittest.mock import patch, MagicMock | ||
from sqlalchemy import inspect | ||
from dsst_etl.oddpub_wrapper import OddpubWrapper | ||
from dsst_etl.models import OddpubMetrics | ||
from dsst_etl.db import get_db_session, init_db | ||
from dsst_etl import get_db_engine | ||
|
||
|
||
class TestOddpubWrapper(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.engine = get_db_engine(is_test=True) | ||
init_db(self.engine) | ||
self.session = get_db_session(self.engine) | ||
self.wrapper = OddpubWrapper(self.session) | ||
|
||
def tearDown(self): | ||
self.session.close() | ||
self.engine.dispose() | ||
|
||
def test_oddpub_wrapper(self): | ||
self.wrapper.process_pdfs("test_pdfs", "test_output") | ||
|
||
# Check if the OddpubMetrics table exists | ||
inspector = inspect(self.session.bind) | ||
self.assertTrue("oddpub_metrics" in inspector.get_table_names()) | ||
|
||
# Check if the data was inserted correctly | ||
result = self.session.query(OddpubMetrics).first() | ||
self.assertIsNotNone(result) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |