-
Notifications
You must be signed in to change notification settings - Fork 22
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
feat: Export Results as Dataframe #100
base: master
Are you sure you want to change the base?
Conversation
Pipeline failure fix is raised here - #99 |
…ython into users/priya/results-dataframe-utility
results: The list of results to normalize. | ||
Returns: | ||
A Pandas DataFrame with the normalized queried results. |
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.
add documentation for the code structure
expected_results_dict = [] | ||
for result in results: | ||
expected_results_dict.append(result.dict(exclude_unset=True)) | ||
expected_results_dataframe = pd.json_normalize(expected_results_dict, sep=".") |
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.
lets manually create a df for expected data, it helps see the actual df structure
keywords=[], | ||
), | ||
Result( | ||
status=Status(status_type=StatusType.PASSED), |
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.
there are some static methods available inside Status like Status.Passed()
. It can be used
assert isinstance(results_dataframe, pd.DataFrame) | ||
assert len(results_dataframe) == 3 | ||
assert len(results_dataframe.columns.tolist()) == 7 | ||
assert results_dataframe.equals(expected_results_dataframe) |
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.
a assert function part of pandas library was used in products utility. we can make use of that
|
||
@pytest.mark.enterprise | ||
class TestTestmonitorDataframeUtilities: | ||
def test__convert_results_to_dataframe__returns_results_dataframe(self, results): |
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.
add one test where the result contains all the fields value set
What does this Pull Request accomplish?
This PR adds utility to export Results as a normalized pandas Dataframe.
Why should this Pull Request be merged?
This utility can be useful to get the results data in the form of a Dataframe which can be useful for further processing.
What testing has been done?
Unit tests are included.