adds: tests for csv

This commit is contained in:
msramalho
2022-09-27 14:49:04 +01:00
parent 65366816fa
commit 484d3cb02c
3 changed files with 7 additions and 0 deletions

View File

@@ -89,6 +89,7 @@ class CSVEncoder:
self.state, self.state,
fieldnames=["cluster_id"] + list(cluster[0].keys()), fieldnames=["cluster_id"] + list(cluster[0].keys()),
quoting=csv.QUOTE_NONNUMERIC, quoting=csv.QUOTE_NONNUMERIC,
lineterminator="\n",
) )
self.writer.writeheader() self.writer.writeheader()

View File

@@ -27,3 +27,4 @@ def test_encoders():
assert res["string"] == read_fixture_content("snapshots/result.txt") assert res["string"] == read_fixture_content("snapshots/result.txt")
assert res["json"] == read_fixture_content("snapshots/result.json") assert res["json"] == read_fixture_content("snapshots/result.json")
assert res["geojson"] == read_fixture_content("snapshots/result.geojson") assert res["geojson"] == read_fixture_content("snapshots/result.geojson")
assert res["csv"] == read_fixture_content("snapshots/result.csv")

5
tests/fixtures/snapshots/result.csv vendored Normal file
View File

@@ -0,0 +1,5 @@
"cluster_id","id","name","lat","lon"
0,1,"Alice",52.523955,13.442362
0,2,"Bob",52.526659,13.448097
1,3,"Carol",52.525626,13.419246
1,4,"Dan",52.52443559865125,13.41261723049818
1 cluster_id id name lat lon
2 0 1 Alice 52.523955 13.442362
3 0 2 Bob 52.526659 13.448097
4 1 3 Carol 52.525626 13.419246
5 1 4 Dan 52.52443559865125 13.41261723049818