diff --git a/cep/exc.py b/cep/exc.py new file mode 100644 index 0000000..5e0ec9c --- /dev/null +++ b/cep/exc.py @@ -0,0 +1,12 @@ +class CepError(Exception): + """ + Error interno del sitio web + https://www.banxico.org.mx/cep/ + """ + + +class MaxRequestError(CepError): + """ + Máximo número de peticiones alcanzadas para + obtener el CEP de una transferencia + """ diff --git a/cep/transferencia.py b/cep/transferencia.py index cd3f469..c3861e4 100644 --- a/cep/transferencia.py +++ b/cep/transferencia.py @@ -4,9 +4,16 @@ import clabe from lxml import etree +from requests import HTTPError from .client import Client from .cuenta import Cuenta +from .exc import CepError, MaxRequestError + +MAX_REQUEST_ERROR_MESSAGE = ( + b'Lo sentimos, pero ha excedido el número máximo ' + b'de consultas en este portal' +) @dataclass @@ -36,7 +43,15 @@ def validar( ) if not client: return None - xml = cls._descargar(client, 'XML') + + try: + xml = cls._descargar(client, 'XML') + except HTTPError as exc: + raise CepError from exc + + if MAX_REQUEST_ERROR_MESSAGE in xml: + raise MaxRequestError + resp = etree.fromstring(xml) ordenante = Cuenta.from_etree(resp.find('Ordenante')) diff --git a/cep/version.py b/cep/version.py index 4c9f88d..7fd229a 100644 --- a/cep/version.py +++ b/cep/version.py @@ -1 +1 @@ -__version__ = '0.2.0.dev0' +__version__ = '0.2.0' diff --git a/tests/cassettes/test_lanza_cep_error_para_errores_500.yaml b/tests/cassettes/test_lanza_cep_error_para_errores_500.yaml new file mode 100644 index 0000000..1bdb0fd --- /dev/null +++ b/tests/cassettes/test_lanza_cep_error_para_errores_500.yaml @@ -0,0 +1,957 @@ +interactions: +- request: + body: tipoCriterio=T&receptorParticipante=0&captcha=c&tipoConsulta=1&fecha=19-04-2022&criterio=CUENCA927820173168&emisor=90646&receptor=40012&cuenta=012180000&monto=0.01 + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '172' + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, + like Gecko) Chrome/75.0.3770.142 Safari/537.36 + method: POST + uri: http://www.banxico.org.mx/cep/valida.do + response: + body: + string: '' + headers: + Connection: + - Keep-Alive + Content-Length: + - '0' + Date: + - Tue, 19 Apr 2022 21:17:33 GMT + Location: + - https://www.banxico.org.mx/cep/valida.do + Server: + - mxbanxico + status: + code: 307 + message: Temporary Redirect +- request: + body: tipoCriterio=T&receptorParticipante=0&captcha=c&tipoConsulta=1&fecha=19-04-2022&criterio=CUENCA927820173168&emisor=90646&receptor=40012&cuenta=012180000&monto=0.01 + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '172' + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, + like Gecko) Chrome/75.0.3770.142 Safari/537.36 + method: POST + uri: https://www.banxico.org.mx/cep/valida.do + response: + body: + string: "\n
\n \n Descargar CEP\n
\n
\n

Gracias por utilizar el servicio de descarga de CEP

\n \ + \ \n
Haga clic sobre el ícono para descargar\ + \ el CEP.

