def testBuildingTaxaBasedInteractionsSmall():
    WebObj = getSupportingSmallWebObj()
    mca = MedeinaCumulativeApplication("dir")
    expected = {
        "acinonyx jubatus": {
            "panthera leo": [4]
        },
        "panthera tigris": {
            "acinonyx jubatus": [3],
            "puma concolor": [2]
        },
        "puma concolor": {
            "ursus arctos": [1]
        },
    }
    assert mca.buildTaxaBasedInteractions(WebObj, "species") == expected
def testBuildingTaxaBasedInteractionsInvalid():
    WebObj = getSupportingInvalidNamesWebObj()
    mca = MedeinaCumulativeApplication("dir")
    expected = {"panthera tigris": {"puma concolor": [2]}}
    assert mca.buildTaxaBasedInteractions(WebObj, "species") == expected
    assert IDTRACKER in WebObj.interactions
def testBuildingTaxaBasedInteractionsLarge():
    WebObj = getSupportingLargeWebObj()
    mca = MedeinaCumulativeApplication("dir")
    expected = {
        "acinonyx jubatus": {
            "puma concolor": [20, 15],
            "vulpes vulpes": [33]
        },
        "canis latrans": {
            "puma concolor": [12]
        },
        "canis lupus": {
            "ursus maritimus": [10]
        },
        "felis catus": {
            "vulpes vulpes": [25]
        },
        "helarctos malayanus": {
            "lynx rufus": [7, 21],
            "panthera tigris": [18],
            "puma concolor": [19],
        },
        "lynx rufus": {
            "felis catus": [13, 16],
            "panthera onca": [22],
            "vulpes zerda": [17],
        },
        "panthera onca": {
            "panthera leo": [8, 9]
        },
        "panthera tigris": {
            "panthera leo": [26, 31],
            "puma concolor": [4, 5, 6],
            "ursus americanus": [32],
        },
        "puma concolor": {
            "ursus arctos": [1]
        },
        "ursus americanus": {
            "lynx rufus": [39],
            "panthera onca": [40],
            "panthera tigris": [35, 36, 37],
            "ursus maritimus": [11],
        },
        "ursus arctos": {
            "panthera tigris": [2, 3]
        },
        "ursus maritimus": {
            "panthera tigris": [38],
            "ursus arctos": [34]
        },
        "vulpes vulpes": {
            "canis latrans": [29],
            "panthera onca": [28],
            "puma concolor": [27],
            "ursus americanus": [30],
            "ursus arctos": [14],
        },
        "vulpes zerda": {
            "vulpes vulpes": [23, 24]
        },
    }
    assert mca.buildTaxaBasedInteractions(WebObj, "species") == expected
    expected = {
        "canidae": {
            "canidae": [29, 23, 24],
            "felidae": [12, 28, 27],
            "ursus": [10, 14, 30],
        },
        "felidae": {
            "canidae": [33, 25, 17],
            "felidae": [4, 5, 6, 26, 31, 20, 15, 8, 9, 22, 13, 16],
            "ursus": [1, 32],
        },
        "ursus": {
            "felidae": [2, 3, 38, 35, 36, 37, 40, 39, 7, 21, 19, 18],
            "ursus": [34, 11],
        },
    }
    assert mca.buildTaxaBasedInteractions(WebObj, "family") == expected