def test_not_head_parse_coin(self): url = \ "http://www.bcra.gov.ar/Publicaciones\ Estadisticas/Evolucion_moneda.asp" coins = { "bolivar_venezolano": "Bolívar Venezolano" } start_date = datetime(2019, 4, 8) end_date = datetime(2019, 4, 8) coin = 'bolivar_venezolano' content = ''' <table class="table table-BCRA table-bordered table-hover table-responsive" colspan="3"> <tr> <td colspan="3"> <b></b> </td> </tr> <tr> <td width="10%"><b></b> </td> <td width="40%"><b></b></td> <td width="50%"><b></b></td> </tr> </table> ''' scraper = BCRAExchangeRateScraper(url, coins, False) parsed_coin = scraper.parse_coin(content, start_date, end_date, coin) assert parsed_coin == []
def test_parse_coin(self): url = \ "http://www.bcra.gov.ar/Publicaciones\ Estadisticas/Evolucion_moneda.asp" coins = { "bolivar_venezolano": "Bolívar Venezolano" } scraper = BCRAExchangeRateScraper(url, coins, False) start_date = datetime(2019, 4, 8) end_date = datetime(2019, 4, 8) coin = 'bolivar_venezolano' content = ''' <table class="table table-BCRA table-bordered table-hover table-responsive" colspan="3"> <thead> <tr> <td colspan="3"> <b>MERCADO DE CAMBIOS - COTIZACIONES CIERRE VENDEDOR<br> Bolívar Venezolano</b> </td> </tr> <tr> <td width="10%"><b> FECHA</b> </td> <td width="40%"><b> TIPO DE PASE - EN DOLARES - (por unidad)</b></td> <td width="50%"><b> TIPO DE CAMBIO - MONEDA DE CURSO LEGAL - (por unidad)</b></td> </tr> </thead> <tbody><tr> <td width="10%"> 08/04/2019</td> <td width="40%"> 0,0003030</td> <td width="50%"> 0,0132500</td> </tr> </tbody> </table> ''' parsed_coin = scraper.parse_coin(content, start_date, end_date, coin) assert parsed_coin == [ { 'moneda': 'bolivar_venezolano', 'indice_tiempo': '08/04/2019', 'tp_usd': '0,0003030', 'tc_local': '0,0132500' } ]
def test_not_table_parse_coin(self): url = \ "http://www.bcra.gov.ar/Publicaciones\ Estadisticas/Evolucion_moneda.asp" coins = { "bolivar_venezolano": "Bolívar Venezolano" } start_date = datetime(2019, 4, 8) end_date = datetime(2019, 4, 8) coin = 'bolivar_venezolano' content = '' scraper = BCRAExchangeRateScraper(url, coins, False) parsed_coin = scraper.parse_coin(content, start_date, end_date, coin) assert parsed_coin == []