\n PDF\n \ + \ \n XML\n \n ZIP\n \ + \ \n\ + \
\n \n
" + headers: + Content-Language: + - es-MX + Content-Length: + - '1508' + Content-Type: + - text/html; charset=UTF-8 + Date: + - Tue, 19 Apr 2022 21:17:33 GMT + Set-Cookie: + - JSESSIONID=1G5DsA6ahFd1UC5mAuAy5nvswFkESdViA2Hcrc60dYV4KVrVfMCg!-925117081; + path=/; HttpOnly + - Hex39714011=!XDMo5QGyDyZpdp/405nf5XFqnQVk9KwS8yY7WPed/zLu2Wwr5IeAD+S8vbEgNrw7Ky11yEH5aue97w==; + expires=Wed, 20-Apr-2022 05:17:33 GMT; path=/; Httponly + - TS012f422b=01ab44a5a8c1463f9b654cc73ef0f6ed1ac425b7f4434e066301bf0492232d383785d62bdce6ba100abd34d3d7cf572491cdf095ffbc40e566ea0b849490fcb1081ba2f49682e7492d773d2dbe08cff7da112e7941; + Path=/ + - TS604574e3027=083fd6a492ab2000bb1dba1f4977d98aa99121c20723547f3783d3af067a318d5cd6ed4028a216b30832d42404113000c449a6520c0afb6f59336ab545ab3dc5c66e9d5107b5cbe6133be97c41e2e063c8084bac9926e256ed173090f2c0ae37;Path=/ + X-OPNET-Transaction-Trace: + - a2_8f0ff089-81df-4c26-879c-67799b97e560 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Cookie: + - Hex39714011=!XDMo5QGyDyZpdp/405nf5XFqnQVk9KwS8yY7WPed/zLu2Wwr5IeAD+S8vbEgNrw7Ky11yEH5aue97w==; + JSESSIONID=1G5DsA6ahFd1UC5mAuAy5nvswFkESdViA2Hcrc60dYV4KVrVfMCg!-925117081; + TS012f422b=01ab44a5a8c1463f9b654cc73ef0f6ed1ac425b7f4434e066301bf0492232d383785d62bdce6ba100abd34d3d7cf572491cdf095ffbc40e566ea0b849490fcb1081ba2f49682e7492d773d2dbe08cff7da112e7941; + TS604574e3027=083fd6a492ab2000bb1dba1f4977d98aa99121c20723547f3783d3af067a318d5cd6ed4028a216b30832d42404113000c449a6520c0afb6f59336ab545ab3dc5c66e9d5107b5cbe6133be97c41e2e063c8084bac9926e256ed173090f2c0ae37 + User-Agent: + - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, + like Gecko) Chrome/75.0.3770.142 Safari/537.36 + method: GET + uri: http://www.banxico.org.mx/cep/descarga.do?formato=XML + response: + body: + string: '' + headers: + Connection: + - Keep-Alive + Content-Length: + - '0' + Date: + - Tue, 19 Apr 2022 21:17:33 GMT + Location: + - https://www.banxico.org.mx/cep/descarga.do?formato=XML + Server: + - mxbanxico + status: + code: 307 + message: Temporary Redirect +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Cookie: + - Hex39714011=!XDMo5QGyDyZpdp/405nf5XFqnQVk9KwS8yY7WPed/zLu2Wwr5IeAD+S8vbEgNrw7Ky11yEH5aue97w==; + JSESSIONID=1G5DsA6ahFd1UC5mAuAy5nvswFkESdViA2Hcrc60dYV4KVrVfMCg!-925117081; + TS012f422b=01ab44a5a8c1463f9b654cc73ef0f6ed1ac425b7f4434e066301bf0492232d383785d62bdce6ba100abd34d3d7cf572491cdf095ffbc40e566ea0b849490fcb1081ba2f49682e7492d773d2dbe08cff7da112e7941; + TS604574e3027=083fd6a492ab2000bb1dba1f4977d98aa99121c20723547f3783d3af067a318d5cd6ed4028a216b30832d42404113000c449a6520c0afb6f59336ab545ab3dc5c66e9d5107b5cbe6133be97c41e2e063c8084bac9926e256ed173090f2c0ae37 + User-Agent: + - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, + like Gecko) Chrome/75.0.3770.142 Safari/537.36 + method: GET + uri: https://www.banxico.org.mx/cep/descarga.do?formato=XML + response: + body: + string: "\r\n\r\n \r\n \r\n" + headers: + Content-Disposition: + - attachment; filename=CEP-20220419-CUENCA927820173168.xml + Content-Language: + - es-MX + Content-Length: + - '1518' + Content-Type: + - application/xml + Date: + - Tue, 19 Apr 2022 21:17:33 GMT + Set-Cookie: + - SRVCOOKIE=!VVIUoqxVRxBsdLj405nf5XFqnQVk9J2P8Ks6kYkcZqUnS5zVXklbFoa4LtxcZpbwF/7AXczjcKcTtA==; + expires=Wed, 20-Apr-2022 05:17:33 GMT; path=/; Httponly + - TS012f422b=01ab44a5a841f0054e28429863661d49f17ab3e4a9434e066301bf0492232d383785d62bdce6ba100abd34d3d7cf572491cdf095ffbc40e566ea0b849490fcb1081ba2f49669054e2e292ef104af8a17bb8e02735a22069690f0c6a234f7132736fef970c7; + Path=/ + - TS604574e3027=083fd6a492ab2000d38e3db03f3fc7d97b1e425fdca4bef490422c5446ceeb66453e656a1403836108069edf9c1130008ab0d2e58d12926a59336ab545ab3dc5c66e9d5107b5cbe6133be97c41e2e063c8084bac9926e256ed173090f2c0ae37;Path=/ + X-OPNET-Transaction-Trace: + - a2_87d8f560-7cb1-4c4f-b101-1e69a25fc3e0 + status: + code: 200 + message: OK +- request: + body: tipoCriterio=T&receptorParticipante=0&captcha=c&tipoConsulta=1&fecha=19-04-2022&criterio=CUENCA927820173168&emisor=90646&receptor=40012&cuenta=012180000&monto=0.01 + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '172' + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, + like Gecko) Chrome/75.0.3770.142 Safari/537.36 + method: POST + uri: http://www.banxico.org.mx/cep/valida.do + response: + body: + string: '' + headers: + Connection: + - Keep-Alive + Content-Length: + - '0' + Date: + - Tue, 19 Apr 2022 21:17:33 GMT + Location: + - https://www.banxico.org.mx/cep/valida.do + Server: + - mxbanxico + status: + code: 307 + message: Temporary Redirect +- request: + body: tipoCriterio=T&receptorParticipante=0&captcha=c&tipoConsulta=1&fecha=19-04-2022&criterio=CUENCA927820173168&emisor=90646&receptor=40012&cuenta=012180000&monto=0.01 + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '172' + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, + like Gecko) Chrome/75.0.3770.142 Safari/537.36 + method: POST + uri: https://www.banxico.org.mx/cep/valida.do + response: + body: + string: "\n
\n \n Descargar CEP\n
\n
\n

Gracias por utilizar el servicio de descarga de CEP

\n \ + \ \n
Haga clic sobre el ícono para descargar\ + \ el CEP.

