Skip to content

Commit

Permalink
Created test file for each country and moved corresponding tests there
Browse files Browse the repository at this point in the history
  • Loading branch information
s-weigand committed Dec 7, 2020
1 parent 5b5bcf9 commit 1e32e83
Show file tree
Hide file tree
Showing 71 changed files with 10,195 additions and 6,817 deletions.
6,817 changes: 0 additions & 6,817 deletions tests.py

This file was deleted.

27 changes: 27 additions & 0 deletions tests/countries/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-

# python-holidays
# ---------------
# A fast, efficient Python library for generating country, province and state
# specific sets of holidays on the fly. It aims to make determining whether a
# specific date is a holiday as fast and flexible as possible.
#
# Author: ryanss <[email protected]> (c) 2014-2017
# dr-prodigy <[email protected]> (c) 2017-2020
# Website: https://github.com/dr-prodigy/python-holidays
# License: MIT (see LICENSE file)

import os
import sys
import unittest
import warnings
from glob import glob
from itertools import product

from datetime import date, datetime, timedelta
from dateutil.relativedelta import relativedelta, MO
from flake8.api import legacy as flake8

import holidays


55 changes: 55 additions & 0 deletions tests/countries/test_angola.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# -*- coding: utf-8 -*-

# python-holidays
# ---------------
# A fast, efficient Python library for generating country, province and state
# specific sets of holidays on the fly. It aims to make determining whether a
# specific date is a holiday as fast and flexible as possible.
#
# Author: ryanss <[email protected]> (c) 2014-2017
# dr-prodigy <[email protected]> (c) 2017-2020
# Website: https://github.com/dr-prodigy/python-holidays
# License: MIT (see LICENSE file)

import os
import sys
import unittest
import warnings
from glob import glob
from itertools import product

from datetime import date, datetime, timedelta
from dateutil.relativedelta import relativedelta, MO
from flake8.api import legacy as flake8

import holidays


class TestAngola(unittest.TestCase):
def setUp(self):
self.holidays = holidays.AO()

def test_new_years(self):
self.assertIn("1975-01-01", self.holidays)
self.assertIn("2017-01-01", self.holidays)
self.assertIn("2999-01-01", self.holidays)
self.assertIn("2017-01-02", self.holidays) # sunday

def test_easter(self):
self.assertIn(date(2017, 4, 14), self.holidays)
self.assertIn(date(2020, 4, 10), self.holidays)
self.assertIn(date(1994, 4, 1), self.holidays)

def test_static(self):
self.assertIn("2004-03-08", self.holidays)
self.assertIn("2020-03-23", self.holidays)

def test_long_weekend(self):
self.assertIn("2020-02-03", self.holidays)
self.assertIn("2019-04-05", self.holidays)
self.assertIn("2050-03-07", self.holidays)

def test_not_holiday(self):
self.assertNotIn("2016-12-28", self.holidays)
self.assertNotIn("2015-03-02", self.holidays)
self.assertNotIn("2018-03-23", self.holidays)
178 changes: 178 additions & 0 deletions tests/countries/test_argentina.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
# -*- coding: utf-8 -*-

# python-holidays
# ---------------
# A fast, efficient Python library for generating country, province and state
# specific sets of holidays on the fly. It aims to make determining whether a
# specific date is a holiday as fast and flexible as possible.
#
# Author: ryanss <[email protected]> (c) 2014-2017
# dr-prodigy <[email protected]> (c) 2017-2020
# Website: https://github.com/dr-prodigy/python-holidays
# License: MIT (see LICENSE file)

import os
import sys
import unittest
import warnings
from glob import glob
from itertools import product

from datetime import date, datetime, timedelta
from dateutil.relativedelta import relativedelta, MO
from flake8.api import legacy as flake8

import holidays


class TestAR(unittest.TestCase):
def setUp(self):
self.holidays = holidays.AR(observed=True)

def test_new_years(self):
self.holidays.observed = False
self.assertNotIn(date(2010, 12, 31), self.holidays)
self.assertNotIn(date(2017, 1, 2), self.holidays)
self.holidays.observed = True
self.assertIn(date(2017, 1, 1), self.holidays)
for year in range(1900, 2100):
dt = date(year, 1, 1)
self.assertIn(dt, self.holidays)
self.assertNotIn(dt + relativedelta(days=-1), self.holidays)
self.assertNotIn(dt + relativedelta(days=+1), self.holidays)

def test_carnival_day(self):
for dt in [
date(2018, 2, 12),
date(2018, 2, 13),
date(2017, 2, 27),
date(2017, 2, 28),
date(2016, 2, 8),
date(2016, 2, 9),
]:
self.assertIn(dt, self.holidays)

