Skip to content

Commit 5322083

Browse files
committed
Add test data fixtures and enhance unit tests for metadata operations
- Introduced new test data fixtures in `tests/fixtures/test_data.py` for various metadata attributes, including columns, option sets, and relationships. - Updated `tests/unit/models/test_metadata.py` to utilize the new fixtures for testing `ColumnMetadata` and `OptionSetInfo` classes, improving test coverage for primary name columns, picklist columns, and status/state option sets. - Enhanced `tests/unit/test_tables_operations.py` to incorporate fixtures for table operations, ensuring accurate testing of column retrieval, relationship listing, and table metadata. - Refactored existing tests to replace hardcoded data with structured test data from the new fixtures, promoting maintainability and clarity in test cases.
1 parent 119ec8f commit 5322083

6 files changed

Lines changed: 804 additions & 100 deletions

File tree

src/PowerPlatform/Dataverse/common/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
ODATA_TYPE_PICKLIST_ATTRIBUTE = "Microsoft.Dynamics.CRM.PicklistAttributeMetadata"
3636
ODATA_TYPE_BOOLEAN_ATTRIBUTE = "Microsoft.Dynamics.CRM.BooleanAttributeMetadata"
3737
ODATA_TYPE_MULTISELECT_PICKLIST_ATTRIBUTE = "Microsoft.Dynamics.CRM.MultiSelectPicklistAttributeMetadata"
38+
ODATA_TYPE_STATUS_ATTRIBUTE = "Microsoft.Dynamics.CRM.StatusAttributeMetadata"
39+
ODATA_TYPE_STATE_ATTRIBUTE = "Microsoft.Dynamics.CRM.StateAttributeMetadata"
3840
ODATA_TYPE_STRING_ATTRIBUTE = "Microsoft.Dynamics.CRM.StringAttributeMetadata"
3941
ODATA_TYPE_INTEGER_ATTRIBUTE = "Microsoft.Dynamics.CRM.IntegerAttributeMetadata"
4042
ODATA_TYPE_DECIMAL_ATTRIBUTE = "Microsoft.Dynamics.CRM.DecimalAttributeMetadata"

src/PowerPlatform/Dataverse/data/_odata.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
ODATA_TYPE_BOOLEAN_ATTRIBUTE,
3939
ODATA_TYPE_MULTISELECT_PICKLIST_ATTRIBUTE,
4040
ODATA_TYPE_PICKLIST_ATTRIBUTE,
41+
ODATA_TYPE_STATE_ATTRIBUTE,
42+
ODATA_TYPE_STATUS_ATTRIBUTE,
4143
)
4244

4345
from .. import __version__ as _SDK_VERSION
@@ -1659,6 +1661,8 @@ def _get_column_optionset(
16591661
ODATA_TYPE_PICKLIST_ATTRIBUTE,
16601662
ODATA_TYPE_BOOLEAN_ATTRIBUTE,
16611663
ODATA_TYPE_MULTISELECT_PICKLIST_ATTRIBUTE,
1664+
ODATA_TYPE_STATUS_ATTRIBUTE,
1665+
ODATA_TYPE_STATE_ATTRIBUTE,
16621666
]:
16631667
url = f"{base}/{cast_type}"
16641668
try:

tests/fixtures/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT license.

0 commit comments

Comments
 (0)