bito-code-review[bot] commented on code in PR #40885:
URL: https://github.com/apache/superset/pull/40885#discussion_r3602682284


##########
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:
   <!-- Bito Reply -->
   The approach of folding the text-payload case into the existing 
parametrization is appropriate. It effectively consolidates the test logic 
while maintaining coverage for bytes (ASCII and UTF-8) and string (UTF-8) 
inputs, which aligns with the reviewer's suggestion to avoid test duplication.
   
   **tests/unit_tests/utils/test_core.py**
   ```
   @pytest.mark.parametrize(
       ("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"
   ```



-- 
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]

Reply via email to