-
Notifications
You must be signed in to change notification settings - Fork 1k
Tests performed for the fetch_consumption method #8462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
VIKTORVAV99
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR but I fail to understand what you are actually trying to test since you are creating a class of ZoneKey instead of using the ZoneKey type.
| class ZoneKey: | ||
| def __init__(self, zone): self.zone = zone | ||
| def __eq__(self, other): | ||
| if isinstance(other, ZoneKey): return self.zone == other.zone | ||
| return self.zone == other | ||
| def __hash__(self): return hash(self.zone) | ||
| def __str__(self): return self.zone |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this a class?
ZoneKey is just a type alias of str to help with type flows.
| def mock_dependencies(mocker): | ||
|
|
||
| mocker.patch(f"{PATCH_PATH}.datetime", mocker.MagicMock(wraps=datetime)) | ||
| mocker.patch(f"{PATCH_PATH}.datetime.now", return_value=MOCKED_NOW) | ||
| mocker.patch(f"{PATCH_PATH}.timedelta", timedelta) | ||
|
|
||
| mocker.patch(f"{PATCH_PATH}.fetch_live_consumption", autospec=True) | ||
| mocker.patch(f"{PATCH_PATH}.fetch_historical_consumption", autospec=True) | ||
|
|
||
| mocker.patch(f"{PATCH_PATH}.Session") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dependencies should not be mocked.
| mocker.patch(f"{PATCH_PATH}.Session") | ||
|
|
||
| def test_ct1_live_data_valida(mocker): | ||
| expected_data = [{"time": "now"}] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this supposed to test?
We don't have any data in this format?
Hello, I am a beginner in software testing development and I'm trying to contribute to this project. While analyzing the fetch_consumption method, which is located in /electricitymap/contrib/parsers/VN.py, I noticed that the logical operator 'is' should be changed to the logical operator '==', so I modified the VN.py file. I added a test file named test_VN.py in electricitymap/contrib/parsers/tests which tests the method after changing the logical operators. If this is a mistake, I apologize.