Exemplo n.º 1
0
def test_heatindex():
    expected = {
        27: {
            40: 27, 45: 27, 50: 27, 55: 27, 60: 28, 65: 28, 70: 28, 75: 29, 80: 29, 85: 29, 90: 30, 95: 30, 100: 31
        },
        28: {
            40: 27, 45: 28, 50: 28, 55: 29, 60: 29, 65: 29, 70: 30, 75: 31, 80: 32, 85: 32, 90: 33, 95: 34, 100: 35
        },
        29: {
            40: 28, 45: 29, 50: 29, 55: 30, 60: 31, 65: 32, 70: 32, 75: 33, 80: 34, 85: 36, 90: 37, 95: 38, 100: 39
        },
        30: {
            40: 29, 45: 31, 50: 31, 55: 32, 60: 33, 65: 34, 70: 35, 75: 36, 80: 38, 85: 39, 90: 41, 95: 42, 100: 44
        },
        31: {
            40: 31, 45: 32, 50: 33, 55: 34, 60: 35, 65: 37, 70: 38, 75: 39, 80: 41, 85: 43, 90: 45, 95: 47, 100: 49
        },
        32: {
            40: 33, 45: 34, 50: 35, 55: 36, 60: 38, 65: 39, 70: 41, 75: 43, 80: 45, 85: 47, 90: 50, 95: 53, 100: 56
        },
        33: {
            40: 34, 45: 36, 50: 37, 55: 38, 60: 41, 65: 42, 70: 44, 75: 47, 80: 49, 85: 52, 90: 55
        },
        34: {
            40: 36, 45: 38, 50: 39, 55: 41, 60: 43, 65: 46, 70: 48, 75: 51, 80: 54, 85: 57
        },
        36: {
            40: 38, 45: 40, 50: 42, 55: 44, 60: 47, 65: 49, 70: 54, 75: 56
        },
        37: {
            40: 41, 45: 43, 50: 45, 55: 47, 60: 51, 65: 53, 70: 57
        },
        38: {
            40: 43, 45: 46, 50: 48, 55: 51, 60: 54, 65: 58
        },
        39: {
            40: 46, 45: 48, 50: 51, 55: 54, 60: 58
        },
        40: {
            40: 48, 45: 51, 50: 55, 55: 58
        },
        41: {
            40: 51, 45: 54, 50: 58
        },
        42: {
            40: 54, 45: 58
        },
        43: {
            40: 58
        },
    }

    for temperature in expected.keys():
        for humidity in expected[temperature].keys():
            yield check_expected, temperature, humidity, Weather.heatindex(temperature, humidity), float(expected[temperature][humidity])
Exemplo n.º 2
0
def test_heat_index(temperature, humidity, expected):
    assert abs(Weather.heatindex(temperature, humidity) - expected) <= 2
Exemplo n.º 3
0
def check_expected(temperature, humidity, observered, expected):
    assert abs(Weather.heatindex(temperature, humidity) - expected) <= 2