def testIndexingOfSpeciesMixed(patch_apiCall): class TempWebClass: def __init__(self): self.taxa = { 1: { "family": "A" }, 2: { "family": "B" }, 3: { "family": "C" }, } self.stringNames = { "panthera tigris": 1, "ursus arctos": 2, "turdus merula": 3, } translatedSpecies = [ ("ursus americanus", { "family": "D" }), ("ursus maritimus", { "family": "E" }), ] WebObj = TempWebClass() patch_apiCall.return_value = translatedSpecies mca = MedeinaCumulativeApplication("dir") data = [ "panthera tigris", "ursus arctos", "ursus maritimus", "ursus americanus", "turdus merula", ] expected = { "panthera tigris": { "family": "A" }, "ursus arctos": { "family": "B" }, "turdus merula": { "family": "C" }, "ursus americanus": { "family": "D" }, "ursus maritimus": { "family": "E" }, } assert mca.indexSpeciesWithTaxaData(data, WebObj) == expected APISpeciesInput, strictParam = patch_apiCall.call_args[0] assert strictParam == False assert set(APISpeciesInput) == set(["ursus americanus", "ursus maritimus"])
def testIndexingOfSpeciesAllExisting(patch_apiCall): class TempWebClass: def __init__(self): self.taxa = { 1: { "family": "A" }, 2: { "family": "B" }, 3: { "family": "C" }, 4: { "family": "D" }, 5: { "family": "E" }, } self.stringNames = { "panthera tigris": 1, "ursus arctos": 2, "turdus merula": 3, "ursus americanus": 4, "ursus maritimus": 5, } translatedSpecies = [ ("panthera tigris", True, { "nkdakda": "A" }), ("ursus arctos", True, { "adssakd": "B" }), ("turdus merula", True, { "dasdsa": "C" }), ("ursus americanus", True, { "dassakdsa": "D" }), ("ursus maritimus", True, { "odsksa": "E" }), ] WebObj = TempWebClass() patch_apiCall.return_value = translatedSpecies mca = MedeinaCumulativeApplication("dir") data = [ "panthera tigris", "ursus arctos", "ursus maritimus", "ursus americanus", "turdus merula", ] expected = { "panthera tigris": { "family": "A" }, "ursus arctos": { "family": "B" }, "turdus merula": { "family": "C" }, "ursus americanus": { "family": "D" }, "ursus maritimus": { "family": "E" }, } assert mca.indexSpeciesWithTaxaData(data, WebObj) == expected patch_apiCall.assert_not_called()