Skip to content

Add regression test for UUID values - #172

Merged
browniebroke merged 1 commit into
django-commons:mainfrom
GiannopoulosK:test-uuid-values-issue-24
Nov 19, 2026
Merged

browniebroke merged 1 commit into
django-commons:mainfrom
GiannopoulosK:test-uuid-values-issue-24

Conversation

@GiannopoulosK

Copy link
Copy Markdown
Contributor

Closes #24.

Summary

The ValueError: Cannot convert UUID(...) to Excel reported in #24 no longer occurs. It was fixed indirectly by #34 (released in 0.4.1), which runs cell values through str() as part of value sanitization. Before that change, raw uuid.UUID objects were passed straight to openpyxl, which can't write them.

I confirmed the export works on the latest release (2.6.0).

Changes

Since nothing in the code handles UUIDs explicitly, this adds a regression test (test_uuid_values) so the bug can't silently return if the sanitization logic changes. It covers:

  • UUIDField (DRF already serializes this to a string)
  • ReadOnlyField passing a raw uuid.UUID through
  • SerializerMethodField returning a raw uuid.UUID

The test first asserts that the last two really do produce uuid.UUID objects, then checks that all three cells contain the UUID as a string.

@codecov

codecov Bot commented Nov 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@browniebroke browniebroke changed the title Add regression test for UUID values (#24) Add regression test for UUID values Nov 19, 2026
@browniebroke
browniebroke merged commit 8c9f568 into django-commons:main Nov 19, 2026
7 checks passed
@browniebroke

Copy link
Copy Markdown
Member

Thanks for the contribution 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ValueError: Cannot convert UUID('some_uuid') to Excel

2 participants