-
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.
tested 2/4 functionalities of bioModels_cache.py
- Loading branch information
1 parent
3ea6ce8
commit 2c73d9b
Showing
1 changed file
with
24 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import unittest | ||
from unittest.mock import patch, mock_open | ||
from src.bioModels_cache import remove_html_tags, update_cache, save_to_json, cache_biomodels | ||
|
||
class TestBioModelsCache(unittest.TestCase): | ||
|
||
def test_remove_html_tags(self): | ||
self.assertEqual(remove_html_tags("<p>BIOMD007</p>"), "BIOMD007") | ||
self.assertEqual(remove_html_tags("Remove"), "Remove") | ||
self.assertEqual(remove_html_tags(""), "") | ||
|
||
def test_update_cache_existing_model(self): | ||
model = {'publicationId': 'BIOMD007', 'description': 'Test'} | ||
modelResults = {'BIOMD007': model} | ||
self.assertFalse(update_cache(model, modelResults)) | ||
|
||
@patch('builtins.open', new_callable=mock_open) | ||
def test_save_to_json(self, mock_file_open): | ||
model_info = {'BIOMD007': {'description': 'Description of BioModel 7'}} | ||
save_to_json(model_info) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |