-
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.
feat(unit_tests): new unit tests for lit_processing
- Loading branch information
Showing
11 changed files
with
62 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
rm -rf agr_literature_service/lit_processing/data_ingest/tmp | ||
rm -rf agr_literature_service/lit_processing/tests/tmp | ||
rm -rf agr_literature_service/lit_processing/tests/tmp | ||
rm -rf tests/lit_processing/tmp |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#!/usr/bin/env bash | ||
export ENV_STATE=test | ||
# pytest -vv | ||
pytest | ||
pytest -m "not webtest" | ||
|
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
Empty file.
Empty file.
17 changes: 17 additions & 0 deletions
17
tests/lit_processing/data_ingest/pubmed_ingest/test_process_single_pmid.py
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,17 @@ | ||
import os | ||
from os import environ | ||
|
||
import pytest | ||
|
||
from agr_literature_service.lit_processing.data_ingest.pubmed_ingest.process_single_pmid import process_pmid | ||
from tests.utils import cleanup_tmp_files | ||
|
||
|
||
class TestProcessSinglePMID: | ||
|
||
@pytest.mark.webtest | ||
def test_process_pmid(self): | ||
base_path = environ.get('XML_PATH') | ||
process_pmid("PMID:12345") | ||
assert os.path.exists(os.path.join(base_path, "pubmed_xml", "12345.xml")) | ||
cleanup_tmp_files() |
11 changes: 11 additions & 0 deletions
11
tests/lit_processing/data_ingest/pubmed_ingest/test_xml_to_json.py
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,11 @@ | ||
from agr_literature_service.lit_processing.data_ingest.pubmed_ingest.xml_to_json import \ | ||
get_alliance_category_from_pubmed_types | ||
|
||
|
||
class TestXmlToJson: | ||
|
||
def test_get_alliance_category_from_pubmed_types(self): | ||
assert get_alliance_category_from_pubmed_types(["Journal Article", "Research Support, N.I.H., Extramural", | ||
"Research Support, Non-U.S. Gov't"]) == "Research_Article" | ||
assert get_alliance_category_from_pubmed_types(["Journal Article"]) == "Research_Article" | ||
# TODO: add more cases |
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,20 @@ | ||
import pytest | ||
|
||
from agr_literature_service.lit_processing.tests.mod_populate_load import post_mods | ||
from ..fixtures import db # noqa | ||
|
||
|
||
@pytest.fixture | ||
def test_data(db): | ||
print("***** Loading data into the DB *****") | ||
print("***** Adding mods *****") | ||
post_mods() | ||
print("***** Adding references *****") | ||
yield None | ||
print("***** Cleaning up data *****") | ||
|
||
|
||
class TestDataExport: | ||
|
||
def test_dump_data(self, test_data): | ||
assert True |
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,7 @@ | ||
import shutil | ||
from os import environ | ||
|
||
|
||
def cleanup_tmp_files(): | ||
base_path = environ.get('XML_PATH') | ||
shutil.rmtree(base_path) |