I am trying to write a function that validates a package that contains 2 dates (beginning and end), a destination and a price
Initially, I tried to write a function that "creates" dates and puts them in a list and then compares them to find out if the end date was lower than the beginning but I figured that was too complicated so I resorted to the datetime inbuilt module
However, when I try to run the test function, it fails and it outputs this error message
File "C:\Users\Anon\Desktop\Fac\FP\pythonProject\main.py", line 65, in valideaza_pachet
    raise Exception(err)
Exception: wrong dates!
I assume that I must have messed up a condition in the valideaza_pachet() function, but I don't understand what I did wrong
The code:
import time
import calendar
from datetime import date, datetime
def creeaza_pachet(data_i, data_s, dest, pret):
    # function that creates a tourism package, data_i = beginning date, data_s = end date, dest = destination and pret = price
    return {
        "data_i": data_i,
        "data_s": data_s,
        "dest": dest,
        "pret": pret
    }
def get_data_i(pachet):
    # functie that returns the beginning date of the package
    return pachet["data_i"]
def get_data_s(pachet):
    # functie that returns the end date of the package
    return pachet["data_s"]
def get_destinatie(pachet):
    # functie that returns the destination of the package
    return pachet["dest"]
def get_pret(pachet):
    # functie that returns the price of the package
    # input: pachet - un pachet
    # output: pretul float > 0 al pachetului
    return pachet["pret"]
def valideaza_pachet(pachet):
    #functie that validates if a package was correctly introduced or not
    #it raises an Exception as ex if any of the conditions aren't met
    err = ""
    if get_data_i(pachet) < get_data_s(pachet):
        err += "wrong dates!" # if the end date is lower than the beginning date
    if get_destinatie(pachet) == " ":
        err += "wrong destination!"
    if get_pret(pachet) <= 0:
        err += "wrong price!"
    if len(err) > 0:
        raise Exception(err)
def test_valideaza_pachet():
    pachet = creeaza_pachet(datetime.strptime('24/08/2021',"%d/%m/%Y"), datetime.strptime('26/08/2021',"%d/%m/%Y"), "Galati", 9000.1)
    valideaza_pachet(pachet)
    pachet_gresit = creeaza_pachet(datetime.strptime('24/08/2021',"%d/%m/%Y"), datetime.strptime('22/08/2021',"%d/%m/%Y"), "Galati", 9000.1)
    try:
        valideaza_pachet(pachet_gresit)
        assert False
    except Exception as ex:
        assert (str(ex) == "wrong dates!\n")
    alt_pachet = creeaza_pachet(datetime.strptime('24/08/2021',"%d/%m/%Y"), datetime.strptime('22/08/2021',"%d/%m/%Y"), " ", -904)
    try:
        valideaza_pachet(alt_pachet)
        assert False
    except Exception as ex:
        assert(str(ex) == "wrong dates!\nwrong destination!\nwrong price!\n")
def test_creeaza_pachet():
    data_i_string = '24/08/2021'
    data_i = datetime.strptime(data_i_string, "%d/%m/%Y")
    data_s_string = '26/08/2021'
    data_s = datetime.strptime(data_s_string, "%d/%m/%Y")
    dest = "Galati"
    pret = 9000.1
    pachet = creeaza_pachet(data_i,data_s,dest,pret)
    assert (get_data_i(pachet) == data_i)
    assert (get_data_s(pachet) == data_s)
    assert (get_destinatie(pachet) == dest)
    assert (abs(get_pret(pachet) - pret) < 0.0001)
def run_teste():
    test_creeaza_pachet()
    test_valideaza_pachet()
def run():
    pass
def main():
    run()
    run_teste()
main()