def test_fromDateConst(gregorian: str, tzolkin: TzolkinDate) -> None:
    """Test `Tzolkin`."""
    gregorian_date = datetime.datetime.strptime(gregorian, USED_DATEFMT).date()
    to_test = Tzolkin.fromDate(gregorian_date)
    another = Tzolkin(number=tzolkin.number, name_str=day_names[tzolkin.name])
    assert to_test.getDayNumber() == another.getDayNumber()  # nosec
    assert to_test.getDayNameNumber() == another.getDayNameNumber()  # nosec
def test_fromToday() -> None:
    """Test `Tzolkin.fromToday`."""
    assert (  # nosec
        Tzolkin.fromToday().getDayName() == Tzolkin.fromDate(
            date=datetime.date.today()).getDayName())
    assert (  # nosec
        Tzolkin.fromToday().getDayNumber() == Tzolkin.fromDate(
            date=datetime.date.today()).getDayNumber())
def test_getDayDiff(gregorian: str, tzolkin: TzolkinDate, days: int) -> None:
    """Test `Tzolkin.getDayDiff`."""
    gregorian_date = datetime.datetime.strptime(gregorian, USED_DATEFMT).date()
    tzolkin_start = Tzolkin.fromDate(date=gregorian_date)
    assert tzolkin_start.getTzolkinDate().number == tzolkin.number  # nosec
    assert tzolkin_start.getTzolkinDate().name == tzolkin.name  # nosec
    tzolkin_add = Tzolkin.fromDate(date=gregorian_date).addTimedelta(
        datetime.timedelta(days=days))
    assert tzolkin_start.getDayDiff(other=tzolkin_add) == days  # nosec
def test_getLastDate(gregorian: str, tzolkin: TzolkinDate) -> None:
    """Test `Tzolkin.getLastDate`."""
    gregorian_date = datetime.datetime.strptime(
        gregorian, USED_DATEFMT).date() + datetime.timedelta(days=1)
    to_test = Tzolkin.fromDateString(date_str=gregorian, fmt=USED_DATEFMT)
    assert to_test.getLastDate(
        start_date=gregorian_date) == lastTzolkin(  # nosec
            tzolkin=tzolkin, starting=gregorian_date)
def test_getTzolkinCalendar() -> None:
    """Test `Tzolkin.getTzolkinCalendar`."""
    calendar = Tzolkin.getTzolkinCalendar()
    tzolkin_dict = makeLookUpTable()
    assert len(calendar) == 260  # nosec
    for key in tzolkin_dict:
        assert calendar[key - 1] == "{number} {name}".format(  # nosec
            number=tzolkin_dict[key].number,
            name=day_names[tzolkin_dict[key].name])
def test_getLastDateList(gregorian: str, tzolkin: TzolkinDate) -> None:
    """Test `Tzolkin.getLastDateList`."""
    gregorian_date = datetime.datetime.strptime(
        gregorian, USED_DATEFMT).date() - datetime.timedelta(days=1)
    to_test = Tzolkin.fromDateString(date_str=gregorian, fmt=USED_DATEFMT)
    tz_list = to_test.getLastDateList(start_date=gregorian_date)
    good_list = tzolkin2gregorian(tzolkin=tzolkin,
                                  start=gregorian_date,
                                  num_results=50,
                                  forward=False)
    assert len(tz_list) == 50  # nosec
    for idx in range(0, len(good_list)):
        assert tz_list[idx] == good_list[idx]  # nosec
def test_getLastDateToday(gregorian: str, tzolkin: TzolkinDate) -> None:
    """Test `Tzolkin.getLastDate`."""
    to_test = Tzolkin.fromDateString(date_str=gregorian, fmt=USED_DATEFMT)
    assert to_test.getLastDate() == lastTzolkin(  # nosec
        tzolkin=tzolkin, starting=datetime.date.today())
def test_TzolkinException3() -> None:
    """Test the constructor of `Tzolkin`, using a invalid day name."""
    with pytest.raises(TzolkinException) as excp:
        Tzolkin(number=6, name_str="DOES NOT EXIST")
    assert excp  # nosec
def test_TzolkinException2() -> None:
    """Test the constructor of `Tzolkin`, using a invalid day name number."""
    with pytest.raises(TzolkinException) as excp:
        Tzolkin(number=6, name_number=27)
    assert excp  # nosec
def test_getTzolkinYearDay(gregorian: str, tzolkin: TzolkinDate) -> None:
    """Test `Tzolkin.getTzolkinYearDay`."""
    gregorian_date = datetime.datetime.strptime(gregorian, USED_DATEFMT).date()
    to_test = Tzolkin.fromDate(gregorian_date)
    assert to_test.getTzolkinYearDay() == getTzolkinDay(tzolkin)  # nosec
def test_getTzolkinDate(gregorian: str, tzolkin: TzolkinDate) -> None:
    """Test `Tzolkin.getTzolkinDate`."""
    gregorian_date = datetime.datetime.strptime(gregorian, USED_DATEFMT).date()
    to_test = Tzolkin.fromDate(gregorian_date)
    assert to_test.getTzolkinDate().number == tzolkin.number  # nosec
    assert to_test.getTzolkinDate().name == tzolkin.name  # nosec
def test_fromIsoFormat(gregorian: str, tzolkin: TzolkinDate) -> None:
    """Test `Tzolkin.fromIsoFormat`."""
    gregorian_date = datetime.datetime.strptime(gregorian, USED_DATEFMT).date()
    to_test = Tzolkin.fromIsoFormat(date_str=gregorian_date.isoformat())
    assert to_test.getDayNumber() == tzolkin.number  # nosec
    assert to_test.getDayNameNumber() == tzolkin.name  # nosec
def test_fromDateStr(gregorian: str, tzolkin: TzolkinDate) -> None:
    """Test `Tzolkin.fromDateString`."""
    to_test = Tzolkin.fromDateString(date_str=gregorian, fmt=USED_DATEFMT)
    assert to_test.getDayNumber() == tzolkin.number  # nosec
    assert to_test.getDayNameNumber() == tzolkin.name  # nosec
def test_print(gregorian: str, tzolkin: TzolkinDate) -> None:
    """Test `Tzolkin.__repr__()`."""
    to_test = Tzolkin.fromDateString(date_str=gregorian, fmt=USED_DATEFMT)
    assert to_test.__repr__() == tzolkin.__repr__()  # nosec
def test_getNameNumberFromNameExc() -> None:
    """Test `Tzolkin.getNameNumberFromName`, raises excpention."""
    with pytest.raises(TzolkinException) as excp:
        Tzolkin.getNameNumberFromName(name_str="BLA")
    assert excp  # nosec
def test_getNameNumberFromName() -> None:
    """Test `Tzolkin.getNameNumberFromName`."""
    for number in day_names:
        assert (  # nosec
            Tzolkin.getNameNumberFromName(
                name_str=day_names[number]) == number)