1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974
|
from unittest.mock import patch
from datetime import date
import time
from . import GenericCalendarTest
from ..asia import (
HongKong, HongKongBank,
Japan, JapanBank, Qatar, Singapore,
SouthKorea, Taiwan, Malaysia, China, Israel, Philippines, Kazakhstan
)
from ..asia.china import holidays as china_holidays
from ..exceptions import CalendarError
class ChinaTest(GenericCalendarTest):
cal_class = China
def test_year_2018(self):
holidays = self.cal.holidays_set(2018)
self.assertIn(date(2018, 1, 1), holidays) # New year
self.assertIn(date(2018, 2, 15), holidays) # Spring Festival
self.assertIn(date(2018, 2, 21), holidays) # Spring Festival
self.assertIn(date(2018, 10, 1), holidays) # National Day
self.assertIn(date(2018, 10, 7), holidays) # National Day
# Variable days
self.assertIn(date(2018, 4, 5), holidays) # Ching Ming Festival
self.assertIn(date(2018, 4, 7), holidays) # Ching Ming Festival
self.assertIn(date(2018, 4, 29), holidays) # Labour Day Holiday
self.assertIn(date(2018, 5, 1), holidays) # Labour Day Holiday
self.assertIn(date(2018, 6, 18), holidays) # Dragon Boat Festival
self.assertIn(date(2018, 9, 24), holidays) # Mid-Autumn Festival
self.assertIn(date(2018, 12, 30), holidays) # New year
self.assertIn(date(2018, 12, 31), holidays) # New year
def test_year_2019(self):
holidays = self.cal.holidays_set(2019)
self.assertNotIn(date(2019, 4, 28), holidays) # Labour Day Shift
self.assertIn(date(2019, 5, 1), holidays) # Labour Day Holiday
self.assertIn(date(2019, 5, 2), holidays) # Labour Day Holiday
self.assertIn(date(2019, 5, 3), holidays) # Labour Day Holiday
self.assertNotIn(date(2019, 5, 5), holidays) # Labour Day Shift
def test_year_2020(self):
holidays = self.cal.holidays_set(2020)
self.assertIn(date(2020, 1, 1), holidays) # New Year
self.assertIn(date(2020, 1, 25), holidays) # Spring Festival
self.assertIn(date(2020, 4, 4), holidays) # Ching Ming Festival
self.assertIn(date(2020, 4, 6), holidays) # Ching Ming Festival
self.assertIn(date(2020, 5, 1), holidays) # Labour Day Holiday
self.assertIn(date(2020, 5, 5), holidays) # Labour Day Holiday
self.assertIn(date(2020, 6, 25), holidays) # Dragon Boat Festival
self.assertIn(date(2020, 6, 27), holidays) # Dragon Boat Festival
self.assertIn(date(2020, 10, 1), holidays) # National Day
self.assertIn(date(2020, 10, 8), holidays) # National Day
self.assertNotIn(date(2020, 1, 19), holidays) # Spring Festival Shift
self.assertNotIn(date(2020, 2, 1), holidays) # Spring Festival Shift
self.assertNotIn(date(2020, 4, 26), holidays) # Labour Day Shift
self.assertNotIn(date(2020, 5, 9), holidays) # Labour Day Shift
self.assertNotIn(date(2020, 6, 28), holidays) # Dragon Boat Shift
self.assertNotIn(date(2020, 9, 27), holidays) # National Day Shift
self.assertNotIn(date(2020, 10, 10), holidays) # National Day Shift
def test_year_2021(self):
holidays = self.cal.holidays_set(2021)
self.assertIn(date(2021, 1, 1), holidays) # New Year
self.assertIn(date(2021, 2, 11), holidays) # Spring Festival
self.assertIn(date(2021, 2, 17), holidays) # Spring Festival
self.assertIn(date(2021, 4, 3), holidays) # Ching Ming Festival
self.assertIn(date(2021, 4, 5), holidays) # Ching Ming Festival
self.assertIn(date(2021, 5, 1), holidays) # Labour Day Holiday
self.assertIn(date(2021, 5, 5), holidays) # Labour Day Holiday
self.assertIn(date(2021, 6, 12), holidays) # Dragon Boat Festival
self.assertIn(date(2021, 6, 14), holidays) # Dragon Boat Festival
self.assertIn(date(2021, 9, 19), holidays) # Mid-Autumn Festival
self.assertIn(date(2021, 9, 21), holidays) # Mid-Autumn Festival
self.assertIn(date(2021, 10, 1), holidays) # National Day
self.assertIn(date(2021, 10, 7), holidays) # National Day
self.assertNotIn(date(2021, 2, 7), holidays) # Spring Festival Shift
self.assertNotIn(date(2021, 2, 20), holidays) # Spring Festival Shift
self.assertNotIn(date(2021, 4, 25), holidays) # Labour Day Shift
self.assertNotIn(date(2021, 5, 8), holidays) # Labour Day Shift
self.assertNotIn(date(2021, 9, 18), holidays) # Mid-Autumn Shift
self.assertNotIn(date(2021, 9, 26), holidays) # National Day Shift
self.assertNotIn(date(2021, 10, 9), holidays) # National Day Shift
def test_year_2022(self):
holidays = self.cal.holidays_set(2022)
self.assertIn(date(2022, 1, 1), holidays) # New Year
self.assertIn(date(2022, 1, 3), holidays) # New Year
self.assertIn(date(2022, 1, 31), holidays) # Spring Festival
self.assertIn(date(2022, 2, 6), holidays) # Spring Festival
self.assertIn(date(2022, 4, 3), holidays) # Ching Ming Festival
self.assertIn(date(2022, 4, 5), holidays) # Ching Ming Festival
self.assertIn(date(2022, 4, 30), holidays) # Labour Day Holiday
self.assertIn(date(2022, 5, 4), holidays) # Labour Day Holiday
self.assertIn(date(2022, 6, 3), holidays) # Dragon Boat Festival
self.assertIn(date(2022, 6, 5), holidays) # Dragon Boat Festival
self.assertIn(date(2022, 9, 10), holidays) # Mid-Autumn Festival
self.assertIn(date(2022, 9, 12), holidays) # Mid-Autumn Festival
self.assertIn(date(2022, 10, 1), holidays) # National Day
self.assertIn(date(2022, 10, 7), holidays) # National Day
self.assertNotIn(date(2022, 1, 29), holidays) # Spring Festival Shift
self.assertNotIn(date(2022, 1, 30), holidays) # Spring Festival Shift
# Ching Ming Festival Shift
self.assertNotIn(date(2022, 4, 2), holidays)
self.assertNotIn(date(2022, 4, 24), holidays) # Labour Day Shift
self.assertNotIn(date(2022, 5, 7), holidays) # Labour Day Shift
self.assertNotIn(date(2022, 10, 8), holidays) # National Day Shift
self.assertNotIn(date(2022, 10, 9), holidays) # National Day Shift
def test_year_2023(self):
holidays = self.cal.holidays_set(2023)
self.assertIn(date(2023, 1, 2), holidays) # New Year
self.assertIn(date(2023, 1, 21), holidays) # Spring Festival
self.assertIn(date(2023, 1, 27), holidays) # Spring Festival
self.assertIn(date(2023, 4, 5), holidays) # Ching Ming Festival
self.assertIn(date(2023, 4, 29), holidays) # Labour Day Holiday
self.assertIn(date(2023, 5, 3), holidays) # Labour Day Holiday
self.assertIn(date(2023, 6, 22), holidays) # Dragon Boat Festival
self.assertIn(date(2023, 6, 24), holidays) # Dragon Boat Festival
self.assertIn(date(2023, 9, 29), holidays) # Mid-Autumn Festival
self.assertIn(date(2023, 9, 30), holidays) # National Day
self.assertIn(date(2023, 10, 6), holidays) # National Day
self.assertNotIn(date(2023, 1, 28), holidays) # Spring Festival Shift
self.assertNotIn(date(2023, 1, 29), holidays) # Spring Festival Shift
self.assertNotIn(date(2023, 4, 23), holidays) # Labour Day Shift
self.assertNotIn(date(2023, 5, 6), holidays) # Labour Day Shift
self.assertNotIn(date(2023, 10, 7), holidays) # National Day Shift
self.assertNotIn(date(2023, 10, 8), holidays) # National Day Shift
def test_missing_holiday_year(self):
save_2018 = china_holidays[2018]
del china_holidays[2018]
with self.assertRaises(CalendarError):
self.cal.holidays_set(2018)
china_holidays[2018] = save_2018
def test_warning(self):
year = date.today().year
with patch('warnings.warn') as patched:
self.cal.get_calendar_holidays(year)
patched.assert_called_with(
'Support years 2018-2023 currently, need update every year.'
)
def test_is_working_day(self):
# It's a SAT, but it's a working day this year
self.assertTrue(self.cal.is_working_day(date(2019, 2, 2)))
# It's a SUN, but it's a working day this year
self.assertTrue(self.cal.is_working_day(date(2019, 2, 3)))
def test_add_working_days(self):
# Normally, February 1st + 1 working day would be on February 4th
# Because 2nd and 3rd are on SAT and SUN.
self.assertEqual(
self.cal.add_working_days(date(2019, 2, 1), 1),
date(2019, 2, 2)
)
def test_sub_working_days(self):
# Normally, February 4th - 1 working day would be on February 1st
# Because 2nd and 3rd are on SAT and SUN.
self.assertEqual(
self.cal.sub_working_days(date(2019, 2, 4), 1),
date(2019, 2, 3)
)
class HongKongTest(GenericCalendarTest):
cal_class = HongKong
def test_year_2010(self):
# Interesting because Christmas fell on a Saturday and CNY fell
# on a Sunday, so didn't roll, and Ching Ming was on the same day
# as Easter Monday
# https://www.gov.hk/en/about/abouthk/holiday/2010.htm
holidays = self.cal.holidays_set(2010)
self.assertIn(date(2010, 1, 1), holidays) # New Year
self.assertIn(date(2010, 2, 13), holidays) # Chinese new year (shift)
self.assertIn(date(2010, 2, 15), holidays) # Chinese new year
self.assertIn(date(2010, 2, 16), holidays) # Chinese new year
self.assertNotIn(date(2010, 2, 17), holidays) # Not Chinese new year
self.assertIn(date(2010, 4, 2), holidays) # Good Friday
self.assertIn(date(2010, 4, 3), holidays) # Day after Good Friday
self.assertIn(date(2010, 4, 5), holidays) # Easter Monday
self.assertIn(date(2010, 4, 6), holidays) # Ching Ming (shifted)
self.assertIn(date(2010, 5, 1), holidays) # Labour Day
self.assertIn(date(2010, 5, 21), holidays) # Buddha's Birthday
self.assertIn(date(2010, 6, 16), holidays) # Tuen Ng Festival
self.assertIn(date(2010, 7, 1), holidays) # HK SAR Establishment Day
self.assertIn(date(2010, 9, 23), holidays) # Day after Mid-Autumn
self.assertIn(date(2010, 10, 1), holidays) # National Day
self.assertIn(date(2010, 10, 16), holidays) # Chung Yeung Festival
self.assertIn(date(2010, 12, 25), holidays) # Christmas Day
self.assertIn(date(2010, 12, 27), holidays) # Boxing Day (shifted)
def test_year_2013(self):
# https://www.gov.hk/en/about/abouthk/holiday/2013.htm
holidays = self.cal.holidays_set(2013)
self.assertIn(date(2013, 1, 1), holidays) # New Year
self.assertIn(date(2013, 2, 11), holidays) # Chinese new year
self.assertIn(date(2013, 2, 12), holidays) # Chinese new year
self.assertIn(date(2013, 2, 13), holidays) # Chinese new year
self.assertIn(date(2013, 3, 29), holidays) # Good Friday
self.assertIn(date(2013, 3, 30), holidays) # Day after Good Friday
self.assertIn(date(2013, 4, 1), holidays) # Easter Monday
self.assertIn(date(2013, 4, 4), holidays) # Ching Ming
self.assertIn(date(2013, 5, 1), holidays) # Labour Day
self.assertIn(date(2013, 5, 17), holidays) # Buddha's Birthday
self.assertIn(date(2013, 6, 12), holidays) # Tuen Ng Festival
self.assertIn(date(2013, 7, 1), holidays) # HK SAR Establishment Day
self.assertIn(date(2013, 9, 20), holidays) # Day after Mid-Autumn
self.assertIn(date(2013, 10, 1), holidays) # National Day
self.assertIn(date(2013, 10, 14), holidays) # Chung Yeung Festival
self.assertIn(date(2013, 12, 25), holidays) # Christmas Day
self.assertIn(date(2013, 12, 26), holidays) # Boxing Day
def test_year_2016(self):
# https://www.gov.hk/en/about/abouthk/holiday/2016.htm
holidays = self.cal.holidays_set(2016)
self.assertIn(date(2016, 1, 1), holidays) # New Year
self.assertIn(date(2016, 2, 8), holidays) # Chinese new year
self.assertIn(date(2016, 2, 9), holidays) # Chinese new year
self.assertIn(date(2016, 2, 10), holidays) # Chinese new year
self.assertIn(date(2016, 3, 25), holidays) # Good Friday
self.assertIn(date(2016, 3, 26), holidays) # Day after Good Friday
self.assertIn(date(2016, 3, 28), holidays) # Easter Monday
self.assertIn(date(2016, 4, 4), holidays) # Ching Ming
self.assertIn(date(2016, 5, 1), holidays) # Labour Day (SUN)
self.assertIn(date(2016, 5, 2), holidays) # Labour Day (shifted)
self.assertIn(date(2016, 5, 14), holidays) # Buddha's Birthday
self.assertIn(date(2016, 6, 9), holidays) # Tuen Ng Festival
self.assertIn(date(2016, 7, 1), holidays) # HK SAR Establishment Day
self.assertIn(date(2016, 9, 16), holidays) # Day after Mid-Autumn
self.assertIn(date(2016, 10, 1), holidays) # National Day
self.assertIn(date(2016, 10, 10), holidays) # Chung Yeung Festival
self.assertIn(date(2016, 12, 25), holidays) # Christmas Day
self.assertIn(date(2016, 12, 26), holidays) # Christmas + Boxing Day
self.assertIn(date(2016, 12, 27), holidays) # Second weekday
def test_year_2017(self):
# https://www.gov.hk/en/about/abouthk/holiday/2017.htm
holidays = self.cal.holidays_set(2017)
self.assertIn(date(2017, 1, 2), holidays) # New Year (shifted)
self.assertIn(date(2017, 1, 28), holidays) # Chinese new year
self.assertIn(date(2017, 1, 30), holidays) # Chinese new year
self.assertIn(date(2017, 1, 31), holidays) # Chinese new year
self.assertIn(date(2017, 4, 4), holidays) # Ching Ming
self.assertIn(date(2017, 4, 14), holidays) # Good Friday
self.assertIn(date(2017, 4, 15), holidays) # Day after Good Friday
self.assertIn(date(2017, 4, 17), holidays) # Easter Monday
self.assertIn(date(2017, 5, 1), holidays) # Labour Day
self.assertIn(date(2017, 5, 3), holidays) # Buddha's Birthday
self.assertIn(date(2017, 5, 30), holidays) # Tuen Ng Festival
self.assertIn(date(2017, 7, 1), holidays) # HK SAR Establishment Day
self.assertIn(date(2017, 10, 2), holidays) # National Day (shifted)
self.assertIn(date(2017, 10, 5), holidays) # Day after Mid-Autumn
self.assertIn(date(2017, 10, 28), holidays) # Chung Yeung Festival
self.assertIn(date(2017, 12, 25), holidays) # Christmas Day
self.assertIn(date(2017, 12, 26), holidays) # Boxing Day
def test_chingming_festival(self):
# This is the same as the Taiwan test, just different spelling
# Could move this into a Core test
self.assertIn(date(2005, 4, 5), self.cal.holidays_set(2005))
self.assertIn(date(2006, 4, 5), self.cal.holidays_set(2006))
self.assertIn(date(2007, 4, 5), self.cal.holidays_set(2007))
self.assertIn(date(2008, 4, 4), self.cal.holidays_set(2008))
self.assertIn(date(2010, 4, 5), self.cal.holidays_set(2010))
self.assertIn(date(2011, 4, 5), self.cal.holidays_set(2011))
self.assertIn(date(2012, 4, 4), self.cal.holidays_set(2012))
self.assertIn(date(2013, 4, 4), self.cal.holidays_set(2013))
self.assertIn(date(2014, 4, 5), self.cal.holidays_set(2014))
self.assertIn(date(2015, 4, 4), self.cal.holidays_set(2015))
self.assertIn(date(2016, 4, 4), self.cal.holidays_set(2016))
self.assertIn(date(2017, 4, 4), self.cal.holidays_set(2017))
self.assertIn(date(2018, 4, 5), self.cal.holidays_set(2018))
def test_holidays_2020(self):
# https://www.gov.hk/en/about/abouthk/holiday/2020.htm
holidays = self.cal.holidays_set(2020)
self.assertIn(date(2020, 1, 1), holidays) # New Year
self.assertIn(date(2020, 1, 25), holidays) # Chinese new year
self.assertIn(date(2020, 1, 27), holidays) # Chinese new year
self.assertIn(date(2020, 1, 28), holidays) # Chinese new year
self.assertIn(date(2020, 4, 4), holidays) # Ching Ming
self.assertIn(date(2020, 4, 10), holidays) # Good Friday
self.assertIn(date(2020, 4, 11), holidays) # Day after Good Friday
self.assertIn(date(2020, 4, 13), holidays) # Easter Monday
self.assertIn(date(2020, 4, 30), holidays) # Buddha's Birthday
self.assertIn(date(2020, 5, 1), holidays) # Labour Day
self.assertIn(date(2020, 6, 25), holidays) # Tuen Ng Festival
self.assertIn(date(2020, 7, 1), holidays) # HK SAR Establishment Day
self.assertIn(date(2020, 10, 1), holidays) # National Day
self.assertIn(date(2020, 10, 2), holidays) # Day after Mid-Autumn
self.assertIn(date(2020, 10, 26), holidays) # Chung Yeung Festival
self.assertIn(date(2020, 12, 25), holidays) # Christmas Day
self.assertIn(date(2020, 12, 26), holidays) # Boxing Day
# Special: Boxing day is not shifted, because it's not a SUN
self.assertNotIn(date(2020, 12, 28), holidays)
def test_holidays_2021(self):
# https://www.gov.hk/en/about/abouthk/holiday/2021.htm
holidays = self.cal.holidays_set(2021)
self.assertIn(date(2021, 1, 1), holidays) # New Year
self.assertIn(date(2021, 2, 12), holidays) # Chinese new year
self.assertIn(date(2021, 2, 13), holidays) # Chinese new year
self.assertIn(date(2021, 2, 14), holidays) # Chinese new year (SUN)
self.assertIn(date(2021, 2, 15), holidays) # Chinese new year
self.assertIn(date(2021, 4, 2), holidays) # Good Friday
self.assertIn(date(2021, 4, 3), holidays) # Day after Good Friday
self.assertIn(date(2021, 4, 4), holidays) # Ching Ming
self.assertIn(date(2021, 4, 5), holidays) # Ching Ming shift+Easter
self.assertIn(date(2021, 4, 6), holidays) # Day after Easter Monday
self.assertIn(date(2021, 5, 1), holidays) # Labour Day
self.assertIn(date(2021, 5, 19), holidays) # Buddha's Birthday
self.assertIn(date(2021, 6, 14), holidays) # Tuen Ng Festival
self.assertIn(date(2021, 7, 1), holidays) # HK SAR Establishment Day
self.assertIn(date(2021, 9, 22), holidays) # Day after Mid-Autumn
self.assertIn(date(2021, 10, 1), holidays) # National Day
self.assertIn(date(2021, 10, 14), holidays) # Chung Yeung Festival
self.assertIn(date(2021, 12, 25), holidays) # Christmas Day
self.assertIn(date(2021, 12, 27), holidays) # First weekday after Xmas
def test_are_saturdays_working_days(self):
# Let's start with february 6th.
start = date(2020, 2, 6)
# If SAT was a non-working day, it would have been the 13th.
self.assertEqual(
self.cal.add_working_days(start, 5),
date(2020, 2, 12)
)
def test_no_duplicate_days(self):
holidays = self.cal.holidays(2021)
labels = [day[1] for day in holidays]
labels_dedup = list(set(labels))
assert sorted(labels) == sorted(labels_dedup)
class HongKongBankTest(HongKongTest):
cal_class = HongKongBank
def test_are_saturdays_working_days(self):
# Let's start with february 6th.
start = date(2020, 2, 6)
# If SAT and SUN are non-working days
self.assertEqual(
self.cal.add_working_days(start, 5),
date(2020, 2, 13)
)
class JapanTest(GenericCalendarTest):
cal_class = Japan
def test_year_2013(self):
holidays = self.cal.holidays_set(2013)
self.assertIn(date(2013, 1, 1), holidays) # new year
self.assertIn(date(2013, 2, 11), holidays) # Foundation Day
self.assertIn(date(2013, 3, 20), holidays) # Vernal Equinox Day
self.assertIn(date(2013, 4, 29), holidays) # Showa Day
self.assertIn(date(2013, 5, 3), holidays) # Constitution Memorial Day
self.assertIn(date(2013, 5, 4), holidays) # Greenery Day
self.assertIn(date(2013, 5, 5), holidays) # Children's Day
self.assertIn(date(2013, 9, 23), holidays) # Autumnal Equinox Day
self.assertIn(date(2013, 11, 3), holidays) # Culture Day
self.assertIn(date(2013, 11, 23), holidays) # Labour Thanksgiving Day
self.assertIn(date(2013, 12, 23), holidays) # The Emperor's Birthday
# Variable days
self.assertIn(date(2013, 1, 14), holidays) # Coming of Age Day
self.assertIn(date(2013, 7, 15), holidays) # Marine Day
self.assertIn(date(2013, 9, 16), holidays) # Respect-for-the-Aged Day
self.assertIn(date(2013, 10, 14), holidays) # Health and Sports Day
def test_year_2016(self):
# Before 2016, no Mountain Day
holidays = self.cal.holidays_set(2014)
self.assertNotIn(date(2014, 8, 11), holidays) # Mountain Day
holidays = self.cal.holidays_set(2015)
self.assertNotIn(date(2015, 8, 11), holidays) # Mountain Day
# After 2016, yes
holidays = self.cal.holidays_set(2016)
self.assertIn(date(2016, 8, 11), holidays) # Mountain Day
holidays = self.cal.holidays_set(2017)
self.assertIn(date(2017, 8, 11), holidays) # Mountain Day
def test_year_2019(self):
holidays = self.cal.holidays_set(2019)
self.assertIn(date(2019, 1, 14), holidays) # Coming of Age Day
self.assertIn(date(2019, 5, 1), holidays) # Coronation Day
self.assertIn(date(2019, 5, 6), holidays) # Children's Day
self.assertIn(date(2019, 8, 12), holidays) # Mountain Day Observed
self.assertIn(date(2019, 11, 4), holidays) # Culture Day Observed
# retrieve the sports day label
holidays = self.cal.holidays(2019)
holidays_dict = dict(holidays)
self.assertEqual(
holidays_dict[date(2019, 10, 14)], "Health and Sports Day")
def test_year_2020(self):
holidays = self.cal.holidays_set(2020)
self.assertIn(date(2020, 7, 23), holidays) # Marine Day
self.assertIn(date(2020, 7, 24), holidays) # Sports Day
self.assertIn(date(2020, 8, 10), holidays) # Mountain Day adjustment
self.assertNotIn(date(2020, 8, 11), holidays) # Mountain Day
self.assertNotIn(date(2020, 12, 31), holidays) # New Year's Bank Day
# retrieve the sports day label
holidays = self.cal.holidays(2020)
holidays_dict = dict(holidays)
self.assertEqual(holidays_dict[date(2020, 7, 24)], "Sports Day")
def test_year_2021(self):
holidays = self.cal.holidays_set(2021)
self.assertIn(date(2021, 7, 22), holidays) # Marine Day
self.assertIn(date(2021, 7, 23), holidays) # Sports Day
self.assertIn(date(2021, 8, 8), holidays) # Mountain Day
self.assertIn(date(2021, 8, 9), holidays) # Mountain Day Observed
self.assertNotIn(date(2021, 7, 19), holidays) # Marine Day
self.assertNotIn(date(2021, 8, 11), holidays) # Mountain Day
self.assertNotIn(date(2021, 10, 11), holidays) # Sports Day
# retrieve the sports day label
holidays = self.cal.holidays(2021)
holidays_dict = dict(holidays)
self.assertEqual(holidays_dict[date(2021, 7, 23)], "Sports Day")
class JapanBankTest(GenericCalendarTest):
cal_class = JapanBank
def test_year_2019(self):
holidays = self.cal.holidays_set(2019)
self.assertIn(date(2019, 1, 2), holidays) # New Year's Bank Day
self.assertIn(date(2019, 1, 3), holidays) # New Year's Bank Day
self.assertIn(date(2019, 1, 14), holidays) # Coming of Age Day
self.assertIn(date(2019, 5, 3), holidays) # Constitution Memorial Day
self.assertIn(date(2019, 11, 4), holidays) # Culture Day Observed
self.assertIn(date(2019, 12, 31), holidays) # New Year's Bank Day
def test_year_2020(self):
holidays = self.cal.holidays_set(2020)
self.assertIn(date(2020, 1, 2), holidays) # New Year's Bank Day
self.assertIn(date(2020, 1, 3), holidays) # New Year's Bank Day
self.assertIn(date(2020, 12, 31), holidays) # New Year's Bank Day
self.assertIn(date(2020, 8, 10), holidays) # Mountain Day adjustment
self.assertNotIn(date(2020, 8, 11), holidays) # Mountain Day
self.assertIn(date(2020, 7, 23), holidays) # Marine Day
self.assertIn(date(2020, 7, 24), holidays) # Sports Day
class MalaysiaTest(GenericCalendarTest):
cal_class = Malaysia
def test_year_2013(self):
holidays = self.cal.holidays_set(2013)
self.assertIn(date(2013, 1, 1), holidays) # New Year's Day
self.assertIn(date(2013, 1, 28), holidays) # Thaipusam
self.assertIn(date(2013, 2, 1), holidays) # Federal Territory Day
self.assertIn(date(2013, 2, 11), holidays) # 2nd day of Lunar NY
self.assertIn(date(2013, 2, 12), holidays) # 1st day (Sun lieu)
self.assertIn(date(2013, 5, 1), holidays) # Workers' Day
self.assertIn(date(2013, 5, 24), holidays) # Vesak Day
self.assertIn(date(2013, 8, 8), holidays) # 1st day eid-al-fitr
self.assertIn(date(2013, 8, 9), holidays) # 2nd day eid-al-fitr
self.assertIn(date(2013, 8, 31), holidays) # National Day
self.assertIn(date(2013, 9, 16), holidays) # Malaysia Day
self.assertIn(date(2013, 10, 15), holidays) # Hari Raya Haji
self.assertIn(date(2013, 11, 2), holidays) # Deepavali
self.assertIn(date(2013, 11, 5), holidays) # Islamic New Year
self.assertIn(date(2013, 12, 25), holidays) # Xmas
def test_year_2012(self):
holidays = self.cal.holidays_set(2012)
self.assertIn(date(2012, 1, 1), holidays) # New Year's Day
self.assertIn(date(2012, 1, 24), holidays) # Federal Territory Day
self.assertIn(date(2012, 2, 1), holidays) # 2nd day of Lunar NY
self.assertIn(date(2012, 5, 1), holidays) # 1st day (Sun lieu)
self.assertIn(date(2012, 5, 5), holidays) # Workers' Day
self.assertIn(date(2012, 8, 19), holidays) # 1st day eid-al-fitr
self.assertIn(date(2012, 8, 20), holidays) # 2nd day eid-al-fitr
self.assertIn(date(2012, 8, 31), holidays) # National Day
self.assertIn(date(2012, 9, 16), holidays) # Malaysia Day
self.assertIn(date(2012, 10, 26), holidays) # Hari Raya Haji
self.assertIn(date(2012, 11, 13), holidays) # Islamic New Year
self.assertIn(date(2012, 11, 15), holidays) # Deepavali
self.assertIn(date(2012, 12, 25), holidays) # Xmas
def test_nuzul_al_quran(self):
holidays = self.cal.holidays_set(2017)
self.assertIn(date(2017, 6, 12), holidays)
holidays = self.cal.holidays_set(2018)
self.assertIn(date(2018, 6, 1), holidays)
def test_fix_deepavali_2018(self):
holidays = self.cal.holidays(2018)
holidays = dict(holidays)
deepavali = date(2018, 11, 6)
self.assertIn(deepavali, holidays)
self.assertEqual(holidays[deepavali], "Deepavali")
def test_msia_thaipusam(self):
# we only have them for years 2010-2024
self.assertEqual(set(self.cal.MSIA_THAIPUSAM), set(range(2010, 2025)))
def test_missing_deepavali(self):
save_2020 = self.cal.MSIA_DEEPAVALI[2020]
del self.cal.MSIA_DEEPAVALI[2020]
with self.assertRaises(KeyError):
self.cal.holidays(2020)
# Back to normal, to avoid breaking further tests
self.cal.MSIA_DEEPAVALI[2020] = save_2020
def test_missing_thaipusam(self):
save_2020 = self.cal.MSIA_THAIPUSAM[2020]
del self.cal.MSIA_THAIPUSAM[2020]
with self.assertRaises(KeyError):
self.cal.holidays(2020)
# Back to normal, to avoid breaking further tests
self.cal.MSIA_THAIPUSAM[2020] = save_2020
def test_labour_day_label(self):
holidays = self.cal.holidays(2020)
holidays = dict(holidays)
self.assertEqual(
holidays[date(2020, 5, 1)], "Workers' Day")
class QatarTest(GenericCalendarTest):
cal_class = Qatar
test_include_january_1st = False
def test_year_2013(self):
holidays = self.cal.holidays_set(2013)
self.assertIn(date(2013, 7, 9), holidays) # start ramadan
# warning, the official date was (2013, 8, 10)
self.assertIn(date(2013, 8, 8), holidays) # eid al fitr
# The official date was (2013, 10, 14)
self.assertIn(date(2013, 10, 15), holidays) # eid al adha
self.assertIn(date(2013, 10, 16), holidays) # eid al adha
self.assertIn(date(2013, 10, 17), holidays) # eid al adha
self.assertIn(date(2013, 10, 18), holidays) # eid al adha
self.assertIn(date(2013, 12, 18), holidays) # National Day
def test_weekend(self):
# In Qatar, Week-end days are Friday / Sunday.
weekend_day = date(2017, 5, 12) # This is a Friday
non_weekend_day = date(2017, 5, 14) # This is a Sunday
self.assertFalse(self.cal.is_working_day(weekend_day))
self.assertTrue(self.cal.is_working_day(non_weekend_day))
class SingaporeTest(GenericCalendarTest):
cal_class = Singapore
def test_CNY_2010(self):
holidays = self.cal.holidays_set(2010)
self.assertIn(date(2010, 2, 14), holidays) # CNY1
self.assertIn(date(2010, 2, 15), holidays) # CNY2
self.assertIn(date(2010, 2, 16), holidays) # Rolled day for CNY
def test_year_2013(self):
holidays = self.cal.holidays_set(2013)
self.assertIn(date(2013, 1, 1), holidays) # New Year
self.assertIn(date(2013, 2, 10), holidays) # CNY1
self.assertIn(date(2013, 2, 11), holidays) # CNY2
self.assertIn(date(2013, 2, 12), holidays) # Rolled day for CNY
self.assertIn(date(2013, 3, 29), holidays) # Good Friday
self.assertIn(date(2013, 5, 1), holidays) # Labour Day
self.assertIn(date(2013, 5, 24), holidays) # Vesak Day
self.assertIn(date(2013, 8, 8), holidays) # Hari Raya Puasa
self.assertIn(date(2013, 8, 9), holidays) # National Day
self.assertIn(date(2013, 10, 15), holidays) # Hari Raya Haji
self.assertIn(date(2013, 11, 3), holidays) # Deepavali
self.assertIn(date(2013, 11, 4), holidays) # Deepavali shift
self.assertIn(date(2013, 12, 25), holidays) # Christmas Day
def test_year_2018(self):
holidays = self.cal.holidays_set(2018)
self.assertIn(date(2018, 1, 1), holidays) # New Year
self.assertIn(date(2018, 2, 16), holidays) # CNY
self.assertIn(date(2018, 2, 17), holidays) # CNY
self.assertIn(date(2018, 3, 30), holidays) # Good Friday
self.assertIn(date(2018, 5, 1), holidays) # Labour Day
self.assertIn(date(2018, 5, 29), holidays) # Vesak Day
self.assertIn(date(2018, 6, 15), holidays) # Hari Raya Puasa
self.assertIn(date(2018, 8, 9), holidays) # National Day
self.assertIn(date(2018, 8, 22), holidays) # Hari Raya Haji
self.assertIn(date(2018, 11, 6), holidays) # Deepavali
self.assertIn(date(2018, 12, 25), holidays) # Christmas Day
def test_fixed_holiday_shift(self):
# Labour Day was on a Sunday in 2016
holidays = self.cal.holidays_set(2016)
# Labour Day (sunday)
self.assertIn(date(2016, 5, 1), holidays)
# Shifted day (Monday)
self.assertIn(date(2016, 5, 2), holidays)
def test_deepavali(self):
# At the moment, we have values for deepavali only until year 2021
for year in range(2000, 2022):
self.assertIn(year, self.cal.DEEPAVALI)
def test_deepavali_current_year(self):
# This is a regression test. We should be able to have the deepavali
# value until this year and probably a few years in the future
current_year = date.today().year
self.assertIn(current_year, self.cal.DEEPAVALI)
def test_deepavali_missing_year(self):
with self.assertRaises(KeyError) as context:
self.cal.holidays_set(1999)
self.assertEqual(
# Equivalent of the error msg
context.exception.args[0],
'Missing date for Singapore Deepavali for year: 1999',
)
class SouthKoreaTest(GenericCalendarTest):
cal_class = SouthKorea
def test_year_2013(self):
holidays = self.cal.holidays_set(2013)
self.assertIn(date(2013, 1, 1), holidays) # new year
self.assertIn(date(2013, 3, 1), holidays) # Independence day
self.assertIn(date(2013, 5, 5), holidays) # children's day
self.assertIn(date(2013, 6, 6), holidays) # Memorial day
self.assertIn(date(2013, 8, 15), holidays) # Liberation day
self.assertIn(date(2013, 10, 3), holidays) # National Foundation Day
self.assertIn(date(2013, 10, 9), holidays) # Hangul Day
self.assertIn(date(2013, 12, 25), holidays) # Christmas
# Variable days
self.assertIn(date(2013, 2, 9), holidays)
self.assertIn(date(2013, 2, 10), holidays)
self.assertIn(date(2013, 2, 11), holidays)
self.assertIn(date(2013, 5, 17), holidays)
self.assertIn(date(2013, 9, 18), holidays)
self.assertIn(date(2013, 9, 19), holidays)
self.assertIn(date(2013, 9, 20), holidays)
class TaiwanTest(GenericCalendarTest):
cal_class = Taiwan
def test_year_2013(self):
holidays = self.cal.holidays_set(2013)
self.assertIn(date(2013, 1, 1), holidays) # New Year
self.assertIn(date(2013, 2, 9), holidays) # Chinese new year's eve
self.assertIn(date(2013, 2, 10), holidays) # Chinese new year
self.assertIn(date(2013, 2, 11), holidays) # Spring Festival
self.assertIn(date(2013, 2, 12), holidays) # Spring Festival
self.assertIn(date(2013, 2, 28), holidays) # 228 Peace Memorial Day
self.assertIn(date(2013, 4, 4), holidays) # Children's Day
self.assertIn(date(2013, 6, 12), holidays) # Dragon Boat Festival
self.assertIn(date(2013, 9, 19), holidays) # Mid-Autumn Festival
self.assertIn(date(2013, 10, 10), holidays) # National Day
def test_qingming_festival(self):
self.assertIn(date(2001, 4, 5), self.cal.holidays_set(2001))
self.assertIn(date(2002, 4, 5), self.cal.holidays_set(2002))
self.assertIn(date(2005, 4, 5), self.cal.holidays_set(2005))
self.assertIn(date(2006, 4, 5), self.cal.holidays_set(2006))
self.assertIn(date(2007, 4, 5), self.cal.holidays_set(2007))
self.assertIn(date(2008, 4, 4), self.cal.holidays_set(2008))
self.assertIn(date(2010, 4, 5), self.cal.holidays_set(2010))
self.assertIn(date(2011, 4, 5), self.cal.holidays_set(2011))
self.assertIn(date(2012, 4, 4), self.cal.holidays_set(2012))
self.assertIn(date(2013, 4, 4), self.cal.holidays_set(2013))
self.assertIn(date(2014, 4, 4), self.cal.holidays_set(2014))
def test_extra_day_2021_february(self):
extra_day_feb_20 = date(2021, 2, 20)
self.assertTrue(self.cal.is_working_day(extra_day_feb_20))
# Compute deltas with the extra-working day...
five_days_after = self.cal.add_working_days(
date(2021, 2, 19), 5
)
# Should've been on 26th, albeit the 20th
self.assertEqual(five_days_after, date(2021, 2, 25))
def test_extra_day_2021_september(self):
extra_day_sept_11 = date(2021, 9, 11)
self.assertTrue(self.cal.is_working_day(extra_day_sept_11))
# Compute deltas with the extra-working day...
five_days_after = self.cal.add_working_days(
date(2021, 9, 10), 5
)
# Should've been on 17th, albeit the 11th
self.assertEqual(five_days_after, date(2021, 9, 16))
class IsraelTest(GenericCalendarTest):
cal_class = Israel
test_include_january_1st = False
def test_holidays_2017(self):
calculated_holidays = self.cal.holidays_set(2017)
known_holidays = {
date(2017, 4, 10), # Passover (Pesach)
date(2017, 4, 11),
date(2017, 4, 16),
date(2017, 4, 17),
date(2017, 5, 1), # Independence Day (Yom Ha-Atzmaut)
date(2017, 5, 2),
date(2017, 9, 20), # Jewish New Year (Rosh Ha-Shana)
date(2017, 9, 21),
date(2017, 9, 22),
date(2017, 9, 29), # Yom Kippur
date(2017, 9, 30),
date(2017, 10, 4), # Sukkot
date(2017, 10, 5),
date(2017, 10, 11),
date(2017, 10, 12),
date(2017, 5, 30), # Shavuot
date(2017, 5, 31),
}
self.assertEqual(calculated_holidays, known_holidays)
def test_holidays_2018(self):
calculated_holidays = self.cal.holidays_set(2018)
known_holidays = {
date(2018, 3, 30), # Passover (Pesach)
date(2018, 3, 31),
date(2018, 4, 5),
date(2018, 4, 6),
date(2018, 4, 18), # Independence Day (Yom Ha-Atzmaut)
date(2018, 4, 19),
date(2018, 9, 9), # Rosh Hashana
date(2018, 9, 10),
date(2018, 9, 11),
date(2018, 9, 18), # Yom Kippur
date(2018, 9, 19),
date(2018, 9, 23), # Sukkot
date(2018, 9, 24),
date(2018, 9, 30),
date(2018, 10, 1),
date(2018, 5, 19), # Shavuot
date(2018, 5, 20),
}
self.assertEqual(calculated_holidays, known_holidays)
def test_holidays_2019(self):
calculated_holidays = self.cal.holidays_set(2019)
known_holidays = {
date(2019, 4, 19), # Passover (Pesach)
date(2019, 4, 20), # Passover (Pesach)
date(2019, 4, 25), # Passover (Pesach)
date(2019, 4, 26), # Passover (Pesach)
date(2019, 5, 8), # Independence Day (Yom Ha-Atzmaut)
date(2019, 5, 9), # Independence Day (Yom Ha-Atzmaut)
date(2019, 6, 8), # Shavuot
date(2019, 6, 9), # Shavuot
date(2019, 9, 29), # Rosh Hashana
date(2019, 9, 30), # Rosh Hashana
date(2019, 10, 1), # Rosh Hashana
date(2019, 10, 8), # Yom Kippur
date(2019, 10, 9), # Yom Kippur
date(2019, 10, 13), # Sukkot
date(2019, 10, 14), # Sukkot
date(2019, 10, 20), # Sukkot
date(2019, 10, 21), # Sukkot
}
self.assertEqual(calculated_holidays, known_holidays)
def test_holidays_2020(self):
calculated_holidays = self.cal.holidays_set(2020)
known_holidays = {
date(2020, 9, 18), # Rosh Hashana Eve
date(2020, 9, 19), # Rosh Hashana A
date(2020, 9, 20), # Rosh Hashana B
date(2020, 9, 27), # Kippur Eve
date(2020, 9, 28), # Kippur
date(2020, 10, 2), # Sukot A Eve
date(2020, 10, 3), # Sukot A
date(2020, 10, 9), # Sukot B Eve
date(2020, 10, 10), # Sukot B
date(2020, 4, 8), # Pesach A Eve
date(2020, 4, 9), # Pesach A
date(2020, 4, 14), # Pesach B Eve
date(2020, 4, 15), # Pesach B
date(2020, 4, 28), # Independence Day Eve
date(2020, 4, 29), # Independence Day
date(2020, 5, 28), # Shavuot Eve
date(2020, 5, 29), # Shavuot
}
self.assertEqual(calculated_holidays, known_holidays)
def test_holidays_2021(self):
calculated_holidays = self.cal.holidays_set(2021)
known_holidays = {
date(2021, 9, 6), # Rosh Hashana Eve
date(2021, 9, 7), # Rosh Hashana A
date(2021, 9, 8), # Rosh Hashana B
date(2021, 9, 15), # Kippur Eve
date(2021, 9, 16), # Kippur
date(2021, 9, 20), # Sukot A Eve
date(2021, 9, 21), # Sukot A
date(2021, 9, 27), # Sukot B Eve
date(2021, 9, 28), # Sukot B
date(2021, 3, 27), # Pesach A Eve
date(2021, 3, 28), # Pesach A
date(2021, 4, 2), # Pesach B Eve
date(2021, 4, 3), # Pesach B
date(2021, 4, 14), # Independence Day Eve
date(2021, 4, 15), # Independence Day
date(2021, 5, 16), # Shavuot Eve
date(2021, 5, 17), # Shavuot
}
self.assertEqual(calculated_holidays, known_holidays)
def test_is_holiday_performance(self):
random_date = date(2019, 10, 9)
japan_cal = Japan()
timer = time.time()
for i in range(30):
japan_cal.is_holiday(random_date)
japan_time = time.time() - timer
timer = time.time()
for i in range(30):
self.cal.is_holiday(random_date)
israel_time = time.time() - timer
self.assertGreater(japan_time * 3, israel_time)
class Philippines(GenericCalendarTest):
cal_class = Philippines
def test_year_2021(self):
holidays = self.cal.holidays_set(2021)
self.assertIn(date(2021, 1, 1), holidays) # New Year
self.assertIn(date(2021, 2, 12), holidays) # Chinese New Year
self.assertIn(date(2021, 2, 25), holidays) # EDSA Revolution
self.assertIn(date(2021, 4, 1), holidays) # Maundy Thursday
self.assertIn(date(2021, 4, 2), holidays) # Good Friday
self.assertIn(date(2021, 4, 3), holidays) # Black Saturday
self.assertIn(date(2021, 4, 4), holidays) # Easter Sunday
self.assertIn(date(2021, 4, 9), holidays) # Araw ng Kagitingan
self.assertIn(date(2021, 5, 1), holidays) # Labor Day
self.assertIn(date(2021, 5, 13), holidays) # Eid'l Fitr
self.assertIn(date(2021, 6, 12), holidays) # Independence Day
self.assertIn(date(2021, 7, 20), holidays) # Eid'l Adha
self.assertIn(date(2021, 8, 21), holidays) # Ninoy Aquino Day
self.assertIn(date(2021, 8, 30), holidays) # National Heroes' Day
self.assertIn(date(2021, 11, 1), holidays) # All Saints' Day
self.assertIn(date(2021, 11, 2), holidays) # All Souls Day
self.assertIn(date(2021, 11, 30), holidays) # Bonifacio Day
self.assertIn(date(2021, 12, 8), holidays) # Immaculate Conception
self.assertIn(date(2021, 12, 24), holidays) # Christmas Eve
self.assertIn(date(2021, 12, 25), holidays) # Christmas Day
self.assertIn(date(2021, 12, 30), holidays) # Rizal Day
self.assertIn(date(2021, 12, 31), holidays) # New Year's Eve
def test_year_2020(self):
holidays = self.cal.holidays_set(2020)
self.assertIn(date(2020, 1, 1), holidays) # New Year
self.assertIn(date(2020, 1, 25), holidays) # Chinese New Year
self.assertIn(date(2020, 2, 25), holidays) # EDSA Revolution
self.assertIn(date(2020, 4, 9), holidays) # Araw ng Kagitingan
self.assertIn(date(2020, 4, 9), holidays) # Maundy Thursday
self.assertIn(date(2020, 4, 10), holidays) # Good Friday
self.assertIn(date(2020, 4, 11), holidays) # Black Saturday
self.assertIn(date(2020, 4, 12), holidays) # Easter Sunday
self.assertIn(date(2020, 5, 1), holidays) # Labor Day
self.assertIn(date(2020, 5, 24), holidays) # Eid'l Fitr
self.assertIn(date(2020, 6, 12), holidays) # Independence Day
self.assertIn(date(2020, 7, 31), holidays) # Eid'l Adha
self.assertIn(date(2020, 8, 21), holidays) # Ninoy Aquino Day
self.assertIn(date(2020, 8, 30), holidays) # National Heroes' Day
self.assertIn(date(2020, 11, 1), holidays) # All Saints' Day
self.assertIn(date(2020, 11, 2), holidays) # All Souls Day
self.assertIn(date(2020, 11, 30), holidays) # Bonifacio Day
self.assertIn(date(2020, 12, 8), holidays) # Immaculate Conception
self.assertIn(date(2020, 12, 24), holidays) # Christmas Eve
self.assertIn(date(2020, 12, 25), holidays) # Christmas Day
self.assertIn(date(2020, 12, 30), holidays) # Rizal Day
self.assertIn(date(2020, 12, 31), holidays) # New Year's Eve
class KazakhstanTest(GenericCalendarTest):
cal_class = Kazakhstan
def test_year_2006(self):
holidays = self.cal.holidays_set(2006)
self.assertIn(date(2006, 1, 1), holidays) # New Year
self.assertIn(date(2006, 1, 2), holidays) # New Year Holiday
self.assertIn(date(2006, 3, 8), holidays) # International Women's Day
self.assertIn(date(2006, 3, 21), holidays) # Nauryz Meyramy
self.assertIn(date(2006, 3, 22), holidays) # Nauryz Meyramy
self.assertIn(date(2006, 3, 23), holidays) # Nauryz Meyramy
self.assertIn(date(2006, 5, 1), holidays) # Unity Day
self.assertIn(date(2006, 5, 9), holidays) # Day of victory
self.assertIn(date(2006, 7, 6), holidays) # Capital City Day
self.assertIn(date(2006, 8, 30), holidays) # Constitution Day
self.assertIn(date(2006, 12, 16), holidays) # Independence Day
self.assertIn(date(2006, 12, 17), holidays) # Independence Day
def test_year_2012(self):
holidays = self.cal.holidays_set(2012)
assert len(holidays) == 14
self.assertIn(date(2012, 1, 1), holidays) # New Year
self.assertIn(date(2012, 1, 2), holidays) # New Year Holiday
self.assertIn(date(2012, 1, 7), holidays) # Orthodox Christmas
self.assertIn(date(2012, 3, 8), holidays) # International Women's Day
self.assertIn(date(2012, 3, 21), holidays) # Nauryz Meyramy
self.assertIn(date(2012, 3, 22), holidays) # Nauryz Meyramy
self.assertIn(date(2012, 3, 23), holidays) # Nauryz Meyramy
self.assertIn(date(2012, 5, 1), holidays) # Unity Day
self.assertIn(date(2012, 5, 9), holidays) # Day of victory
self.assertIn(date(2012, 7, 6), holidays) # Capital City Day
self.assertIn(date(2012, 8, 30), holidays) # Constitution Day
self.assertIn(date(2012, 10, 26), holidays) # Kurban Ait (Eid al-Adha)
self.assertIn(date(2012, 12, 16), holidays) # Independence Day
self.assertIn(date(2012, 12, 17), holidays) # Independence Day
def test_year_2016(self):
holidays = self.cal.holidays_set(2016)
assert len(holidays) == 16
self.assertIn(date(2016, 1, 1), holidays) # New Year
self.assertIn(date(2016, 1, 2), holidays) # New Year Holiday
self.assertIn(date(2016, 1, 7), holidays) # Orthodox Christmas
self.assertIn(date(2016, 3, 8), holidays) # International Women's Day
self.assertIn(date(2016, 3, 21), holidays) # Nauryz Meyramy
self.assertIn(date(2016, 3, 22), holidays) # Nauryz Meyramy
self.assertIn(date(2016, 3, 23), holidays) # Nauryz Meyramy
self.assertIn(date(2016, 5, 1), holidays) # Unity Day
self.assertIn(date(2016, 5, 7), holidays) # Defender of the Fatherland
self.assertIn(date(2016, 5, 9), holidays) # Day of victory
self.assertIn(date(2016, 7, 6), holidays) # Capital City Day
self.assertIn(date(2016, 8, 30), holidays) # Constitution Day
self.assertIn(date(2016, 9, 13), holidays) # Kurban Ait (Eid al-Adha)
self.assertIn(date(2016, 12, 1), holidays) # First President Day
self.assertIn(date(2016, 12, 16), holidays) # Independence Day
self.assertIn(date(2016, 12, 17), holidays) # Independence Day
def test_year_2020(self):
holidays = self.cal.holidays_set(2020)
assert len(holidays) == 16
self.assertIn(date(2020, 1, 1), holidays) # New Year
self.assertIn(date(2020, 1, 2), holidays) # New Year Holiday
self.assertIn(date(2020, 1, 7), holidays) # Orthodox Christmas
self.assertIn(date(2020, 3, 8), holidays) # International Women's Day
self.assertIn(date(2020, 3, 21), holidays) # Nauryz Meyramy
self.assertIn(date(2020, 3, 22), holidays) # Nauryz Meyramy
self.assertIn(date(2020, 3, 23), holidays) # Nauryz Meyramy
self.assertIn(date(2020, 5, 1), holidays) # Unity Day
self.assertIn(date(2020, 5, 7), holidays) # Defender of the Fatherland
self.assertIn(date(2020, 5, 9), holidays) # Day of victory
self.assertIn(date(2020, 7, 6), holidays) # Capital City Day
self.assertIn(date(2020, 7, 31), holidays) # Kurban Ait (Eid al-Adha)
self.assertIn(date(2020, 8, 30), holidays) # Constitution Day
self.assertIn(date(2020, 12, 1), holidays) # First President Day
self.assertIn(date(2020, 12, 16), holidays) # Independence Day
self.assertIn(date(2020, 12, 17), holidays) # Independence Day
|