-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
RawDataRecord with unit tests #297
base: main
Are you sure you want to change the base?
Conversation
tests/software_tests/database/data_record/test_abstract_data_record.py
Outdated
Show resolved
Hide resolved
tests/software_tests/database/data_record/test_abstract_data_record.py
Outdated
Show resolved
Hide resolved
tests/software_tests/database/data_record/test_raw_data_record.py
Outdated
Show resolved
Hide resolved
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.
I like that you separated data_record
module.
I have left plenty of comments, but I think this is a really good start.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #297 +/- ##
===========================================
- Coverage 100.00% 99.93% -0.07%
===========================================
Files 46 48 +2
Lines 2818 2859 +41
Branches 345 351 +6
===========================================
+ Hits 2818 2857 +39
- Misses 0 2 +2
|
tests/software_tests/database/data_record/test_abstract_data_record.py
Outdated
Show resolved
Hide resolved
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.
I am going to help you with tests improvement.
self.__length = value | ||
|
||
@property | ||
def max_raw_value(self): |
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.
let's move it to AbstractDataRecord
(it is common for all DataRecords)
(8, 255), | ||
] | ||
) | ||
def test_max_raw_value_getter(self, length, value): |
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.
let's move it to AbstractDataRecord tests
you can test it without creating an object:
self.mock_data_record.length = length
- to set length value
RawDataRecord.max_raw_value .fget(self.mock_data_record)
- to get max_raw_value
from property of RawDataRecord
class
) | ||
@patch(f"{SCRIPT_LOCATION}.isinstance") | ||
def test_decode_type_error(self, mock_isinstance, value): | ||
with pytest.raises(TypeError): |
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.
we need one more line before with pytest.raises
:
mock_isinstance.return_value = False
to make sure that type check failed
) | ||
@patch(f"{SCRIPT_LOCATION}.isinstance") | ||
def test_encode_type_error(self, mock_isinstance, value): | ||
with pytest.raises(TypeError): |
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.
we need one more line before with pytest.raises:
mock_isinstance.return_value = False to make sure that type check failed
|
||
# encode | ||
|
||
@pytest.mark.parametrize( |
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.
let's parametrize both value and max_raw_value
(like in test_encode_value_error
) and perform Boundary Value Analysis:
good candidates that work well with values in test_encode_value_error
@pytest.mark.parametrize(
"value, max_raw_value", [
(0, 2),
(3, 2),
(63, 6),
]
)
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.
almost ready to be merged
please check why codecov reports missing coverage (there is something wrong with TypeError tests, probably it would be solved after my comments are applied)
Description
Draft of Implementation for RawDataRecord with unit tests.
Refactoring the Data Records directory structure.
How Has This Been Tested?
Executing unit tests.
Process
I know the process and did my best to follow it