Comments (7)
Re-checking now: there's no difference between the scraped and online-viewed JSON, and the test passed.
from xil.
After checking manually and reviewing the test runs (including the latest run), the issue does not reproduce.
I'm going to close it as a temporary bug.
from xil.
https://github.com/jond01/xil/actions/runs/6865423605/job/18674728221
from xil.
https://github.com/jond01/xil/actions/runs/7330517632
https://github.com/jond01/xil/actions/runs/7339447462
https://github.com/jond01/xil/actions/runs/7378131143
https://github.com/jond01/xil/actions/runs/7432286995
from xil.
The latest run (from today) shows the following difference when accessing through Python and a web browser (Chrome/Firefox/Safari):
{
- "generatingReportDateTime": "2024-01-05",
+ "generatingReportDateTime": "2024-01-06",
"marketingRecords": [
{
"buyRate": 0.2475,
"fromCurrency": "EUR",
"representativeExchangeRate": 0.2505,
"sellRate": 0.2499,
"toCurrency": "ILS"
},
{
"buyRate": 4.001,
"fromCurrency": "ILS",
"representativeExchangeRate": 3.9917,
"sellRate": 4.0412,
"toCurrency": "EUR"
},
{
"buyRate": 0.2698,
"fromCurrency": "USD",
"representativeExchangeRate": 0.2735,
"sellRate": 0.2725,
"toCurrency": "ILS"
},
{
"buyRate": 3.6691,
"fromCurrency": "ILS",
"representativeExchangeRate": 3.656,
"sellRate": 3.706,
"toCurrency": "USD"
}
]
}
The later and true date (2023-01-06) is from Python.
A quick test showed that when passing the following "Accept-Encoding" header in Python, the result was the same as in the web:
import urllib.request
headers = {"Accept-Encoding": "gzip, deflate, br"} # This header makes the server return an outdated response
url = "https://dv16ymfyh91nr.cloudfront.net/MarketingRatesReport/MarketingSiteFCYRatesCurrentReport.json"
req = urllib.request.Request(url, headers=headers)
with urllib.request.urlopen(req) as f:
print(f.read().decode())
Original check code
import json
import urllib.request
import logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
all_headers = {
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en-GB,en-US;q=0.9,en;q=0.8",
"Connection": "keep-alive",
"Host": "dv16ymfyh91nr.cloudfront.net",
"Priority": "u=0, i",
"Sec-Fetch-Dest": "document",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-Site": "none",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2.1 Safari/605.1.15",
}
url = "https://dv16ymfyh91nr.cloudfront.net/MarketingRatesReport/MarketingSiteFCYRatesCurrentReport.json"
for item in all_headers.items():
headers = dict([item])
logger.debug(headers)
req = urllib.request.Request(url, headers=headers)
with urllib.request.urlopen(req) as f:
data = f.read().decode()
if json.loads(data)["generatingReportDateTime"] == "2024-01-05":
logger.info("Found it!")
It explains the discrepancy mentioned in the issue's description, but not the failure of the test.
Moreover, since writing this comment, the web browser's response has been updated, matching now Python.
from xil.
https://github.com/jond01/xil/actions/runs/7432286995/job/20225973783
The client sub-issue (web browser/Python) is orthogonal to the test failure.
Even when the same, the test may fail, as in the case linked above.
The "buyRate" is higher than the "representativeExchangeRate" for both EUR and USD ("toCurrency").
The fix for the issue is probably to remove the wrong assertion.
from xil.
https://github.com/jond01/xil/actions/runs/8422210010/job/23060978005#step:6:42
from xil.
Related Issues (20)
- Changing the Git checkout clone depth to include the latest version tag.
- Don't publish local versions (+sha).
- Save caches in the CI (mypy, black, ruff) HOT 2
- Use Hypothesis instead of a constant URL HOT 1
- Add license HOT 1
- Add pyroma to pre-commit
- Run Isort through Ruff HOT 1
- Use `read_html`'s `storage_options` in pandas 2.1.0
- Add One-Zero bank exchange data
- Run only the "live" tests on a scheduled basis HOT 2
- Register a new "live" pytest marker and mark the relevant tests
- Add an option to disable network connection in tests
- Split the pre-commit job from the tests workflow
- Run only the "live" tests in the scheduled trigger of the tests workflow
- Consider publishing to PyPI with "Trusted Publishers"
- Add "Pepper" to known BOI banks list
- Bank Hapoalim API requires a functional cookie
- Update Discount module
- Address Geoblocking
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xil.