Skip to content

Commit 17d4747

Browse files
author
Saurabh Badenkal
committed
Add tests for empty-DF-with-columns and all-NaN create, prompt before cleanup
- test_get_no_results_with_select_preserves_columns: verifies empty result with select returns DataFrame with expected column names - test_create_all_nan_rows_raises: verifies all-NaN rows raise ValueError - prodev: cleanup now prompts user (Y/n) before deleting demo tables, matching the pattern in alternate_keys_upsert.py
1 parent e8f6a48 commit 17d4747

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

examples/advanced/prodev_quick_start.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,12 @@ def run_demo(client):
120120
# -- Step 5: Update and delete --
121121
step5_update_and_delete(client, task_ids, primary_name_col, primary_id_col)
122122

123-
# -- Step 6: Cleanup --
124-
cleanup(client)
123+
# -- Step 6: Cleanup (optional -- prompts before deleting) --
124+
do_cleanup = input("\n6. Delete demo tables and cleanup? (Y/n): ").strip() or "y"
125+
if do_cleanup.lower() in ("y", "yes"):
126+
cleanup(client)
127+
else:
128+
print("[INFO] Tables kept for inspection.")
125129

126130
print("\n" + "=" * 60)
127131
print("[OK] Pro-dev quick start demo complete!")

tests/unit/test_dataframe_operations.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,21 @@ def test_get_no_results(self):
5959
self.assertIsInstance(df, pd.DataFrame)
6060
self.assertEqual(len(df), 0)
6161

62+
def test_get_no_results_with_select_preserves_columns(self):
63+
"""Empty result with select returns DataFrame with expected columns."""
64+
self.client._odata._get_multiple.return_value = iter([])
65+
df = self.client.dataframe.get("account", select=["name", "telephone1"])
66+
self.assertIsInstance(df, pd.DataFrame)
67+
self.assertEqual(len(df), 0)
68+
self.assertListEqual(list(df.columns), ["name", "telephone1"])
69+
70+
def test_create_all_nan_rows_raises(self):
71+
"""DataFrame where all values are NaN raises ValueError."""
72+
df = pd.DataFrame([{"name": None, "phone": None}])
73+
with self.assertRaises(ValueError) as ctx:
74+
self.client.dataframe.create("account", df)
75+
self.assertIn("no non-null values", str(ctx.exception))
76+
6277
def test_get_passes_all_params(self):
6378
"""All OData parameters are forwarded to the underlying API call."""
6479
self.client._odata._get_multiple.return_value = iter([])

0 commit comments

Comments
 (0)