def test_memory_national_day(self):
self.holidays.observed = False
self.assertNotIn(date(1907, 3, 24), self.holidays)
self.assertNotIn(date(2002, 3, 24), self.holidays)
self.holidays.observed = True
for dt in [date(2018, 3, 24), date(2017, 3, 24), date(2016, 3, 24)]:
self.assertIn(dt, self.holidays)

def test_holy_week_day(self):
for dt in [
date(2018, 3, 29),
date(2018, 3, 30),
date(2017, 4, 13),
date(2017, 4, 14),
date(2016, 3, 24),
date(2016, 3, 25),
]:
self.assertIn(dt, self.holidays)

def test_malvinas_war_day(self):
for year in range(1900, 2100):
dt = date(year, 4, 2)
self.assertIn(dt, self.holidays)

def test_labor_day(self):
self.holidays.observed = False
self.assertNotIn(date(2010, 4, 30), self.holidays)
self.assertNotIn(date(2011, 5, 2), self.holidays)
self.holidays.observed = True
self.assertIn(date(1922, 5, 1), self.holidays)
for year in range(1900, 2100):
dt = date(year, 5, 1)
self.assertIn(dt, self.holidays)
self.assertNotIn(dt + relativedelta(days=-1), self.holidays)
self.assertNotIn(dt + relativedelta(days=+1), self.holidays)

def test_may_revolution_day(self):
self.holidays.observed = False
self.assertNotIn(date(1930, 5, 25), self.holidays)
self.assertNotIn(date(2014, 5, 25), self.holidays)
self.holidays.observed = True
for year in range(1900, 2100):
dt = date(year, 5, 1)
self.assertIn(dt, self.holidays)
self.assertNotIn(dt + relativedelta(days=-1), self.holidays)
self.assertNotIn(dt + relativedelta(days=+1), self.holidays)

def test_guemes_day(self):
for year in range(1900, 2100):
dt = date(year, 6, 17)
self.assertIn(dt, self.holidays)
self.assertNotIn(dt + relativedelta(days=-1), self.holidays)
self.assertNotIn(dt + relativedelta(days=+1), self.holidays)

def test_belgrano_day(self):
for year in range(1900, 2100):
dt = date(year, 6, 20)
self.assertIn(dt, self.holidays)
self.assertNotIn(dt + relativedelta(days=-1), self.holidays)
self.assertNotIn(dt + relativedelta(days=+1), self.holidays)

def test_independence_day(self):
self.holidays.observed = False
self.assertNotIn(date(2017, 7, 9), self.holidays)
self.assertNotIn(date(2011, 7, 9), self.holidays)
self.holidays.observed = True
self.assertIn(date(2017, 7, 9), self.holidays)
self.assertIn(date(2011, 7, 9), self.holidays)
for year in range(1900, 2100):
dt = date(year, 7, 9)
self.assertIn(dt, self.holidays)
self.assertNotIn(dt + relativedelta(days=-1), self.holidays)
self.assertNotIn(dt + relativedelta(days=+1), self.holidays)

def test_san_martin_day(self):
self.holidays.observed = False
self.assertNotIn(date(1930, 8, 10), self.holidays)
self.assertNotIn(date(2008, 8, 10), self.holidays)
self.holidays.observed = True
for year in range(1900, 2100):
dt = date(year, 8, 17)
self.assertIn(dt, self.holidays)
self.assertNotIn(dt + relativedelta(days=-1), self.holidays)
self.assertNotIn(dt + relativedelta(days=+1), self.holidays)

def test_cultural_day(self):
self.holidays.observed = False
self.assertNotIn(date(2014, 10, 12), self.holidays)
self.assertNotIn(date(1913, 10, 12), self.holidays)
self.holidays.observed = True
for year in range(1900, 2100):
dt = date(year, 10, 12)
self.assertIn(dt, self.holidays)
self.assertNotIn(dt + relativedelta(days=-1), self.holidays)
self.assertNotIn(dt + relativedelta(days=+1), self.holidays)

def test_national_sovereignty_day(self):
for year in range(1900, 2100):
dt = date(year, 11, 20)
if year < 2010:
self.assertNotIn(dt, self.holidays)
else:
self.assertIn(dt, self.holidays)
self.assertNotIn(dt + relativedelta(days=-1), self.holidays)
self.assertNotIn(dt + relativedelta(days=+1), self.holidays)

def test_inmaculate_conception_day(self):
self.holidays.observed = False
self.assertNotIn(date(1940, 12, 8), self.holidays)
self.assertNotIn(date(2013, 12, 8), self.holidays)
self.holidays.observed = True
for year in range(1900, 2100):
dt = date(year, 12, 8)
self.assertIn(dt, self.holidays)
self.assertNotIn(dt + relativedelta(days=-1), self.holidays)
self.assertNotIn(dt + relativedelta(days=+1), self.holidays)