\n PDF\n \ + \ \n XML\n \n ZIP\n \ + \ \n\ + \
\n \n
" + headers: + Content-Language: + - es-MX + Content-Length: + - '1508' + Content-Type: + - text/html; charset=UTF-8 + Date: + - Tue, 19 Apr 2022 21:17:33 GMT + Set-Cookie: + - JSESSIONID=catDsBFZ52duAHAYiYdBo1NqRrYqypCoStzuNSrL4kMAbZc7UZG3!1328161135; + path=/; HttpOnly + - Hex39714011=!S3wuppfBD4tGvr7405nf5XFqnQVk9GCX3sNE+ZI7eB8OtA3Gy/pDdSTeklh/lrMnco0+Ey5g9/e9cg==; + expires=Wed, 20-Apr-2022 05:17:33 GMT; path=/; Httponly + - TS012f422b=01ab44a5a8f5a3458839ac8b43134b1d1491e42baa0b69f10dae8f798f719549f3029617d4a01e02c5abde01d0bd219058cb763b5b4c3390c6f18b4690d929e06e4613523bd07d610ab696f74effc4dd899e88b5b0; + Path=/ + - TS604574e3027=083fd6a492ab20002df6578d648526f81fc70fafcc948446c765b821be219e877d669201731a15b608f63a29461130006604b9662bb05a2359336ab545ab3dc5e2049986411023a499691be3d933a98fec31c6ad2b7b6ba1f4a74207db7138ab;Path=/ + X-OPNET-Transaction-Trace: + - a2_fd82705b-b27e-4e74-8cde-4c9b4e39b190 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Cookie: + - Hex39714011=!S3wuppfBD4tGvr7405nf5XFqnQVk9GCX3sNE+ZI7eB8OtA3Gy/pDdSTeklh/lrMnco0+Ey5g9/e9cg==; + JSESSIONID=catDsBFZ52duAHAYiYdBo1NqRrYqypCoStzuNSrL4kMAbZc7UZG3!1328161135; + TS012f422b=01ab44a5a8f5a3458839ac8b43134b1d1491e42baa0b69f10dae8f798f719549f3029617d4a01e02c5abde01d0bd219058cb763b5b4c3390c6f18b4690d929e06e4613523bd07d610ab696f74effc4dd899e88b5b0; + TS604574e3027=083fd6a492ab20002df6578d648526f81fc70fafcc948446c765b821be219e877d669201731a15b608f63a29461130006604b9662bb05a2359336ab545ab3dc5e2049986411023a499691be3d933a98fec31c6ad2b7b6ba1f4a74207db7138ab + User-Agent: + - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, + like Gecko) Chrome/75.0.3770.142 Safari/537.36 + method: GET + uri: http://www.banxico.org.mx/cep/descarga.do?formato=XML + response: + body: + string: '' + headers: + Connection: + - Keep-Alive + Content-Length: + - '0' + Date: + - Tue, 19 Apr 2022 21:17:33 GMT + Location: + - https://www.banxico.org.mx/cep/descarga.do?formato=XML + Server: + - mxbanxico + status: + code: 307 + message: Temporary Redirect +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Cookie: + - Hex39714011=!S3wuppfBD4tGvr7405nf5XFqnQVk9GCX3sNE+ZI7eB8OtA3Gy/pDdSTeklh/lrMnco0+Ey5g9/e9cg==; + JSESSIONID=catDsBFZ52duAHAYiYdBo1NqRrYqypCoStzuNSrL4kMAbZc7UZG3!1328161135; + TS012f422b=01ab44a5a8f5a3458839ac8b43134b1d1491e42baa0b69f10dae8f798f719549f3029617d4a01e02c5abde01d0bd219058cb763b5b4c3390c6f18b4690d929e06e4613523bd07d610ab696f74effc4dd899e88b5b0; + TS604574e3027=083fd6a492ab20002df6578d648526f81fc70fafcc948446c765b821be219e877d669201731a15b608f63a29461130006604b9662bb05a2359336ab545ab3dc5e2049986411023a499691be3d933a98fec31c6ad2b7b6ba1f4a74207db7138ab + User-Agent: + - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, + like Gecko) Chrome/75.0.3770.142 Safari/537.36 + method: GET + uri: https://www.banxico.org.mx/cep/descarga.do?formato=XML + response: + body: + string: "\r\n\r\n \r\n \r\n" + headers: + Content-Disposition: + - attachment; filename=CEP-20220419-CUENCA927820173168.xml + Content-Language: + - es-MX + Content-Length: + - '1518' + Content-Type: + - application/xml + Date: + - Tue, 19 Apr 2022 21:17:33 GMT + Set-Cookie: + - SRVCOOKIE=!MaB87yn4CzLvWL7405nf5XFqnQVk9O3MD/sC1NQaOUQhCMv1UDdb6MfmUkemtxTDPPmUJiF4oPBipw==; + expires=Wed, 20-Apr-2022 05:17:34 GMT; path=/; Httponly + - TS012f422b=01ab44a5a8c5ac966d57921cc47d0139a87baeb7750b69f10dae8f798f719549f3029617d4a01e02c5abde01d0bd219058cb763b5b4c3390c6f18b4690d929e06e4613523b18fd67131486dac15f7130b6363c10c07395525639ec7098d309d9a8c044525b; + Path=/ + - TS604574e3027=083fd6a492ab20009685fb225f1209e88d25ed96753593df9134877df4c512022b9c267bb2c1539708590a67db1130006ed069ab4f97ed7dbc9f25aed5cb36bb8ed2c4ab54328b5bd63458aa2c543c37525254b7cf5b0ee8d21438c2178fec39;Path=/ + X-OPNET-Transaction-Trace: + - a2_e7cc9f41-e743-41e7-bc14-eaa7c8956011 + status: + code: 200 + message: OK +- request: + body: tipoCriterio=T&receptorParticipante=0&captcha=c&tipoConsulta=1&fecha=19-04-2022&criterio=CUENCA927820173168&emisor=90646&receptor=40012&cuenta=012180000&monto=0.01 + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '172' + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, + like Gecko) Chrome/75.0.3770.142 Safari/537.36 + method: POST + uri: http://www.banxico.org.mx/cep/valida.do + response: + body: + string: '' + headers: + Connection: + - Keep-Alive + Content-Length: + - '0' + Date: + - Tue, 19 Apr 2022 21:17:34 GMT + Location: + - https://www.banxico.org.mx/cep/valida.do + Server: + - mxbanxico + status: + code: 307 + message: Temporary Redirect +- request: + body: tipoCriterio=T&receptorParticipante=0&captcha=c&tipoConsulta=1&fecha=19-04-2022&criterio=CUENCA927820173168&emisor=90646&receptor=40012&cuenta=012180000&monto=0.01 + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '172' + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, + like Gecko) Chrome/75.0.3770.142 Safari/537.36 + method: POST + uri: https://www.banxico.org.mx/cep/valida.do + response: + body: + string: "\n
\n \n Descargar CEP\n
\n
\n

Gracias por utilizar el servicio de descarga de CEP

\n \ + \ \n
Haga clic sobre el ícono para descargar\ + \ el CEP.

