Add comprehensive unit tests for DataFrame operations and _normalize_scalar#146
Merged
saurabhrb merged 2 commits intousers/zhaodongwang/dataFrameExtensionClaudefrom Mar 17, 2026
Conversation
Co-authored-by: saurabhrb <32964911+saurabhrb@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [PR-98] Address unresolved review comments and add unit tests
Add comprehensive unit tests for DataFrame operations and Mar 17, 2026
_normalize_scalar
saurabhrb
approved these changes
Mar 17, 2026
d028005
into
users/zhaodongwang/dataFrameExtensionClaude
1 check passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds test coverage gaps identified in the PR #98 review: direct tests for
_normalize_scalar()and an end-to-end mocked CRUD flow forDataFrameOperations.tests/unit/test_pandas_helpers.pyTestNormalizeScalarclass (9 tests) directly exercising_normalize_scalar():np.integer,np.floating,np.bool_) → Python nativespd.Timestamp→ ISO 8601 stringNonepass through unchangedtests/unit/test_dataframe_operations.pyTestDataFrameEndToEndclass (2 tests):create → get → update → deleteNotes
filterparameter kept as-is (consistent withrecords.get()API; repo convention prohibits# noqasuppression)DataFrameOperationsnot re-exported from top-level__init__.py(repo convention: package__init__.pyfiles use__all__ = [])Original prompt
Context
This PR addresses the remaining unresolved review comments from PR #98 (#98) and adds comprehensive unit tests for the DataFrame operations.
The PR #98 adds DataFrame CRUD wrappers (
client.dataframe.get(),client.dataframe.create(),client.dataframe.update(),client.dataframe.delete()) to the Dataverse Python SDK. The author has addressed many review comments but several remain unresolved.Current State of the Code
The branch
users/zhaodongwang/dataFrameExtensionClaudehas the latest code. Key files:src/PowerPlatform/Dataverse/utils/_pandas.py(current)src/PowerPlatform/Dataverse/operations/dataframe.py(current - 305 lines)The
DataFrameOperationsclass provides get/create/update/delete methods. Key points:get()returns a single consolidated DataFrame (iterates all pages internally)create()validates non-empty, validates ID count matchesupdate()validates id_column exists, validates IDs are non-empty strings, validates at least one change column exists; hasclear_nullsparameterdelete()validates ids is Series, validates IDs are non-empty strings, special-cases single IDsrc/PowerPlatform/Dataverse/operations/__init__.py(current)src/PowerPlatform/Dataverse/__init__.py(current)src/PowerPlatform/Dataverse/client.py(current)Already imports and exposes
DataFrameOperationsasself.dataframe.Issues to Fix
1.
filterparameter shadows Python built-in (item #8)In
dataframe.pyget()method, the parameterfiltershadows the Python built-infilter(). Since this mirrors the existingrecords.get()API which also usesfilter, renaming is risky for API consistency. The safe fix is to add a# noqa: A002comment on the parameter and leave it as-is for API consistency (the baserecords.get()already usesfilter). Alternatively, rename tofilter_exprwith an alias for backward compatibility. Decision: keepfilterfor API consistency with existingrecords.get(), but suppress the lint warning.2. Missing
__init__.pyexport forDataFrameOperations(item #9)The
operations/__init__.pyalready exportsDataFrameOperations. However, the top-levelsrc/PowerPlatform/Dataverse/__init__.pydoes NOT export it. Add the export there so users can dofrom PowerPlatform.Dataverse import DataFrameOperationsif needed.3. Comprehensive unit tests (item #10)
The existing
tests/unit/test_client_dataframe.pyhas 365 lines of tests. We need to add MORE tests to ensure full coverage. Specifically add tests for:Unit tests for
_pandas.pyhelpers:_normalize_scalarwith np.int64, np.float64, np.bool_, pd.Timestamp, regular Python typesdataframe_to_recordswith NaN handling (na_as_null=True vs False)dataframe_to_recordswith Timestamp conversiondataframe_to_recordswith non-scalar values (lists, dicts in cells)dataframe_to_recordswith numpy scalar types in DataFramedataframe_to_recordswith empty DataFramedataframe_to_recordswith mixed typesUnit tests for
DataFrameOperations:get()single recordget()multi-page results concatenatedget()empty resultsget()with all parameters passed throughcreate()with valid DataFramecreate()with empty DataFrame (should raise ValueError)create()with non-DataFrame input (should raise TypeError)create()ID count mismatch (should raise ValueError)update()with valid DataFrameupdate()single record pathThis pull request was created from Copilot chat.
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.