bito-code-review[bot] commented on code in PR #40885: URL: https://github.com/apache/superset/pull/40885#discussion_r3602444755
########## tests/unit_tests/utils/test_core.py: ########## @@ -70,6 +71,39 @@ } [email protected]( + ("name", "content_type"), + [ + ( + "report.xlsx", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + ), + ("report.zip", "application/zip"), + ], +) +def test_build_email_attachment( + name: str, + content_type: str, +) -> None: + """Email attachments should expose the expected MIME type and filename.""" + attachment = build_email_attachment(name, b"attachment") + + assert attachment.get_content_type() == content_type + assert attachment.get_filename() == name + assert attachment.get_payload(decode=True) == b"attachment" + + +def test_build_email_attachment_encodes_text_payload() -> None: + """Text attachment bodies should be encoded to stable UTF-8 bytes.""" + attachment = build_email_attachment("report.csv", "город,value\nМосква,1") + + assert attachment.get_content_type() == "application/octet-stream" + assert attachment.get_filename() == "report.csv" + assert attachment.get_payload(decode=True) == "город,value\nМосква,1".encode( + "utf-8" + ) Review Comment: <div> <div id="suggestion"> <div id="issue"><b>Semantic test duplication</b></div> <div id="fix"> This test duplicates existing assertion at line 93 that also checks `get_payload(decode=True)`. Both tests verify identical email library behavior from different input types. Consider parameterizing the existing `test_build_email_attachment` to cover all three cases (bytes ASCII, bytes UTF-8, str UTF-8) instead of maintaining separate test functions with overlapping coverage. </div> </div> <small><i>Code Review Run #2b27dd</i></small> </div> --- Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>) - [ ] Yes, avoid them -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