\n PDF\n \ + \ \n XML\n \n ZIP\n \ + \ \n\ + \
\n \n
" + headers: + Content-Language: + - es-MX + Content-Length: + - '1508' + Content-Type: + - text/html; charset=UTF-8 + Date: + - Tue, 19 Apr 2022 21:17:34 GMT + Set-Cookie: + - JSESSIONID=WQ1DsBQpVdaJJUlejDhV_OlQdZJS00q62fWfoQlvQYNIXH51wwT-!-925117081; + path=/; HttpOnly + - Hex39714011=!9x2+wB6gV5H2yz3405nf5XFqnQVk9H0aj0Q5d53ZiQL0Jwk5mQyEG+/2e3X4WrBAa2IZl+6QyEy2YQ==; + expires=Wed, 20-Apr-2022 05:17:34 GMT; path=/; Httponly + - TS012f422b=01ab44a5a8adf55cf695abb15df24940950e3a3196557f85ab6bdc687787d8decf1ea938c57a28310cc5a9a4142f48c9d0d9802ddd905ee76662c0fbeed95614f1a2e9569148414e482520c672e82abf680412fba5; + Path=/ + - TS604574e3027=083fd6a492ab20000d514a7de097dd6482481e265af14a8adb5ce1f37a3189551a65b66823f1706208176641f5113000e808b63ed0ecf707bc9f25aed5cb36bb4963bae285a327a750b482e497ab61fde5da1740ef1de2b96504551f3d14036f;Path=/ + X-OPNET-Transaction-Trace: + - a2_ea95cf85-be25-4f7b-81d6-185190e74e67 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Cookie: + - Hex39714011=!9x2+wB6gV5H2yz3405nf5XFqnQVk9H0aj0Q5d53ZiQL0Jwk5mQyEG+/2e3X4WrBAa2IZl+6QyEy2YQ==; + JSESSIONID=WQ1DsBQpVdaJJUlejDhV_OlQdZJS00q62fWfoQlvQYNIXH51wwT-!-925117081; + TS012f422b=01ab44a5a8adf55cf695abb15df24940950e3a3196557f85ab6bdc687787d8decf1ea938c57a28310cc5a9a4142f48c9d0d9802ddd905ee76662c0fbeed95614f1a2e9569148414e482520c672e82abf680412fba5; + TS604574e3027=083fd6a492ab20000d514a7de097dd6482481e265af14a8adb5ce1f37a3189551a65b66823f1706208176641f5113000e808b63ed0ecf707bc9f25aed5cb36bb4963bae285a327a750b482e497ab61fde5da1740ef1de2b96504551f3d14036f + User-Agent: + - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, + like Gecko) Chrome/75.0.3770.142 Safari/537.36 + method: GET + uri: http://www.banxico.org.mx/cep/descarga.do?formato=XML + response: + body: + string: '' + headers: + Connection: + - Keep-Alive + Content-Length: + - '0' + Date: + - Tue, 19 Apr 2022 21:17:34 GMT + Location: + - https://www.banxico.org.mx/cep/descarga.do?formato=XML + Server: + - mxbanxico + status: + code: 307 + message: Temporary Redirect +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Cookie: + - Hex39714011=!9x2+wB6gV5H2yz3405nf5XFqnQVk9H0aj0Q5d53ZiQL0Jwk5mQyEG+/2e3X4WrBAa2IZl+6QyEy2YQ==; + JSESSIONID=WQ1DsBQpVdaJJUlejDhV_OlQdZJS00q62fWfoQlvQYNIXH51wwT-!-925117081; + TS012f422b=01ab44a5a8adf55cf695abb15df24940950e3a3196557f85ab6bdc687787d8decf1ea938c57a28310cc5a9a4142f48c9d0d9802ddd905ee76662c0fbeed95614f1a2e9569148414e482520c672e82abf680412fba5; + TS604574e3027=083fd6a492ab20000d514a7de097dd6482481e265af14a8adb5ce1f37a3189551a65b66823f1706208176641f5113000e808b63ed0ecf707bc9f25aed5cb36bb4963bae285a327a750b482e497ab61fde5da1740ef1de2b96504551f3d14036f + User-Agent: + - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, + like Gecko) Chrome/75.0.3770.142 Safari/537.36 + method: GET + uri: https://www.banxico.org.mx/cep/descarga.do?formato=XML + response: + body: + string: "\r\n\r\n \r\n \r\n" + headers: + Content-Disposition: + - attachment; filename=CEP-20220419-CUENCA927820173168.xml + Content-Language: + - es-MX + Content-Length: + - '1518' + Content-Type: + - application/xml + Date: + - Tue, 19 Apr 2022 21:17:34 GMT + Set-Cookie: + - SRVCOOKIE=!UHWmUYhtXDkOh/H405nf5XFqnQVk9AEgE5f0EBjboRcGUmwnbXSMaC4hs565fxLSgaJe7lJ9z9ebNQ==; + expires=Wed, 20-Apr-2022 05:17:34 GMT; path=/; Httponly + - TS012f422b=01ab44a5a8c07e987bee4aea49f0d65678010cf344557f85ab6bdc687787d8decf1ea938c57a28310cc5a9a4142f48c9d0d9802ddd905ee76662c0fbeed95614f1a2e95691c9ea201d84651bc66d59dc3bbaec7f5cc1f1e1acf6bf8fb40fc83c2d8bc6825b; + Path=/ + - TS604574e3027=083fd6a492ab2000103118daf8629fbb3e6a8507f1f2e2e56df274142dcfebb33da7feda825721090885d2e37a1130005db9305877503503bc9f25aed5cb36bb4963bae285a327a750b482e497ab61fde5da1740ef1de2b96504551f3d14036f;Path=/ + X-OPNET-Transaction-Trace: + - a2_ab599ec7-66e9-4e38-85d4-bcf9b3f78530 + status: + code: 200 + message: OK +- request: + body: tipoCriterio=T&receptorParticipante=0&captcha=c&tipoConsulta=1&fecha=19-04-2022&criterio=CUENCA927820173168&emisor=90646&receptor=40012&cuenta=012180000&monto=0.01 + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '172' + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, + like Gecko) Chrome/75.0.3770.142 Safari/537.36 + method: POST + uri: http://www.banxico.org.mx/cep/valida.do + response: + body: + string: '' + headers: + Connection: + - Keep-Alive + Content-Length: + - '0' + Date: + - Tue, 19 Apr 2022 21:17:35 GMT + Location: + - https://www.banxico.org.mx/cep/valida.do + Server: + - mxbanxico + status: + code: 307 + message: Temporary Redirect +- request: + body: tipoCriterio=T&receptorParticipante=0&captcha=c&tipoConsulta=1&fecha=19-04-2022&criterio=CUENCA927820173168&emisor=90646&receptor=40012&cuenta=012180000&monto=0.01 + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '172' + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, + like Gecko) Chrome/75.0.3770.142 Safari/537.36 + method: POST + uri: https://www.banxico.org.mx/cep/valida.do + response: + body: + string: "\n
\n \n Descargar CEP\n
\n
\n

