TST: add tests of dict input to data_transformers
@@ -68,7 +68,7 @@ def test_type_error():
pipe(0, f)
-def test_to_json():
+def test_dataframe_to_json():
"""Test to_json
- make certain the filename is deterministic
- make certain the file contents match the data
@@ -86,8 +86,26 @@ def test_to_json():
assert output.equals(data)
-def test_to_csv():
- """Test to_csv
+def test_dict_to_json():
+ """Test to_json
+ - make certain the filename is deterministic
+ - make certain the file contents match the data
+ """
+ data = _create_data_with_values(10)
+ try:
+ result1 = pipe(data, to_json)
+ result2 = pipe(data, to_json)
+ filename = result1['url']
+ output = pd.read_json(filename).to_dict(orient='records')
+ finally:
+ os.remove(filename)
+
+ assert result1 == result2
+ assert data == {'values': output}
+
+
+def test_dataframe_to_csv():
+ """Test to_csv with dataframe input
- make certain the filename is deterministic
- make certain the file contents match the data
"""
@@ -102,3 +120,21 @@ def test_to_csv():
assert result1 == result2
assert output.equals(data)
+
+
+def test_dict_to_csv():
+ """Test to_csv with dict input
+ - make certain the filename is deterministic
+ - make certain the file contents match the data
+ """
+ data = _create_data_with_values(10)
+ try:
+ result1 = pipe(data, to_csv)
+ result2 = pipe(data, to_csv)
+ filename = result1['url']
+ output = pd.read_csv(filename).to_dict(orient='records')
+ finally:
+ os.remove(filename)
+
+ assert result1 == result2
+ assert data == {'values': output}