def test_christmas(self):
for year in range(1900, 2100):
dt = date(year, 12, 25)
self.assertIn(dt, self.holidays)
self.assertNotIn(dt + relativedelta(days=-1), self.holidays)
self.assertNotIn(dt + relativedelta(days=+1), self.holidays)

110 changes: 110 additions & 0 deletions tests/countries/test_aruba.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# -*- coding: utf-8 -*-

# python-holidays
# ---------------
# A fast, efficient Python library for generating country, province and state
# specific sets of holidays on the fly. It aims to make determining whether a
# specific date is a holiday as fast and flexible as possible.
#
# Author: ryanss <[email protected]> (c) 2014-2017
# dr-prodigy <[email protected]> (c) 2017-2020
# Website: https://github.com/dr-prodigy/python-holidays
# License: MIT (see LICENSE file)

import os
import sys
import unittest
import warnings
from glob import glob
from itertools import product

from datetime import date, datetime, timedelta
from dateutil.relativedelta import relativedelta, MO
from flake8.api import legacy as flake8

import holidays


class TestAruba(unittest.TestCase):
def setUp(self):
self.holidays = holidays.AW()

def test_2017(self):
self.assertIn(date(2017, 1, 1), self.holidays)
self.assertIn(date(2017, 1, 25), self.holidays)
self.assertIn(date(2017, 3, 18), self.holidays)
self.assertIn(date(2017, 2, 27), self.holidays)
self.assertIn(date(2017, 4, 14), self.holidays)
self.assertIn(date(2017, 4, 17), self.holidays)
self.assertIn(date(2017, 4, 27), self.holidays)
self.assertIn(date(2017, 5, 1), self.holidays)
self.assertIn(date(2017, 5, 25), self.holidays)
self.assertIn(date(2017, 12, 25), self.holidays)
self.assertIn(date(2017, 12, 26), self.holidays)

def test_new_years(self):
self.assertIn(date(2017, 1, 1), self.holidays)

def test_betico_day(self):
self.assertIn(date(2017, 1, 25), self.holidays)

def test_carnaval_monday(self):
self.assertIn(date(2017, 2, 27), self.holidays)

def test_anthem_and_flag_day(self):
self.assertIn(date(2017, 3, 18), self.holidays)

def test_good_friday(self):
self.assertIn(date(2017, 4, 14), self.holidays)

def test_easter_monday(self):
self.assertIn(date(2017, 4, 17), self.holidays)

def test_labour_day(self):
self.assertIn(date(2017, 5, 1), self.holidays)

def test_queens_day_between_1891_and_1948(self):
# Between 1891 and 1948 Queens Day was celebrated on 8-31
self.holidays = holidays.AW(years=[1901])
self.assertIn(date(1901, 8, 31), self.holidays)

def test_queens_day_between_1891_and_1948_substituted_later(self):
# Between 1891 and 1948 Queens Day was celebrated on 9-1
# (one day later) when Queens Day falls on a Sunday
self.holidays = holidays.AW(years=[1947])
self.assertIn(date(1947, 9, 1), self.holidays)

def test_queens_day_between_1949_and_2013(self):
self.holidays = holidays.AW(years=[1965])
self.assertIn(date(1965, 4, 30), self.holidays)

def test_queens_day_between_1949_and_1980_substituted_later(self):
self.holidays = holidays.AW(years=[1967])
self.assertIn(date(1967, 5, 1), self.holidays)

def test_queens_day_between_1980_and_2013_substituted_earlier(self):
self.holidays = holidays.AW(years=[2006])
self.assertIn(date(2006, 4, 29), self.holidays)

def test_kings_day_after_2014(self):
self.holidays = holidays.AW(years=[2013])
self.assertNotIn(date(2013, 4, 27), self.holidays)

self.holidays = holidays.AW(years=[2017])
self.assertIn(date(2017, 4, 27), self.holidays)

def test_kings_day_after_2014_substituted_earlier(self):
self.holidays = holidays.AW(years=[2188])
self.assertIn(date(2188, 4, 26), self.holidays)

def test_ascension_day(self):
self.holidays = holidays.AW(years=2017)
self.assertIn(date(2017, 5, 25), self.holidays)

def test_christmas(self):
self.holidays = holidays.AW(years=2017)
self.assertIn(date(2017, 12, 25), self.holidays)

def test_second_christmas(self):
self.holidays = holidays.AW(years=2017)
self.assertIn(date(2017, 12, 26), self.holidays)
Loading

0 comments on commit 1e32e83

Please sign in to comment.