Skip to content

Commit 8772a2f

Browse files
committed
fix:PRComments
1 parent 46eaa97 commit 8772a2f

File tree

2 files changed

+27
-25
lines changed

2 files changed

+27
-25
lines changed

nisystemlink/clients/testmonitor/utilities/_dataframe_utilities.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ def convert_results_to_dataframe(results: List[Result]) -> pd.DataFrame:
1212
1313
Returns:
1414
A Pandas DataFrame with the normalized queried results.
15+
status_type_summary will be normalized into the respective status types.
16+
For example, status_type_summary.LOOPING, status_type_summary.PASSED.
17+
Status is normalized into status.status_type and status.status_name.
18+
Properties are normalized into respective properties. For example,
19+
properties.property1, properties.property2 and etc.
1520
"""
1621
results_dict = [result.dict(exclude_unset=True) for result in results]
1722
normalized_dataframe = pd.json_normalize(results_dict, sep=".")

tests/unit/testmonitor/test_testmonitor_dataframe_utilities.py

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,23 @@ def results() -> List[Result]:
1515
"""Sample results for testing purposes."""
1616
results = [
1717
Result(
18-
status=Status(status_type=StatusType.PASSED),
19-
id=uuid.uuid1().hex,
20-
part_number=uuid.uuid1().hex,
21-
keywords=["keyword1", "keyword2"],
22-
properties={"property1": "value1", "property2": "value2"},
23-
),
24-
Result(
25-
status=Status(status_type=StatusType.PASSED),
26-
id=uuid.uuid1().hex,
27-
part_number=uuid.uuid1().hex,
28-
keywords=[],
29-
),
30-
Result(
31-
status=Status(status_type=StatusType.PASSED),
32-
id=uuid.uuid1().hex,
33-
part_number=uuid.uuid1().hex,
34-
properties={
35-
"property1": "value1",
36-
"property2": "value2",
37-
"property3": "value3",
38-
},
18+
status = Status.PASSED(),
19+
started_at = "2018-05-07T18:58:05.219692Z",
20+
updated_at = "2018-05-07T18:58:05.219692Z",
21+
program_name = "My Program Name",
22+
id = uuid.uuid1().hex,
23+
system_id = uuid.uuid1().hex,
24+
host_name = "host name",
25+
part_number = uuid.uuid1().hex,
26+
serial_number = uuid.uuid1().hex,
27+
total_time_in_seconds = 16.76845106446358,
28+
keywords = ["keyword1", "keyword2"],
29+
properties = {"property1": "value1", "property2": "value2"},
30+
operator = "sample operator",
31+
file_ids = [uuid.uuid1().hex, uuid.uuid1().hex],
32+
data_table_ids = [uuid.uuid1().hex, uuid.uuid1().hex],
33+
status_type_summary = {StatusType.PASSED: 1, StatusType.FAILED: 0},
34+
workspace = uuid.uuid1().hex,
3935
),
4036
]
4137

@@ -44,7 +40,7 @@ def results() -> List[Result]:
4440

4541
@pytest.mark.enterprise
4642
class TestTestmonitorDataframeUtilities:
47-
def test__convert_results_to_dataframe__returns_results_dataframe(self, results):
43+
def test__convert_results_to_dataframe__returns_results_dataframe(self, results: List[Result]):
4844
expected_results_dict = []
4945
for result in results:
5046
expected_results_dict.append(result.dict(exclude_unset=True))
@@ -55,9 +51,10 @@ def test__convert_results_to_dataframe__returns_results_dataframe(self, results)
5551

5652
assert not results_dataframe.empty
5753
assert isinstance(results_dataframe, pd.DataFrame)
58-
assert len(results_dataframe) == 3
59-
assert len(results_dataframe.columns.tolist()) == 7
60-
assert results_dataframe.equals(expected_results_dataframe)
54+
assert len(results_dataframe) == 1
55+
assert len(results_dataframe.columns.tolist()) == 19
56+
assert results_dataframe.equals(expected_results_dataframe), expected_results_dataframe
57+
pd.testing.assert_frame_equal(results_dataframe, expected_results_dataframe, check_dtype=True), expected_results_dataframe
6158

6259
def test__convert_results_to_dataframe_with_no_results__returns_empty_dataframe(
6360
self,

0 commit comments

Comments
 (0)