Gracias por utilizar el servicio de descarga de CEP

\n \ + \ \n
Haga clic sobre el ícono para descargar\ + \ el CEP.

\n PDF\n \ + \ \n XML\n \n ZIP\n \ + \ \n\ + \
\n \n
" + headers: + Content-Language: + - es-MX + Content-Length: + - '1508' + Content-Type: + - text/html; charset=UTF-8 + Date: + - Tue, 19 Apr 2022 21:17:35 GMT + Set-Cookie: + - JSESSIONID=0VxDsBbGtov5K-KYDfsF5S5BYqRcqBqdnF5DIIDysn8mwwY2vnCo!-925117081; + path=/; HttpOnly + - Hex39714011=!R9ewz7+1bjGTdM3405nf5XFqnQVk9JBwN3OYvfE31Q6CX9pkYmnslA6ajhfZcrrNty+4McUEj7UEag==; + expires=Wed, 20-Apr-2022 05:17:35 GMT; path=/; Httponly + - TS012f422b=01ab44a5a8e655d58263c2a87f12478ec3afaa59a65378fc9bd26fa1222168c17902059100cb52f99d24783cf2a17d512b924678c2dd39b3a53bf06040dbee5dbc85b9927c9e602324431bbaf4af7ecf2d2be4971c; + Path=/ + - TS604574e3027=083fd6a492ab2000e573c3a1c967f070b646785030835e1c4575a12b8c9e8ecacfba9fdfb824151d08c393b4da113000df7470a0d99e22fefa06384a1a645ec5b52d5293e7d8b40476ed2aa6ad6aac21e3de074e780c99c7ff41c9ed2dc06321;Path=/ + X-OPNET-Transaction-Trace: + - a2_713656a3-9a6f-4389-96b4-3cd6a26615f9 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Cookie: + - Hex39714011=!R9ewz7+1bjGTdM3405nf5XFqnQVk9JBwN3OYvfE31Q6CX9pkYmnslA6ajhfZcrrNty+4McUEj7UEag==; + JSESSIONID=0VxDsBbGtov5K-KYDfsF5S5BYqRcqBqdnF5DIIDysn8mwwY2vnCo!-925117081; + TS012f422b=01ab44a5a8e655d58263c2a87f12478ec3afaa59a65378fc9bd26fa1222168c17902059100cb52f99d24783cf2a17d512b924678c2dd39b3a53bf06040dbee5dbc85b9927c9e602324431bbaf4af7ecf2d2be4971c; + TS604574e3027=083fd6a492ab2000e573c3a1c967f070b646785030835e1c4575a12b8c9e8ecacfba9fdfb824151d08c393b4da113000df7470a0d99e22fefa06384a1a645ec5b52d5293e7d8b40476ed2aa6ad6aac21e3de074e780c99c7ff41c9ed2dc06321 + User-Agent: + - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, + like Gecko) Chrome/75.0.3770.142 Safari/537.36 + method: GET + uri: http://www.banxico.org.mx/cep/descarga.do?formato=XML + response: + body: + string: '' + headers: + Connection: + - Keep-Alive + Content-Length: + - '0' + Date: + - Tue, 19 Apr 2022 21:17:35 GMT + Location: + - https://www.banxico.org.mx/cep/descarga.do?formato=XML + Server: + - mxbanxico + status: + code: 307 + message: Temporary Redirect +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Cookie: + - Hex39714011=!R9ewz7+1bjGTdM3405nf5XFqnQVk9JBwN3OYvfE31Q6CX9pkYmnslA6ajhfZcrrNty+4McUEj7UEag==; + JSESSIONID=0VxDsBbGtov5K-KYDfsF5S5BYqRcqBqdnF5DIIDysn8mwwY2vnCo!-925117081; + TS012f422b=01ab44a5a8e655d58263c2a87f12478ec3afaa59a65378fc9bd26fa1222168c17902059100cb52f99d24783cf2a17d512b924678c2dd39b3a53bf06040dbee5dbc85b9927c9e602324431bbaf4af7ecf2d2be4971c; + TS604574e3027=083fd6a492ab2000e573c3a1c967f070b646785030835e1c4575a12b8c9e8ecacfba9fdfb824151d08c393b4da113000df7470a0d99e22fefa06384a1a645ec5b52d5293e7d8b40476ed2aa6ad6aac21e3de074e780c99c7ff41c9ed2dc06321 + User-Agent: + - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, + like Gecko) Chrome/75.0.3770.142 Safari/537.36 + method: GET + uri: https://www.banxico.org.mx/cep/descarga.do?formato=XML + response: + body: + string: "\r\n\r\n \r\n \r\n" + headers: + Content-Disposition: + - attachment; filename=CEP-20220419-CUENCA927820173168.xml + Content-Language: + - es-MX + Content-Length: + - '1518' + Content-Type: + - application/xml + Date: + - Tue, 19 Apr 2022 21:17:35 GMT + Set-Cookie: + - SRVCOOKIE=!jMGg3sMDWwoEsir405nf5XFqnQVk9OT6Jf1SsYxFpqrgt/UHsPxFVZ7bPL92NjQ/Wzxy3VBqC+6ujw==; + expires=Wed, 20-Apr-2022 05:17:35 GMT; path=/; Httponly + - TS012f422b=01ab44a5a84ee0f5f2b81af101e0b1c8f875cfc07b5378fc9bd26fa1222168c17902059100cb52f99d24783cf2a17d512b924678c2dd39b3a53bf06040dbee5dbc85b9927c3d33e710cfd30a3924506454420961d963205f5b5f324ed2295cea3e3945bb52; + Path=/ + - TS604574e3027=083fd6a492ab20007ff9a66e0d9718ed26a70c9697ef7e07a8d044c78e1dbee2b05005f8602787a208215f8c261130001892680087237a5afa06384a1a645ec5b52d5293e7d8b40476ed2aa6ad6aac21e3de074e780c99c7ff41c9ed2dc06321;Path=/ + X-OPNET-Transaction-Trace: + - a2_79b13b05-6f29-42c7-91ed-71334055f647 + status: + code: 200 + message: OK +- request: + body: tipoCriterio=T&receptorParticipante=0&captcha=c&tipoConsulta=1&fecha=19-04-2022&criterio=CUENCA927820173168&emisor=90646&receptor=40012&cuenta=012180000&monto=0.01 + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '172' + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, + like Gecko) Chrome/75.0.3770.142 Safari/537.36 + method: POST + uri: http://www.banxico.org.mx/cep/valida.do + response: + body: + string: '' + headers: + Connection: + - Keep-Alive + Content-Length: + - '0' + Date: + - Tue, 19 Apr 2022 21:17:35 GMT + Location: + - https://www.banxico.org.mx/cep/valida.do + Server: + - mxbanxico + status: + code: 307 + message: Temporary Redirect +- request: + body: tipoCriterio=T&receptorParticipante=0&captcha=c&tipoConsulta=1&fecha=19-04-2022&criterio=CUENCA927820173168&emisor=90646&receptor=40012&cuenta=012180000&monto=0.01 + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '172' + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, + like Gecko) Chrome/75.0.3770.142 Safari/537.36 + method: POST + uri: https://www.banxico.org.mx/cep/valida.do + response: + body: + string: "\r\n
\r\n \r\n Error\r\n
\r\n
\r\ + \n
\r\n

