forked from specify/web-asset-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request specify#9 from calacademy-research/picturae_import
added derived test classes of base picturae import classes. Created new testing modules for picturae_importer
- Loading branch information
Showing
17 changed files
with
282 additions
and
70 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
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
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"""test case of the CsvCreatePicturae class which runs a reduced init method to use in unittests""" | ||
from image_client.importer import Importer | ||
from image_client.picturae_csv_create import CsvCreatePicturae | ||
from image_client import picturae_config | ||
|
||
class TestCsvCreatePicturae(CsvCreatePicturae): | ||
def __init__(self, date_string): | ||
Importer.__init__(self, db_config_class=picturae_config, collection_name= "Botany") | ||
self.init_all_vars(date_string) | ||
|
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,8 @@ | ||
"""test case of the PicturaeImporter class which runs a reduced init method to use in unittests""" | ||
from image_client.importer import Importer | ||
from image_client.picturae_importer import PicturaeImporter | ||
from image_client import picturae_config | ||
class TestPicturaeImporter(PicturaeImporter): | ||
def __init__(self, date_string, paths): | ||
Importer.__init__(self, db_config_class=picturae_config, collection_name="Botany") | ||
self.init_all_vars(date_string=date_string, paths=paths) |
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,61 @@ | ||
import pandas as pd | ||
from tests.pic_importer_test_class import TestPicturaeImporter | ||
import unittest | ||
from tests.testing_tools import TestingTools | ||
|
||
class TestAgentList(unittest.TestCase, TestingTools): | ||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.md5_hash = self.generate_random_md5() | ||
def setUp(self): | ||
"""creating instance of PicturaeImporter, + | ||
creating dummy dataset of real and fake names""" | ||
|
||
self.test_picturae_importer = TestPicturaeImporter(date_string=self.md5_hash, | ||
paths=self.md5_hash) | ||
|
||
# jose Gonzalez is a real agent, | ||
# to make sure true matches are not added to list. | ||
data = {'collector_first_name1': ['Bob', 'Joe'], | ||
'collector_last_name1': ['Fakeson jr.', 'DiMaggio'], | ||
'collector_middle_name1': ['J', 'S'], | ||
'collector_first_name2': ['Enrique', pd.NA], | ||
'collector_last_name2': ['de la fake', pd.NA], | ||
'collector_middle_name2': ['X', pd.NA], | ||
'collector_first_name3': ['Jose', pd.NA], | ||
'collector_last_name3': ['Gonzalez', pd.NA], | ||
'collector_middle_name3': [pd.NA, pd.NA] | ||
} | ||
|
||
self.test_picturae_importer.record_full = pd.DataFrame(data) | ||
|
||
self.test_picturae_importer.collector_list = [] | ||
|
||
def test_agent_list(self): | ||
"""makes sure the correct list of dictionaries is produced of collectors, | ||
where new agents are included, and old agents are excluded from new_collector_list""" | ||
temp_agent_list = [] | ||
for index, row in self.test_picturae_importer.record_full.iterrows(): | ||
self.test_picturae_importer.create_agent_list(row) | ||
temp_agent_list.extend(self.test_picturae_importer.new_collector_list) | ||
|
||
first_dict = temp_agent_list[0] | ||
second_dict = temp_agent_list[1] | ||
third_dict = temp_agent_list[2] | ||
# array | ||
collectors = [[first_dict['collector_first_name'], 'Bob'], [first_dict['collector_last_name'], 'Fakeson'], | ||
[first_dict['collector_title'], 'jr.'], [second_dict['collector_first_name'], 'Enrique'], | ||
[second_dict['collector_middle_initial'], 'X'], [third_dict['collector_first_name'], 'Joe'], | ||
[third_dict['collector_last_name'], 'DiMaggio'], [len(temp_agent_list), 3] | ||
] | ||
|
||
for comparison in collectors: | ||
self.assertEqual(comparison[0], comparison[1]) | ||
|
||
self.assertEqual(len(temp_agent_list), 3) | ||
|
||
def tearDown(self): | ||
"""deleting instance of self.PicturaeImporter""" | ||
del self.test_picturae_importer | ||
|
||
|
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
Oops, something went wrong.