def test_funtion_analyze_scanresult_bbu_not_charging():
    scanresult = {
        "hotspare_count": 0,
        "logical_disk_count": 0,
        "physical_disk_count": 0,
        "media_errors": 0,
        "pred_errors": 0,
        "other_errors": 0,
        "physical_errors": 0,
        "logical_disk_errors": 0,
        "bbu_nav_count": 0,
        "bbu_charging_count": 0,
        "bbu_ncharging_count": 3}
    assert_equals(analyze_scanresult(scanresult, 0, 0, 0, 0, 0, 0),
                  (1, "3 BBU not charging. (m0p0o0)"))
def test_funtion_analyze_scanresult_logical_disks():
    scanresult = {
        "hotspare_count": 0,
        "logical_disk_count": 1,
        "physical_disk_count": 0,
        "media_errors": 0,
        "pred_errors": 0,
        "other_errors": 0,
        "physical_errors": 0,
        "logical_disk_errors": 0,
        "bbu_nav_count": 0,
        "bbu_charging_count": 0,
        "bbu_ncharging_count": 0}
    assert_equals(analyze_scanresult(scanresult, 2, 0, 0, 0, 0, 0),
                  (2, "Missing logical Disk: Found 1 Expected 2. (m0p0o0)"))
def test_funtion_analyze_scanresult_disk_errors_ignore():
    scanresult = {
        "hotspare_count": 1,
        "logical_disk_count": 0,
        "physical_disk_count": 0,
        "media_errors": 1,
        "pred_errors": 1,
        "other_errors": 1,
        "physical_errors": 0,
        "logical_disk_errors": 0,
        "bbu_nav_count": 0,
        "bbu_charging_count": 0,
        "bbu_ncharging_count": 0}
    assert_equals(analyze_scanresult(scanresult, 0, 0, 1, 1, 1, 0),
                  (0, "Everything is ok. (m1p1o1)"))
def test_funtion_analyze_scanresult_logical_errors():
    scanresult = {
        "hotspare_count": 0,
        "logical_disk_count": 0,
        "physical_disk_count": 0,
        "media_errors": 0,
        "pred_errors": 0,
        "other_errors": 0,
        "physical_errors": 0,
        "logical_disk_errors": 2,
        "bbu_nav_count": 0,
        "bbu_charging_count": 0,
        "bbu_ncharging_count": 0}
    assert_equals(analyze_scanresult(scanresult, 0, 0, 0, 0, 0, 0),
                  (2, "Found 2 logical drive error(s). (m0p0o0)"))
def test_funtion_analyze_scanresult_missing_hotspare():
    scanresult = {
        "hotspare_count": 1,
        "logical_disk_count": 0,
        "physical_disk_count": 0,
        "media_errors": 0,
        "pred_errors": 0,
        "other_errors": 0,
        "physical_errors": 0,
        "logical_disk_errors": 0,
        "bbu_nav_count": 0,
        "bbu_charging_count": 0,
        "bbu_ncharging_count": 0}
    assert_equals(analyze_scanresult(scanresult, 0, 0, 0, 0, 0, 2),
                  (1, "Expected 2 Hotspares, got 1. (m0p0o0)"))
def test_funtion_analyze_scanresult_disk_errors():
    scanresult = {
        "hotspare_count": 0,
        "logical_disk_count": 0,
        "physical_disk_count": 0,
        "media_errors": 1,
        "pred_errors": 1,
        "other_errors": 1,
        "physical_errors": 0,
        "logical_disk_errors": 0,
        "bbu_nav_count": 0,
        "bbu_charging_count": 0,
        "bbu_ncharging_count": 0}
    assert_equals(analyze_scanresult(scanresult, 0, 0, 0, 0, 0, 0),
                  (1, "Found diskerrors. (m1p1o1)"))
def test_funtion_analyze_scanresult_logical_disks():
    scanresult = {
        "hotspare_count": 0,
        "logical_disk_count": 1,
        "physical_disk_count": 0,
        "media_errors": 0,
        "pred_errors": 0,
        "other_errors": 0,
        "physical_errors": 0,
        "logical_disk_errors": 0,
        "bbu_nav_count": 0,
        "bbu_charging_count": 0,
        "bbu_ncharging_count": 0
    }
    assert_equals(analyze_scanresult(scanresult, 2, 0, 0, 0, 0, 0),
                  (2, "Missing logical Disk: Found 1 Expected 2. (m0p0o0)"))
