def testHandlingOfNonExceptedSpeciesSmall():
    WebObj = getSupportingSmallWebObj()
    WebObj.taxaExceptions = {}
    mca = MedeinaCumulativeApplication("dir")
    speciesWithTaxa = {
        "panthera tigris": {
            "family": "felidae",
            "species": "panthera tigris"
        },
        "acinonyx jubatus": {
            "family": "felidae",
            "species": "acinonyx jubatus"
        },
        "panthera leo": {
            "family": "felidae",
            "species": "panthera leo"
        },
    }
    interactions = mca.handleNonExceptionSpecies(WebObj, speciesWithTaxa,
                                                 "species")
    expected = [
        ("panthera tigris", "acinonyx jubatus"),
        ("acinonyx jubatus", "panthera leo"),
    ]
    assert interactions == expected
    speciesWithTaxa = {
        "ursus arctos": {
            "family": "ursus",
            "species": "ursus arctos"
        },
        "ursus maritimus": {
            "family": "ursus",
            "species": "ursus maritimus"
        },
    }
    interactions = mca.handleNonExceptionSpecies(WebObj, speciesWithTaxa,
                                                 "family")
    expected = []
    assert interactions == expected
def testHandlingOfNonExceptedSpeciesInvalid():
    WebObj = getSupportingInvalidNamesWebObj()
    WebObj.taxaExceptions = {}
    mca = MedeinaCumulativeApplication("dir")
    expected = []
    speciesWithTaxa = {
        "ursus arctos": {
            "family": "",
            "species": "ursus arctos"
        },
        "": {
            "family": "ursus",
            "species": "ursus maritimus"
        },
        "": {
            "family": "felidae",
            "species": ""
        },
    }
    assert mca.handleNonExceptionSpecies(WebObj, speciesWithTaxa,
                                         "species") == expected
    assert IDTRACKER in WebObj.interactions
def testHandlingOfNonExceptedSpeciesLarge():
    WebObj = getSupportingLargeWebObj()
    WebObj.taxaExceptions = {}
    mca = MedeinaCumulativeApplication("dir")
    speciesWithTaxa = {
        "ursus arctos": {
            "family": "ursus",
            "species": "ursus arctos"
        },
        "vulpes vulpes": {
            "family": "canidae",
            "species": "vulpes vulpes"
        },
        "canis lupus": {
            "family": "canidae",
            "species": "canis lupus"
        },
        "ursus maritimus": {
            "family": "ursus",
            "species": "ursus maritimus"
        },
        "panthera tigris": {
            "family": "felidae",
            "species": "panthera tigris"
        },
        "felis catus": {
            "family": "felidae",
            "species": "felis catus"
        },
        "panthera onca": {
            "family": "felidae",
            "species": "panthera onca"
        },
    }
    interactions = mca.handleNonExceptionSpecies(WebObj, speciesWithTaxa,
                                                 "species")
    expected = [
        ("ursus arctos", "panthera tigris"),
        ("vulpes vulpes", "ursus arctos"),
        ("vulpes vulpes", "panthera onca"),
        ("canis lupus", "ursus maritimus"),
        ("ursus maritimus", "ursus arctos"),
        ("ursus maritimus", "panthera tigris"),
        ("felis catus", "vulpes vulpes"),
    ]
    assert interactions == expected
    speciesWithTaxa = {
        "ursus arctos": {
            "family": "ursus",
            "species": "ursus arctos"
        },
        "ursus maritimus": {
            "family": "ursus",
            "species": "ursus maritimus"
        },
    }
    interactions = mca.handleNonExceptionSpecies(WebObj, speciesWithTaxa,
                                                 "family")
    expected = [
        ("ursus arctos", "ursus arctos"),
        ("ursus arctos", "ursus maritimus"),
        ("ursus maritimus", "ursus arctos"),
        ("ursus maritimus", "ursus maritimus"),
    ]

    assert interactions == expected