Skip to content

Commit 2886cb2

Browse files
refactor: update test file
1 parent 42725e5 commit 2886cb2

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

nisystemlink/clients/product/utilities/_dataframe_utilities.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ def convert_products_to_dataframe(products: List[Product]) -> DataFrame:
1414
Returns:
1515
DataFrame: A Pandas DataFrame containing the normalized product data.
1616
"""
17-
products_dict_representation = [
18-
product.dict(exclude_unset=True) for product in products
19-
]
17+
products_dict_representation = [product.dict() for product in products]
2018
normalized_products_dataframe = pd.json_normalize(
2119
products_dict_representation, sep="."
2220
)

tests/unit/product/test_product_dataframe_utilities.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,13 @@ def empty_products_data() -> List:
5353

5454

5555
@pytest.mark.enterprise
56+
@pytest.mark.unit
5657
class TestProductDataframeUtilities:
5758
def test__convert_products_to_dataframe__with_complete_data(
5859
self, mock_product_data, expected_products_dataframe
5960
):
6061
"""Test normal case with valid product data."""
61-
products = mock_product_data
62-
63-
products_dataframe = convert_products_to_dataframe(products)
62+
products_dataframe = convert_products_to_dataframe(mock_product_data)
6463

6564
assert not products_dataframe.empty
6665
assert (
@@ -73,9 +72,7 @@ def test__convert_products_to_dataframe__with_complete_data(
7372

7473
def test__convert_products_to_dataframe__with_empty_data(self, empty_products_data):
7574
"""Test case when the input products data is empty."""
76-
products = empty_products_data
77-
78-
products_dataframe = convert_products_to_dataframe(products)
75+
products_dataframe = convert_products_to_dataframe(empty_products_data)
7976

8077
assert products_dataframe.empty
8178

@@ -84,8 +81,8 @@ def test__convert_products_to_dataframe__with_missing_fields(
8481
):
8582
"""Test case when some fields in product data are missing."""
8683
products = mock_product_data
87-
del products[0].keywords
88-
del products[0].properties
84+
products[0].keywords = None
85+
products[0].properties = None
8986

9087
products_dataframe = convert_products_to_dataframe(products)
9188
expected_products_dataframe = expected_products_dataframe.drop(

0 commit comments

Comments
 (0)