Repository: leogregianin/stock-exchange-holidays (language: python)

Issue:
Create tests



Discussion / hints:

Fix patch:
diff --git a/README.md b/README.md
index 7843d6b..c373cf6 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,13 @@ $ source .venv/bin/activate
     
 without dependencies
 
+
+### Install development dependencies
+    
+```sh
+$ pip install -r requirements-dev.txt
+```
+
 ## Using
 
 ### New York Stock Exchange (NYSE)
diff --git a/requirements-dev.txt b/requirements-dev.txt
new file mode 100644
index 0000000..7d64b92
--- /dev/null
+++ b/requirements-dev.txt
@@ -0,0 +1,2 @@
+coverage==6.1.2
+flake8==4.0.1
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..952a6be
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,3 @@
+[flake8]
+max-line-length = 160
+exclude = .git,__pycache__


Test patch:
diff --git a/test_holidays.py b/test_holidays.py
new file mode 100644
index 0000000..c7e557f
--- /dev/null
+++ b/test_holidays.py
@@ -0,0 +1,94 @@
+from datetime import date
+from unittest import TestCase
+
+from stock_exchange_holidays import Holidays, NYSE, CME, B3
+
+
+class TestNYSE(TestCase):
+
+    def setUp(self):
+        self.holidays = Holidays(exchange=NYSE())
+        self.nyse_holidays = self.holidays.get_holidays()
+
+    def test_nyse_first_day_year_is_holiday(self):
+        first_day = date(2020, 1, 1)
+        self.assertTrue(holiday for holiday in self.nyse_holidays if holiday == first_day)
+
+    def test_nyse_random_date_is_not_holiday(self):
+        january_random_day = date(2020, 1, 10)
+        self.assertFalse(january_random_day in self.nyse_holidays)
+
+    def test_nyse_holidays_2020(self):
+        year = 2020
+        holidays_by_year = self.holidays.get_holidays_by_year(year)
+        self.assertEqual(len(holidays_by_year), 9)
+
+    def test_nyse_holidays_2021(self):
+        year = 2021
+        holidays_by_year = self.holidays.get_holidays_by_year(year)
+        self.assertEqual(len(holidays_by_year), 9)
+
+    def test_nyse_holidays_2022(self):
+        year = 2022
+        holidays_by_year = self.holidays.get_holidays_by_year(year)
+        self.assertEqual(len(holidays_by_year), 9)
+
+    def test_nyse_holidays_2023(self):
+        year = 2023
+        holidays_by_year = self.holidays.get_holidays_by_year(year)
+        self.assertEqual(len(holidays_by_year), 9)
+
+
+class TestCME(TestCase):
+
+    def setUp(self):
+        self.holidays = Holidays(exchange=CME())
+        self.cme_holidays = self.holidays.get_holidays()
+
+    def test_cme_first_day_year_is_holiday(self):
+        first_day = date(2020, 1, 1)
+        self.assertTrue(holiday for holiday in self.cme_holidays if holiday == first_day)
+
+    def test_cme_random_date_is_not_holiday(self):
+        january_random_day = date(2020, 1, 10)
+        self.assertFalse(january_random_day in self.cme_holidays)
+
+    def test_cme_holidays_2020(self):
+        year = 2020
+        holidays_by_year = self.holidays.get_holidays_by_year(year)
+        self.assertEqual(len(holidays_by_year), 9)
+
+    def test_cme_holidays_2021(self):
+        year = 2021
+        holidays_by_year = self.holidays.get_holidays_by_year(year)
+        self.assertEqual(len(holidays_by_year), 9)
+
+
+class TestB3(TestCase):
+
+    def setUp(self):
+        self.holidays = Holidays(exchange=B3())
+        self.b3_holidays = self.holidays.get_holidays()
+
+    def test_b3_first_day_year_is_holiday(self):
+        first_day = date(2020, 1, 1)
+        self.assertTrue(holiday for holiday in self.b3_holidays if holiday == first_day)
+
+    def test_b3_random_date_is_not_holiday(self):
+        january_random_day = date(2020, 1, 10)
+        self.assertFalse(january_random_day in self.b3_holidays)
+
+    def test_b3_holidays_2020(self):
+        year = 2020
+        holidays_by_year = self.holidays.get_holidays_by_year(year)
+        self.assertEqual(len(holidays_by_year), 14)
+
+    def test_b3_holidays_2021(self):
+        year = 2021
+        holidays_by_year = self.holidays.get_holidays_by_year(year)
+        self.assertEqual(len(holidays_by_year), 15)
+
+    def test_b3_holidays_2022(self):
+        year = 2022
+        holidays_by_year = self.holidays.get_holidays_by_year(year)
+        self.assertEqual(len(holidays_by_year), 13)