Skip to content
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

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

priyadarshini-ni
Copy link
Contributor

@priyadarshini-ni priyadarshini-ni commented Mar 5, 2025

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.

@priyadarshini-ni
Copy link
Contributor Author

Pipeline failure fix is raised here - #99

results: The list of results to normalize.
Returns:
A Pandas DataFrame with the normalized queried results.

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=".")

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),

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)

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):

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants