# Path: tests/util.py
# def dt(dtstr):  # (parse datetime str)
#     """
#     Return datetime parsed from str of various accepted formats, eg:
#       - '2014-02-14 16:30:45 001234'
#       - '2014-02-14 16:30:45'
#       - '2014-02-14 16:30'
#       - '2014-02-14'
#     Raise ValueError if not recognizable.
#     """
#     FORMATS = (
#         '%Y-%m-%d %H:%M:%S %f',
#         '%Y-%m-%d %H:%M:%S',
#         '%Y-%m-%d %H:%M',
#         '%Y-%m-%d',
#     )
#     for fmt in FORMATS:
#         try:
#             dt1 = datetime.strptime(dtstr, fmt)
#             return dt1
#         except ValueError as e:
#             pass
#     raise ValueError("time data '{dtstr}' does not match any format"
#         .format(dtstr=dtstr))


import pytest
import axonchisel.metrics.foundation.chrono.dtmath as dtmath
from .util import dt
        t(-100,     '2014-02-12 14:30:45 001234')
        t(-144*60,  '2013-08-18 16:30:45 001234')
        t(+144*60,  '2014-08-13 16:30:45 001234')

    def test_add_hours(self, dts):
        def t(delta, check):
            assert dtmath.add_hours(dts[4], delta) == dt(check)
        t(+5,    '2014-02-14 21:30:45 001234')
        t(-5,    '2014-02-14 11:30:45 001234')
        t(+44,   '2014-02-16 12:30:45 001234')
        t(-44,   '2014-02-12 20:30:45 001234')

    def test_add_days(self, dts):
        def t(delta, check):
            assert dtmath.add_days(dts[4], delta) == dt(check)
        t(+5,    '2014-02-19 16:30:45 001234')
        t(-5,    '2014-02-09 16:30:45 001234')
        t(+700,  '2016-01-15 16:30:45 001234')
        t(-700,  '2012-03-16 16:30:45 001234')

    def test_add_weeks(self, dts):
        def t(delta, check):
            assert dtmath.add_weeks(dts[4], delta) == dt(check)
        t(+5,    '2014-03-21 16:30:45 001234')
        t(-5,    '2014-01-10 16:30:45 001234')
        t(+200,  '2017-12-15 16:30:45 001234')
        t(-200,  '2010-04-16 16:30:45 001234')

    def test_add_months(self, dts):
        def t(delta, check):

# Path: tests/util.py
# def dt(dtstr):  # (parse datetime str)
#     """
#     Return datetime parsed from str of various accepted formats, eg:
#       - '2014-02-14 16:30:45 001234'
#       - '2014-02-14 16:30:45'
#       - '2014-02-14 16:30'
#       - '2014-02-14'
#     Raise ValueError if not recognizable.
#     """
#     FORMATS = (
#         '%Y-%m-%d %H:%M:%S %f',
#         '%Y-%m-%d %H:%M:%S',
#         '%Y-%m-%d %H:%M',
#         '%Y-%m-%d',
#     )
#     for fmt in FORMATS:
#         try:
#             dt1 = datetime.strptime(dtstr, fmt)
#             return dt1
#         except ValueError as e:
#             pass
#     raise ValueError("time data '{dtstr}' does not match any format"
#         .format(dtstr=dtstr))


# Path: tests/test_dtmath.py
import pytest
import axonchisel.metrics.foundation.chrono.dtmath as dtmath
from .util import dt

        t(-100,     '2014-02-12 14:30:45 001234')
        t(-144*60,  '2013-08-18 16:30:45 001234')
        t(+144*60,  '2014-08-13 16:30:45 001234')

    def test_add_hours(self, dts):
        def t(delta, check):
            assert dtmath.add_hours(dts[4], delta) == dt(check)
        t(+5,    '2014-02-14 21:30:45 001234')
        t(-5,    '2014-02-14 11:30:45 001234')
        t(+44,   '2014-02-16 12:30:45 001234')
        t(-44,   '2014-02-12 20:30:45 001234')

    def test_add_days(self, dts):
        def t(delta, check):
            assert dtmath.add_days(dts[4], delta) == dt(check)
        t(+5,    '2014-02-19 16:30:45 001234')
        t(-5,    '2014-02-09 16:30:45 001234')
        t(+700,  '2016-01-15 16:30:45 001234')
        t(-700,  '2012-03-16 16:30:45 001234')

    def test_add_weeks(self, dts):
        def t(delta, check):
            assert dtmath.add_weeks(dts[4], delta) == dt(check)
        t(+5,    '2014-03-21 16:30:45 001234')
        t(-5,    '2014-01-10 16:30:45 001234')
        t(+200,  '2017-12-15 16:30:45 001234')
        t(-200,  '2010-04-16 16:30:45 001234')

    def test_add_months(self, dts):
        def t(delta, check):

            assert dtmath.add_months(dts[4], delta) == dt(check)