\r\n La imagen de seguridad no fue\ + \ ingresada correctamente. Favor de validar.\r\n

\r\n
\r\ + \n
\r\n\r\n" + headers: + Content-Language: + - es-MX + Content-Length: + - '405' + Content-Type: + - text/html; charset=UTF-8 + Date: + - Tue, 19 Apr 2022 21:17:36 GMT + Set-Cookie: + - JSESSIONID=6cJDsBmUO7OjutcMI8VxNVxtzlBIM6JHRHINEzs3gliiStHUhHpa!-925117081; + path=/; HttpOnly + - Hex39714011=!MWFXVIw/cRbrBz3405nf5XFqnQVk9Hvghg2GhEL384Cx7OdDFyI1oI0fYMM96VoU7HU8ThiWL0pLaQ==; + expires=Wed, 20-Apr-2022 05:17:36 GMT; path=/; Httponly + - TS012f422b=01ab44a5a8761823b60f3765cee7d5559d3ed3961908d4459c47fedcc99534b2ca7b658c045c1d70a84798df3d97e2848159966ec770318251bed2c9270525852a6e7d9f33fd5c43af6fc4195eddccb1075b8acc77; + Path=/ + - TS604574e3027=083fd6a492ab200007d94aaf5be6dfba69d46f64d45c72db5793176ff9b898a88692d3a1a828d9e908af966ba1113000e0840914674bb44b6d552077a07f6b0024196a95dd03e59c55dc88a5858845257faca4c82dfddb5d72a846673742f1c3;Path=/ + X-OPNET-Transaction-Trace: + - a2_5b3d9b40-d879-4b28-b0e5-f3df3ac01ef7 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Cookie: + - Hex39714011=!MWFXVIw/cRbrBz3405nf5XFqnQVk9Hvghg2GhEL384Cx7OdDFyI1oI0fYMM96VoU7HU8ThiWL0pLaQ==; + JSESSIONID=6cJDsBmUO7OjutcMI8VxNVxtzlBIM6JHRHINEzs3gliiStHUhHpa!-925117081; + TS012f422b=01ab44a5a8761823b60f3765cee7d5559d3ed3961908d4459c47fedcc99534b2ca7b658c045c1d70a84798df3d97e2848159966ec770318251bed2c9270525852a6e7d9f33fd5c43af6fc4195eddccb1075b8acc77; + TS604574e3027=083fd6a492ab200007d94aaf5be6dfba69d46f64d45c72db5793176ff9b898a88692d3a1a828d9e908af966ba1113000e0840914674bb44b6d552077a07f6b0024196a95dd03e59c55dc88a5858845257faca4c82dfddb5d72a846673742f1c3 + User-Agent: + - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, + like Gecko) Chrome/75.0.3770.142 Safari/537.36 + method: GET + uri: http://www.banxico.org.mx/cep/descarga.do?formato=XML + response: + body: + string: '' + headers: + Connection: + - Keep-Alive + Content-Length: + - '0' + Date: + - Tue, 19 Apr 2022 21:17:36 GMT + Location: + - https://www.banxico.org.mx/cep/descarga.do?formato=XML + Server: + - mxbanxico + status: + code: 307 + message: Temporary Redirect +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Cookie: + - Hex39714011=!MWFXVIw/cRbrBz3405nf5XFqnQVk9Hvghg2GhEL384Cx7OdDFyI1oI0fYMM96VoU7HU8ThiWL0pLaQ==; + JSESSIONID=6cJDsBmUO7OjutcMI8VxNVxtzlBIM6JHRHINEzs3gliiStHUhHpa!-925117081; + TS012f422b=01ab44a5a8761823b60f3765cee7d5559d3ed3961908d4459c47fedcc99534b2ca7b658c045c1d70a84798df3d97e2848159966ec770318251bed2c9270525852a6e7d9f33fd5c43af6fc4195eddccb1075b8acc77; + TS604574e3027=083fd6a492ab200007d94aaf5be6dfba69d46f64d45c72db5793176ff9b898a88692d3a1a828d9e908af966ba1113000e0840914674bb44b6d552077a07f6b0024196a95dd03e59c55dc88a5858845257faca4c82dfddb5d72a846673742f1c3 + User-Agent: + - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, + like Gecko) Chrome/75.0.3770.142 Safari/537.36 + method: GET + uri: https://www.banxico.org.mx/cep/descarga.do?formato=XML + response: + body: + string: ' + + + + + + Error 500--Internal Server Error + + + + + +
+ + + +