def test_funtion_analyze_scanresult_bbu_not_charging():
    scanresult = {
        "hotspare_count": 0,
        "logical_disk_count": 0,
        "physical_disk_count": 0,
        "media_errors": 0,
        "pred_errors": 0,
        "other_errors": 0,
        "physical_errors": 0,
        "logical_disk_errors": 0,
        "bbu_nav_count": 0,
        "bbu_charging_count": 0,
        "bbu_ncharging_count": 3
    }
    assert_equals(analyze_scanresult(scanresult, 0, 0, 0, 0, 0, 0),
                  (1, "3 BBU not charging. (m0p0o0)"))
def test_funtion_analyze_scanresult_logical_errors():
    scanresult = {
        "hotspare_count": 0,
        "logical_disk_count": 0,
        "physical_disk_count": 0,
        "media_errors": 0,
        "pred_errors": 0,
        "other_errors": 0,
        "physical_errors": 0,
        "logical_disk_errors": 2,
        "bbu_nav_count": 0,
        "bbu_charging_count": 0,
        "bbu_ncharging_count": 0
    }
    assert_equals(analyze_scanresult(scanresult, 0, 0, 0, 0, 0, 0),
                  (2, "Found 2 logical drive error(s). (m0p0o0)"))
def test_funtion_analyze_scanresult_disk_errors_ignore():
    scanresult = {
        "hotspare_count": 1,
        "logical_disk_count": 0,
        "physical_disk_count": 0,
        "media_errors": 1,
        "pred_errors": 1,
        "other_errors": 1,
        "physical_errors": 0,
        "logical_disk_errors": 0,
        "bbu_nav_count": 0,
        "bbu_charging_count": 0,
        "bbu_ncharging_count": 0
    }
    assert_equals(analyze_scanresult(scanresult, 0, 0, 1, 1, 1, 0),
                  (0, "Everything is ok. (m1p1o1)"))
def test_funtion_analyze_scanresult_disk_errors():
    scanresult = {
        "hotspare_count": 0,
        "logical_disk_count": 0,
        "physical_disk_count": 0,
        "media_errors": 1,
        "pred_errors": 1,
        "other_errors": 1,
        "physical_errors": 0,
        "logical_disk_errors": 0,
        "bbu_nav_count": 0,
        "bbu_charging_count": 0,
        "bbu_ncharging_count": 0
    }
    assert_equals(analyze_scanresult(scanresult, 0, 0, 0, 0, 0, 0),
                  (1, "Found diskerrors. (m1p1o1)"))
def test_funtion_analyze_scanresult_missing_hotspare():
    scanresult = {
        "hotspare_count": 1,
        "logical_disk_count": 0,
        "physical_disk_count": 0,
        "media_errors": 0,
        "pred_errors": 0,
        "other_errors": 0,
        "physical_errors": 0,
        "logical_disk_errors": 0,
        "bbu_nav_count": 0,
        "bbu_charging_count": 0,
        "bbu_ncharging_count": 0
    }
    assert_equals(analyze_scanresult(scanresult, 0, 0, 0, 0, 0, 2),
                  (1, "Expected 2 Hotspares, got 1. (m0p0o0)"))
def test_funtion_analyze_scanresult_all_together():
    scanresult = {
        "hotspare_count": 2,
        "logical_disk_count": 8,
        "physical_disk_count": 2,
        "media_errors": 1,
        "pred_errors": 1,
        "other_errors": 1,
        "physical_errors": 3,
        "logical_disk_errors": 2,
        "bbu_nav_count": 2,
        "bbu_charging_count": 3,
        "bbu_ncharging_count": 3}
    assert_equals(analyze_scanresult(scanresult, 9, 1, 0, 0, 0, 3),
                  (2, ("Missing logical Disk: Found 8 Expected 9. "
                       "Found 2 logical drive error(s). "
                       "Found 3 physical disk error(s). "
                       "2 BBU not available. "
                       "3 BBU not charging. "
                       "3 BBU charging. "
                       "Found diskerrors. "
                       "Expected 3 Hotspares, got 2. "
                       "(m1p1o1)")))
def test_funtion_analyze_scanresult_all_together():
    scanresult = {
        "hotspare_count": 2,
        "logical_disk_count": 8,
        "physical_disk_count": 2,
        "media_errors": 1,
        "pred_errors": 1,
        "other_errors": 1,
        "physical_errors": 3,
        "logical_disk_errors": 2,
        "bbu_nav_count": 2,
        "bbu_charging_count": 3,
        "bbu_ncharging_count": 3
    }
    assert_equals(analyze_scanresult(scanresult, 9, 1, 0, 0, 0, 3),
                  (2, ("Missing logical Disk: Found 8 Expected 9. "
                       "Found 2 logical drive error(s). "
                       "Found 3 physical disk error(s). "
                       "2 BBU not available. "
                       "3 BBU not charging. "
                       "3 BBU charging. "
                       "Found diskerrors. "
                       "Expected 3 Hotspares, got 2. "
                       "(m1p1o1)")))