This commit is contained in:
@@ -4,50 +4,46 @@ from slic.utils.readable import readable_seconds
|
|||||||
@pytest.mark.parametrize("seconds, expected", [
|
@pytest.mark.parametrize("seconds, expected", [
|
||||||
|
|
||||||
(59.4, "59 seconds"),
|
(59.4, "59 seconds"),
|
||||||
(59.9, "59 seconds"),
|
(59.9, "60 seconds"),
|
||||||
(119.9, "120 seconds"),
|
(119.9, "120 seconds"),
|
||||||
(120.1, "2 minutes"),
|
(120.1, "2 minutes"),
|
||||||
|
|
||||||
(3599.4, "59 minutes"),
|
(3599.9, "60 minutes"),
|
||||||
(3599.9, "60 minutes"),
|
(3600.1, "1 hour"),
|
||||||
(3600.1, "1 hour"),
|
(7199.9, "2 hours"),
|
||||||
(7199.9, "119 minutes"),
|
(7200.1, "2 hours"),
|
||||||
(7200.1, "2 hours"),
|
|
||||||
|
(90.4, "90 seconds"),
|
||||||
(90.4, "90 seconds"),
|
(90.6, "91 seconds"),
|
||||||
(90.6, "91 seconds"),
|
(121.9, "2 minutes"),
|
||||||
(121.9, "2 minutes"),
|
(3660.1, "1 hour"),
|
||||||
(3659.9, "60 minutes"),
|
|
||||||
(3660.1, "1 hour"),
|
(1296000.0, "15 days"), # 15 * 86400
|
||||||
|
(2332800.0, "27 days"), # 27 * 86400
|
||||||
(2629746 * 0.5, "15 days"),
|
(2592000.0, "1 month"), # 30 * 86400
|
||||||
(2629746 * 0.9, "27 days"),
|
(2678400.0, "1 month"), # 31 * 86400
|
||||||
(2629746 * 1.0, "1 month"),
|
(3888000.0, "2 months"), # 45 * 86400
|
||||||
(2629746 * 1.1, "1 month"),
|
(5097600.0, "2 months"), # 59 * 86400
|
||||||
(2629746 * 1.5, "1 month"),
|
(5184000.0, "2 months"), # 60 * 86400
|
||||||
(2629746 * 1.9, "1 month"),
|
(5270400.0, "2 months"), # 61 * 86400
|
||||||
(2629746 * 2.0, "2 months"),
|
|
||||||
(2629746 * 2.1, "2 months"),
|
(23328000.0, "9 months"), # 9 * 2592000
|
||||||
|
(31104000.0, "1 year"), # 12 * 2592000
|
||||||
(31556904 * 0.9, "9 months"),
|
(33696000.0, "1 year"), # 13 * 2592000
|
||||||
(31556904 * 1.0, "1 year"),
|
(59616000.0, "2 years"), # 23 * 2592000
|
||||||
(31556904 * 1.1, "1 year"),
|
(62208000.0, "2 years"), # 24 * 2592000
|
||||||
(31556904 * 1.5, "1 year"),
|
|
||||||
(31556904 * 1.9, "1 year"),
|
(5158080.0, "2 months"), # 1.99 * 2592000
|
||||||
(31556904 * 2.0, "2 years"),
|
(5209920.0, "2 months"), # 2.01 * 2592000
|
||||||
(31556904 * 2.1, "2 years"),
|
(30844800.0, "12 months"), # 11.9 * 2592000
|
||||||
|
(31363200.0, "1 year"), # 12.1 * 2592000
|
||||||
(2629746 * 1.99, "1 month"),
|
|
||||||
(2629746 * 2.01, "2 months"),
|
(3153600.0, "1 month"), # 0.1 * 31536000
|
||||||
(31556904 * 1.99, "1 year"),
|
(15452640.0, "5 months"), # 0.49 * 31536000
|
||||||
(31556904 * 2.01, "2 years"),
|
|
||||||
|
|
||||||
(2629746 * 11.9, "11 months"),
|
|
||||||
(2629746 * 12.1, "1 year"),
|
|
||||||
(31556904 * 0.1, "1 month"),
|
|
||||||
(31556904 * 0.49, "5 months")
|
|
||||||
|
|
||||||
])
|
])
|
||||||
|
def test_readable_seconds(seconds, expected):
|
||||||
|
assert readable_seconds(seconds) == expected
|
||||||
|
|
||||||
|
|
||||||
def test_rounding_cases(seconds, expected):
|
def test_rounding_cases(seconds, expected):
|
||||||
assert readable_seconds(seconds) == expected
|
assert readable_seconds(seconds) == expected
|
||||||
Reference in New Issue
Block a user