+ +

Error 500--Internal Server + Error

+ +
+ + + +

From RFC 2068 Hypertext + Transfer Protocol -- HTTP/1.1:

+ +

10.5.1 500 Internal Server Error

+ +

The server encountered an unexpected condition + which prevented it from fulfilling the request.

+ +
+ + + + + + + ' + headers: + Connection: + - close + Content-Length: + - '833' + Content-Type: + - text/html; charset=UTF-8 + Date: + - Tue, 19 Apr 2022 21:17:36 GMT + Set-Cookie: + - SRVCOOKIE=!f3sZq1H9d1S4+FX405nf5XFqnQVk9FgmJKPo0QxklfZwxZKufDzvrw2+ACDXj4c0lhyx3nlcsZ98ug==; + expires=Wed, 20-Apr-2022 05:17:36 GMT; path=/; Httponly + - TS012f422b=01ab44a5a8c884fe8dd3071575fe2361378169827808d4459c47fedcc99534b2ca7b658c045c1d70a84798df3d97e2848159966ec770318251bed2c9270525852a6e7d9f33229f81f985eabb2332f22b6724ea1682017bf3951ff27b7e174421b0fc1de82a; + Path=/ + - TS604574e3027=083fd6a492ab20004b27a71726f021ec9e2104108257861e46a163fc78ea8fe3595952f42d741e88087c07aea9113000bcce342d7428324a6d552077a07f6b0024196a95dd03e59c55dc88a5858845257faca4c82dfddb5d72a846673742f1c3;Path=/ + X-OPNET-Transaction-Trace: + - a2_721380fe-ff89-47ab-9d22-9e24c8a74161 + status: + code: 500 + message: Internal Server Error +version: 1 diff --git a/tests/cassettes/test_maximo_numero_de_requests.yaml b/tests/cassettes/test_maximo_numero_de_requests.yaml new file mode 100644 index 0000000..85e62a4 --- /dev/null +++ b/tests/cassettes/test_maximo_numero_de_requests.yaml @@ -0,0 +1,220 @@ +interactions: +- request: + body: tipoCriterio=T&receptorParticipante=0&captcha=c&tipoConsulta=1&fecha=19-04-2022&criterio=CUENCA927820173168&emisor=90646&receptor=40012&cuenta=012180000&monto=0.01 + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '172' + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, + like Gecko) Chrome/75.0.3770.142 Safari/537.36 + method: POST + uri: http://www.banxico.org.mx/cep/valida.do + response: + body: + string: '' + headers: + Connection: + - Keep-Alive + Content-Length: + - '0' + Date: + - Tue, 19 Apr 2022 21:51:50 GMT + Location: + - https://www.banxico.org.mx/cep/valida.do + Server: + - mxbanxico + status: + code: 307 + message: Temporary Redirect +- request: + body: tipoCriterio=T&receptorParticipante=0&captcha=c&tipoConsulta=1&fecha=19-04-2022&criterio=CUENCA927820173168&emisor=90646&receptor=40012&cuenta=012180000&monto=0.01 + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '172' + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, + like Gecko) Chrome/75.0.3770.142 Safari/537.36 + method: POST + uri: https://www.banxico.org.mx/cep/valida.do + response: + body: + string: "\n\n\n \n \n \n\n \n\n\n\n\n\ + \n\n\n \n\n\n\n\n\ + \n\n\ + \n\n\n\n\n\n\n\n\n\n\n\n\ + \n\n Comprobante Electrónico de Pago\n\ + \ \n \n
\n \n
\n \ + \
\n
COMPROBANTE\ + \ ELECTRÓNICO DE PAGO (CEP)
\n
\n

Lo sentimos, pero ha\ + \ excedido el número máximo de consultas en este portal. Favor\ + \ de intentar nuevamente más tarde.

