22Test CSV formatting.
33
44"""
5+ from codecs import BOM_UTF8
6+
57from hamcrest import (
68 assert_that ,
79 contains_inanyorder ,
@@ -22,14 +24,14 @@ def test_make_response():
2224 dict (foo = "baz" ),
2325 ]))
2426
25- assert_that (response .data , is_ (equal_to (b"foo\r \n bar\r \n baz\r \n " )))
27+ assert_that (response .data , is_ (equal_to (BOM_UTF8 + b"foo\r \n bar\r \n baz\r \n " )))
2628 assert_that (response .content_type , is_ (equal_to ("text/csv; charset=utf-8" )))
2729 assert_that (response .headers , contains_inanyorder (
2830 ("Content-Disposition" , "attachment; filename=\" response.csv\" " ),
2931 ("Content-Type" , "text/csv; charset=utf-8" ),
3032 ("ETag" , etag_for (
31- md5_hash = '"a2ead3516dd1be4a3c7f45716c0a0eb7 "' ,
32- spooky_hash = '"02dee263db4f9326a3fbee9135939717 "' ,
33+ md5_hash = '"d0366f8e71095c1b68e2ddfd551b3285 "' ,
34+ spooky_hash = '"e264d2b6b13c5298cb2059716018aa4d "' ,
3335 )),
3436 ))
3537
@@ -42,14 +44,14 @@ def test_make_response_tuples():
4244 ("d" , "e" , "f" ),
4345 ]))
4446
45- assert_that (response .data , is_ (equal_to (b"a,b,c\r \n d,e,f\r \n " )))
47+ assert_that (response .data , is_ (equal_to (BOM_UTF8 + b"a,b,c\r \n d,e,f\r \n " )))
4648 assert_that (response .content_type , is_ (equal_to ("text/csv; charset=utf-8" )))
4749 assert_that (response .headers , contains_inanyorder (
4850 ("Content-Disposition" , "attachment; filename=\" response.csv\" " ),
4951 ("Content-Type" , "text/csv; charset=utf-8" ),
5052 ("ETag" , etag_for (
51- md5_hash = '"eb8bde290633452402b37aa580ca30e9 "' ,
52- spooky_hash = '"63b989eb36315937ef68206fb9fc3104 "' ,
53+ md5_hash = '"22252aa7c314539c78dfa19dbf9af674 "' ,
54+ spooky_hash = '"37cd063df88efefe1929f3cf4532b718 "' ,
5355 )),
5456 ))
5557
@@ -62,14 +64,14 @@ def test_make_response_list():
6264 ["d" , "e" , "f" ],
6365 ]))
6466
65- assert_that (response .data , is_ (equal_to (b"a,b,c\r \n d,e,f\r \n " )))
67+ assert_that (response .data , is_ (equal_to (BOM_UTF8 + b"a,b,c\r \n d,e,f\r \n " )))
6668 assert_that (response .content_type , is_ (equal_to ("text/csv; charset=utf-8" )))
6769 assert_that (response .headers , contains_inanyorder (
6870 ("Content-Disposition" , "attachment; filename=\" response.csv\" " ),
6971 ("Content-Type" , "text/csv; charset=utf-8" ),
7072 ("ETag" , etag_for (
71- md5_hash = '"eb8bde290633452402b37aa580ca30e9 "' ,
72- spooky_hash = '"63b989eb36315937ef68206fb9fc3104 "' ,
73+ md5_hash = '"22252aa7c314539c78dfa19dbf9af674 "' ,
74+ spooky_hash = '"37cd063df88efefe1929f3cf4532b718 "' ,
7375 )),
7476 ))
7577
@@ -85,13 +87,13 @@ def test_make_response_ordered():
8587 )
8688 ]))
8789
88- assert_that (response .data , is_ (equal_to (b"id,firstName,lastName\r \n me,First,Last\r \n " )))
90+ assert_that (response .data , is_ (equal_to (BOM_UTF8 + b"id,firstName,lastName\r \n me,First,Last\r \n " )))
8991 assert_that (response .content_type , is_ (equal_to ("text/csv; charset=utf-8" )))
9092 assert_that (response .headers , contains_inanyorder (
9193 ("Content-Disposition" , "attachment; filename=\" response.csv\" " ),
9294 ("Content-Type" , "text/csv; charset=utf-8" ),
9395 ("ETag" , etag_for (
94- md5_hash = '"4480bd6748cf93740490ebeee7eae1fe "' ,
95- spooky_hash = '"0a7f40b47efb0a197b180444c4911b17 "' ,
96+ md5_hash = '"79e41b38792fdca793f61791ef55e026 "' ,
97+ spooky_hash = '"994df8aa1632af103265ebeae37a3804 "' ,
9698 )),
9799 ))
0 commit comments