def test_html_is_not_valid(self):
        """Probar que el html no sea valido"""
        url = ""

        rates = {}

        with patch.object(BCRALiborScraper,
                          'fetch_day_content',
                          return_value='''
                <table class="table table-BCRA table-bordered table-hover
                    table-responsive">
                    <thead></thead>
                </table>
            '''):
            scraper = BCRALiborScraper(url,
                                       rates,
                                       intermediate_panel_path=None,
                                       use_intermediate_panel=False)
            content_date = date.today()
            content = scraper.fetch_day_content(content_date)

            soup = BeautifulSoup(content, "html.parser")

            table = soup.find('table')
            head = table.find('thead') if table else None
            body = table.find('tbody') if table else None

            assert table is not None
            assert head is not None
            assert body is None
    def test_html_is_valid(self):
        """Probar que el html sea valido"""
        url = ""
        single_date = date(2019, 3, 4)

        rates = {}
        with patch.object(BCRALiborScraper,
                          'fetch_day_content',
                          return_value='''
                <table class="table table-BCRA table-bordered table-hover
                    table-responsive">
                <thead></thead>
                <tbody></tbody>
                </table>
            '''):
            scraper = BCRALiborScraper(url, rates, False)
            content = scraper.fetch_day_content(single_date)

            soup = BeautifulSoup(content, "html.parser")

            table = soup.find('table')
            head = table.find('thead') if table else None
            body = table.find('tbody') if table else None

            assert table is not None
            assert head is not None
            assert body is not None
    def test_fetch_day_content_invalid_url_patching_driver(self):
        """Probar fetch day content con url invalida"""
        single_date = date(2019, 3, 4)
        rates = {}
        url = ''

        mocked_driver = MagicMock()
        mocked_driver.page_source = 400

        with patch.object(BCRALiborScraper,
                          'get_browser_driver',
                          return_value=mocked_driver):
            scraper = BCRALiborScraper(url, rates, False)
            content = scraper.fetch_day_content(single_date)
            assert content == 400
    def test_fetch_day_content_patching_driver(self):
        """Probar fetch day content"""
        single_date = date(2019, 3, 4)
        rates = {}
        url = ''

        mocked_driver = MagicMock()
        mocked_driver.page_source = "foo"
        mocked_driver.status_code = 200

        with patch.object(BCRALiborScraper,
                          'get_browser_driver',
                          return_value=mocked_driver):
            scraper = BCRALiborScraper(url,
                                       rates,
                                       intermediate_panel_path=None,
                                       use_intermediate_panel=False)
            content = scraper.fetch_day_content(single_date)
            assert content['content'] == "foo"