\n
\n \ + \ \n \n\n" + headers: + Content-Language: + - es-MX + Content-Length: + - '2406' + Content-Type: + - text/html; charset=UTF-8 + Date: + - Tue, 19 Apr 2022 21:51:50 GMT + Set-Cookie: + - JSESSIONID=KLdDz3LR_IRe6qPumAGCjSRfNZx91q8BIj_LwHRY_LCcibcfWTvI!1328161135; + path=/; HttpOnly + - Hex39714011=!AkEDf9NaQgleUL/405nf5XFqnQVk9D9VcrkCYEPQep+A3oHUJyDE8htrLE4FTPUpRUMsOdkbRDIubA==; + expires=Wed, 20-Apr-2022 05:51:50 GMT; path=/; Httponly + - TS012f422b=01ab44a5a84ba34c6254a45e478d11f14262bf511a9306483d2c7cc58f192905fd9e019d5473069defd5830e310c3982200f31571ee74849480bcf0ab316272c5ea364881c0f4c784228060d62792d55448c10604e; + Path=/ + - TS604574e3027=083fd6a492ab200089282012bc422149ca7726bed6c29d31e21f2e7154820a0e40d2b889733f26af0874c788d0113000f9f421179607e3aae9aff0c88a12638e3960b93e5387f38da0cc9c7e29fdc65544bb76cc96f53551446a69ff8e3b4763;Path=/ + X-OPNET-Transaction-Trace: + - a2_99506051-843d-42c8-863a-517d53d6c767 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Cookie: + - Hex39714011=!AkEDf9NaQgleUL/405nf5XFqnQVk9D9VcrkCYEPQep+A3oHUJyDE8htrLE4FTPUpRUMsOdkbRDIubA==; + JSESSIONID=KLdDz3LR_IRe6qPumAGCjSRfNZx91q8BIj_LwHRY_LCcibcfWTvI!1328161135; + TS012f422b=01ab44a5a84ba34c6254a45e478d11f14262bf511a9306483d2c7cc58f192905fd9e019d5473069defd5830e310c3982200f31571ee74849480bcf0ab316272c5ea364881c0f4c784228060d62792d55448c10604e; + TS604574e3027=083fd6a492ab200089282012bc422149ca7726bed6c29d31e21f2e7154820a0e40d2b889733f26af0874c788d0113000f9f421179607e3aae9aff0c88a12638e3960b93e5387f38da0cc9c7e29fdc65544bb76cc96f53551446a69ff8e3b4763 + User-Agent: + - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, + like Gecko) Chrome/75.0.3770.142 Safari/537.36 + method: GET + uri: http://www.banxico.org.mx/cep/descarga.do?formato=XML + response: + body: + string: '' + headers: + Connection: + - Keep-Alive + Content-Length: + - '0' + Date: + - Tue, 19 Apr 2022 21:51:50 GMT + Location: + - https://www.banxico.org.mx/cep/descarga.do?formato=XML + Server: + - mxbanxico + status: + code: 307 + message: Temporary Redirect +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Cookie: + - Hex39714011=!AkEDf9NaQgleUL/405nf5XFqnQVk9D9VcrkCYEPQep+A3oHUJyDE8htrLE4FTPUpRUMsOdkbRDIubA==; + JSESSIONID=KLdDz3LR_IRe6qPumAGCjSRfNZx91q8BIj_LwHRY_LCcibcfWTvI!1328161135; + TS012f422b=01ab44a5a84ba34c6254a45e478d11f14262bf511a9306483d2c7cc58f192905fd9e019d5473069defd5830e310c3982200f31571ee74849480bcf0ab316272c5ea364881c0f4c784228060d62792d55448c10604e; + TS604574e3027=083fd6a492ab200089282012bc422149ca7726bed6c29d31e21f2e7154820a0e40d2b889733f26af0874c788d0113000f9f421179607e3aae9aff0c88a12638e3960b93e5387f38da0cc9c7e29fdc65544bb76cc96f53551446a69ff8e3b4763 + User-Agent: + - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, + like Gecko) Chrome/75.0.3770.142 Safari/537.36 + method: GET + uri: https://www.banxico.org.mx/cep/descarga.do?formato=XML + response: + body: + string: "\n\n\n \n \n \n\n \n\n\n\n\n\ + \n\n\n \n\n\n\n\n\ + \n\n\ + \n\n\n\n\n\n\n\n\n\n\n\n\ + \n\n Comprobante Electrónico de Pago\n\ + \ \n \n
\n \n
\n \ + \
\n
COMPROBANTE\ + \ ELECTRÓNICO DE PAGO (CEP)
\n
\n

Lo sentimos, pero ha\ + \ excedido el número máximo de consultas en este portal. Favor\ + \ de intentar nuevamente más tarde.

\n
\n \ + \ \n \n\n" + headers: + Content-Language: + - es-MX + Content-Length: + - '2406' + Content-Type: + - text/html; charset=UTF-8 + Date: + - Tue, 19 Apr 2022 21:51:50 GMT + Set-Cookie: + - SRVCOOKIE=!2w1jhvdlbozG5sb405nf5XFqnQVk9J2n59GepkXVIK+/WmlCJ2w++9O5OIqqMhcKpRUWOm6OREn2nQ==; + expires=Wed, 20-Apr-2022 05:51:50 GMT; path=/; Httponly + - TS012f422b=01ab44a5a884a34c70cd0f67c02ee851d659a1698d9306483d2c7cc58f192905fd9e019d5473069defd5830e310c3982200f31571ee74849480bcf0ab316272c5ea364881c5cf1af23755b31ab92b4f41241a75e918e80a00b5317894584a9338a0662afdb; + Path=/ + - TS604574e3027=083fd6a492ab2000a7fde1407f73b9cacfd9f9413af72771dd0cea9f02f4d034e5cf9893e5396e6d08ec67f70d113000231aad0df5d8e978e9aff0c88a12638e3960b93e5387f38da0cc9c7e29fdc65544bb76cc96f53551446a69ff8e3b4763;Path=/ + X-OPNET-Transaction-Trace: + - a2_a071dea0-3515-4de5-b164-07ba2e5b55f6 + status: + code: 200 + message: OK +version: 1 \ No newline at end of file diff --git a/tests/test_transferencia.py b/tests/test_transferencia.py index 206e5c1..5cbea57 100644 --- a/tests/test_transferencia.py +++ b/tests/test_transferencia.py @@ -2,8 +2,10 @@ import os import pytest +from requests import HTTPError from cep import Transferencia +from cep.exc import CepError, MaxRequestError @pytest.mark.vcr @@ -54,3 +56,36 @@ def test_descagar_transferencia_con_fecha_distinta(transferencia): ) assert type(tr.to_dict()) is dict tr.descargar() + + +@pytest.mark.vcr +def test_lanza_cep_error_para_errores_500(): + try: + for i in range(10): + Transferencia.validar( + fecha=dt.date(2022, 4, 19), + clave_rastreo='CUENCA927820173168', + emisor='90646', # STP + receptor='40012', # BBVA + cuenta='012180000', + monto=0.01, + ) + except CepError as exc: + assert type(exc.__cause__) is HTTPError + assert str(exc.__cause__) == ( + '500 Server Error: Internal Server Error for url: ' + 'https://www.banxico.org.mx/cep/descarga.do?formato=XML' + ) + + +@pytest.mark.vcr +def test_maximo_numero_de_requests(): + with pytest.raises(MaxRequestError): + Transferencia.validar( + fecha=dt.date(2022, 4, 19), + clave_rastreo='CUENCA927820173168', + emisor='90646', # STP + receptor='40012', # BBVA + cuenta='012180000', + monto=0.01, + )