from banbou import controller_projection

def test_projection_CC_correcte_metropole() :
    sut = ("1004", 1585702, 2185080)

    proj = controller_projection(*sut)

    assert proj == "CC43"

def test_projection_Lambert93_correcte_metropole() :
    sut = ("1004", 752466.254, 6600112.012)

    proj = controller_projection(*sut)

    assert proj == "Lambert93"

def test_projection_GPS_correcte() :
    sut = ("1004", 0, 0)

    proj = controller_projection(*sut)

    assert proj == "GPS"

def test_projection_correcte_avec_des_flottants() :
    sut = ("1004", 1585702.06, 2185080.612)

    proj = controller_projection(*sut)

    assert proj == "CC43"

def test_lattitude_incorrecte() :
    sut = ("1004", 1000000, 0)

    proj = controller_projection(*sut)

    assert proj == "Mauvaise projection"

def test_longitude_incorrecte(capsys) : 
    sut = ("1004", 1000000, 500000000)

    proj = controller_projection(*sut)
    out, err = capsys.readouterr()
    expected_out = "\nProj. trouvé : Mauvaise projection\n" + "\nAvertissement : Longitude du point id 1004 pas en métropole.\n"

    assert proj == "Mauvaise projection"
    assert out == expected_out


def test_coordonnees_intersection_entre_CC47_et_Lambert93(capsys):
    sut = ("1004", 1125804.292, 6291079.947)

    proj = controller_projection(*sut)
    out, err = capsys.readouterr()
    expected_out = "\nAvertissement : ces coordonnées peuvent être interpréter correctement comme du CC47 et du Lambert93\n" + \
                   "Normalement vous devrez projeter la Table de Point en CC47\n" + \
                   "\nProj. trouvé : CC47\n"

    assert proj == "CC47"
    assert out == expected_out

