import pytest
import datetime

import yacron.cron


FAKE_TIME = datetime.datetime(1999, 12, 31, 0, 0, 0)


@pytest.fixture
def patch_datetime_now(monkeypatch):

    class mydatetime:
        @classmethod
        def utcnow(cls):
            return FAKE_TIME

    monkeypatch.setattr(yacron.cron.datetime, 'datetime', mydatetime)


@pytest.mark.parametrize("tz, expected_now", [
    ('Asia/Taipei', datetime.datetime(1999, 12, 31, 8)),  # UTC+8
    ('America/New_York', datetime.datetime(1999, 12, 30, 19)),  # UTC-5
    ('America/Los_Angeles', datetime.datetime(1999, 12, 30, 16)),  # UTC-8
])
def test_tz_get_now(patch_datetime_now, tz, expected_now):
    assert yacron.cron.get_now(False, tz) == expected_now

