class TestDtParse:
    """Test dt_*."""
    @pytest.mark.parametrize(
        "val",
        [format(dt_now()), dt_now(),
         timedelta(minutes=1)],
        scope="class",
    )
    def test_val(self, val):
        now = dt_parse(obj=val)
        assert isinstance(now, datetime)

    def test_list(self):
        now = [format(dt_now())]
        now = dt_parse(obj=now)
        assert isinstance(now, list)
        assert [isinstance(x, datetime) for x in now]
Esempio n. 2
0
class TestDtParse(object):
    """Test tools.dt_*."""

    @pytest.mark.parametrize(
        "val",
        [format(tools.dt_now()), tools.dt_now(), tools.timedelta(minutes=1)],
        scope="class",
    )
    def test_val(self, val):
        """Pass."""
        now = tools.dt_parse(obj=val)
        assert isinstance(now, tools.datetime)

    def test_list(self):
        """Pass."""
        now = [format(tools.dt_now())]
        now = tools.dt_parse(obj=now)
        assert isinstance(now, tools.LIST)
        assert [isinstance(x, tools.datetime) for x in now]
 def test_now_notz(self):
     now = dt_now(tz=None)
     assert not now.tzinfo
 def test_now(self):
     now = dt_now()
     assert now.tzinfo
 def test_min_ago_utc_dt_naive(self):
     """Simple test."""
     then = dt_now(None) - timedelta(minutes=1)
     assert dt_min_ago(obj=then) == 1
 def test_min_ago_utc_str(self):
     """Simple test."""
     then = format(dt_now() - timedelta(minutes=1))
     assert dt_min_ago(obj=then) == 1
 def test_ok(self, val):
     then = dt_now(delta=timedelta(minutes=5))
     assert dt_within_min(obj=then, n=val) is True
 def test_list(self):
     now = [format(dt_now())]
     now = dt_parse(obj=now)
     assert isinstance(now, list)
     assert [isinstance(x, datetime) for x in now]
 def test_now_delta(self):
     then = dt_now(delta=timedelta(minutes=5))
     assert dt_min_ago(then) == 5
Esempio n. 10
0
 def test_ok(self, val):
     """Pass."""
     then = tools.dt_now(delta=tools.timedelta(minutes=5))
     assert tools.dt_within_min(obj=then, n=val) is True
Esempio n. 11
0
 def test_list(self):
     """Pass."""
     now = [format(tools.dt_now())]
     now = tools.dt_parse(obj=now)
     assert isinstance(now, tools.LIST)
     assert [isinstance(x, tools.datetime) for x in now]
Esempio n. 12
0
 def test_now_delta(self):
     """Pass."""
     then = tools.dt_now(delta=tools.timedelta(minutes=5))
     assert tools.dt_min_ago(then) == 5
Esempio n. 13
0
 def test_now_notz(self):
     """Pass."""
     now = tools.dt_now(tz=None)
     assert not now.tzinfo
Esempio n. 14
0
 def test_now(self):
     """Pass."""
     now = tools.dt_now()
     assert now.tzinfo
Esempio n. 15
0
 def test_min_ago_utc_dt(self):
     """Simple test."""
     then = tools.dt_now() - tools.timedelta(minutes=1)
     assert tools.dt_min_ago(obj=then) == 1
Esempio n. 16
0
 def test_bad(self, val):
     """Pass."""
     then = dt_now(delta=timedelta(minutes=5))
     assert dt_within_min(obj=then, n=val) is False