#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""Tests for `ethiopian_date_converter` package."""


import unittest

from ethiopian_date_converter import converter


class TestEthiopian_date_converter(unittest.TestCase):
    """Tests for `ethiopian_date_converter` package."""

    def test_ethiopic_to_gregorian(self):
        pairs = [
            [('5492-05-07', 'AA'), '0000-01-01'],
            [('5493-05-08', 'AA'), '0001-01-01'],
            [('5499-13-06', 'AA'), '0007-08-27'],
            [('5500-01-01', 'AA'), '0007-08-28'],
            [('5500-01-02', 'AA'), '0007-08-29'],
            [('5500-13-05', 'AA'), '0008-08-26'],
            [('1855-02-20', ), '1862-10-29'],
            [('1857-10-29', ), '1865-07-05'],
            [('1858-05-22', ), '1866-01-29'],
            [('1858-08-10', ), '1866-04-17'],
            [('1859-04-28', ), '1867-01-05'],
            [('1860-05-05', ), '1868-01-13'],
            [('0001-01-01', ), '0008-08-27'],
            [('0002-01-01', ), '0009-08-27'],
            [('0003-01-01', ), '0010-08-27'],
            [('0004-01-01', ), '0011-08-28'],
            [('0001-13-05', ), '0009-08-26'],
            [('0002-13-05', ), '0010-08-26'],
            [('0003-13-05', ), '0011-08-26'],
            [('0003-13-06', ), '0011-08-27'],
            [('0004-13-05', ), '0012-08-26'],
            [('1575-02-06', ), '1582-10-13'],
            [('1575-02-07', ), '1582-10-14'],
            [('1575-02-08', ), '1582-10-15'],
            [('1575-02-09', ), '1582-10-16'],
            [('1892-04-23', ), '1900-01-01'],
            [('1997-04-23', ), '2005-01-01'],
            [('2000-13-05', ), '2008-09-10'],
            [('1893-04-22', ), '1900-12-31'],
            [('1985-04-22', ), '1992-12-31'],
            [('1989-04-22', ), '1996-12-31'],
            [('1993-04-22', ), '2000-12-31'],
            [('1997-04-22', ), '2004-12-31'],
            [('2001-04-22', ), '2008-12-31'],
            [('2993-04-14', ), '3000-12-31'],
            [('3993-04-07', ), '4000-12-31'],
            [('5993-03-22', ), '6000-12-31']]

        for ethiopic, gregorian in pairs:
            assert converter(*ethiopic, to='gregorian') == gregorian, gregorian

    def test_gregorian_to_ethiopic(self):
        pairs = [[('1862-10-29', ), '1855-02-20'],
                 [('1865-07-05', ), '1857-10-29'],
                 [('1866-01-29', ), '1858-05-22'],
                 [('1866-04-17', ), '1858-08-10'],
                 [('1867-01-05', ), '1859-04-28'],
                 [('1868-01-13', ), '1860-05-05'],
                 [('0001-01-01', ), '5493-05-08'],
                 [('0007-08-27', ), '5499-13-06'],
                 [('0007-08-28', ), '5500-01-01'],
                 [('0007-08-29', ), '5500-01-02'],
                 [('0008-08-27', ), '0001-01-01'],
                 [('0009-08-27', ), '0002-01-01'],
                 [('0010-08-27', ), '0003-01-01'],
                 [('0011-08-28', ), '0004-01-01'],
                 [('0008-08-26', ), '5500-13-05'],
                 [('0009-08-26', ), '0001-13-05'],
                 [('0010-08-26', ), '0002-13-05'],
                 [('0011-08-26', ), '0003-13-05'],
                 [('0011-08-27', ), '0003-13-06'],
                 [('0012-08-26', ), '0004-13-05'],
                 [('1582-10-13', ), '1575-02-06'],
                 [('1582-10-14', ), '1575-02-07'],
                 [('1582-10-15', ), '1575-02-08'],
                 [('1582-10-16', ), '1575-02-09'],
                 [('1900-01-01', ), '1892-04-23'],
                 [('2005-01-01', ), '1997-04-23'],
                 [('2008-09-10', ), '2000-13-05'],
                 [('1900-12-31', ), '1893-04-22'],
                 [('1992-12-31', ), '1985-04-22'],
                 [('1996-12-31', ), '1989-04-22'],
                 [('2000-12-31', ), '1993-04-22'],
                 [('2004-12-31', ), '1997-04-22'],
                 [('2008-12-31', ), '2001-04-22'],
                 [('3000-12-31', ), '2993-04-14'],
                 [('4000-12-31', ), '3993-04-07'],
                 [('6000-12-31', ), '5993-03-22']]

        for gregorian, ethiopic in pairs:
            assert converter(*gregorian, to='ethiopian') == ethiopic, ethiopic

if __name__ == '__main__':
    unittest.main()
