Exemple #1
0
    def __set_available_period(self) -> None:
        """
        Attribute setter method for available period.

        :return: None
        """
        links_of_monthly_economy_watcher = scraper.get_watcher_directory(TOP_MENU_PAGE)
        logger.debug('links_of_monthly_economy_watcher: {}'.format(links_of_monthly_economy_watcher))
        publish_date_list = [
            scraper.get_publish_date_from_url(link_) for link_ in links_of_monthly_economy_watcher
        ]
        logger.debug('publish_date_list: {}'.format(publish_date_list))

        self.__AVAILABLE_PERIOD = pd.Series(
            [self.__set_datetime_month_to_one(month) - pd.offsets.MonthBegin(1) for month in publish_date_list]
        )
        logger.debug('AVAILABLE_PERIOD: {}'.format(self.__AVAILABLE_PERIOD.tolist()))

        self.__map_month_to_url = {
            month: url for month, url in zip(self.__AVAILABLE_PERIOD, links_of_monthly_economy_watcher)
        }
        logger.debug('map_month_to_url: {}'.format(self.__map_month_to_url))

        self.__LATEST_MONTH = max(self.__AVAILABLE_PERIOD)
        self.__EARLIEST_MONTH = min(self.__AVAILABLE_PERIOD)
        logger.debug('LATEST_MONTH: {0}, EARLIEST_MONTH: {1}'.format(
            *[self.__LATEST_MONTH, self.__EARLIEST_MONTH])
        )
 def setUpClass(cls):
     cls.links_ = get_watcher_directory(TOP_MENU_PAGE)
     cls.watcher_type = WatcherType.Current
     cls.data = get_watcher_file(cls.links_[0], cls.watcher_type.file_name)
    def test_get_watcher_file(self):
        links_ = get_watcher_directory(TOP_MENU_PAGE)

        data = get_watcher_file(links_[0], WatcherType.Current.file_name)

        self.assertTrue(data.size > 0)
 def test_get_publish_date_from_url(self):
     links_ = get_watcher_directory(TOP_MENU_PAGE)
     self.assertIsNotNone(get_publish_date_from_url(links_[0]))
 def test_get_watcher_directory(self):
     links_ = get_watcher_directory(TOP_MENU_PAGE)
     for link_ in links_:
         self.assertTrue('watcher' in link_)
         self.assertFalse('menu' in link_)
         self.assertTrue(len(re.findall('\d{4}', link_)))