def test_rows_to_pandas_missing_cols(self):
        import pandas as pd

        row_list = RowList([
            Row("k1", {
                "c1": "v1",
                "c2": "v1"
            }),
            Row("k2", {
                "c1": "v2",
                "c2": "v2",
                "c3": "v2"
            })
        ])
        pd.testing.assert_frame_equal(
            pd.DataFrame(
                {
                    "c1": ["v1", "v2"],
                    "c2": ["v1", "v2"],
                    "c3": [None, "v2"]
                },
                index=["k1", "k2"]),
            row_list.to_pandas().sort_index(axis=1),
        )
        pd.testing.assert_frame_equal(
            pd.DataFrame({
                "c1": ["v1"],
                "c2": ["v1"]
            }, index=["k1"]), row_list[0].to_pandas())
Beispiel #2
0
 def test_insert_single_DTO(self, mock_raw_row_response):
     res = RAW_API.rows.insert(
         db_name="db1", table_name="table1", row=Row(key="row1", columns={"c1": 1, "c2": "2"}), ensure_parent=False
     )
     assert res is None
     assert [{"key": "row1", "columns": {"c1": 1, "c2": "2"}}] == jsgz_load(
         mock_raw_row_response.calls[0].request.body
     )["items"]
 def test_get_rows_in_table(self, mock_raw_table_response,
                            mock_raw_row_response):
     tables = RAW_API.tables.list(db_name="db1")
     rows = tables[0].rows()
     assert RowList(
         [Row._load({
             "key": "row1",
             "columns": {
                 "c1": 1,
                 "c2": "2"
             }
         })]) == rows
 def test_insert_multiple_DTO(self, mock_raw_row_response):
     res = RAW_API.rows.insert(
         "db1",
         "table1",
         row=[Row(key="row1", columns={
             "c1": 1,
             "c2": "2"
         })])
     assert res is None
     assert [{
         "key": "row1",
         "columns": {
             "c1": 1,
             "c2": "2"
         }
     }] == jsgz_load(mock_raw_row_response.calls[0].request.body)["items"]
 def test_list(self, mock_raw_row_response):
     res_list = RAW_API.rows.list(db_name="db1", table_name="table1")
     assert RowList([Row(key="row1", columns={
         "c1": 1,
         "c2": "2"
     })]) == res_list
Beispiel #6
0
 def test_list(self, mock_raw_row_response):
     res_list = RAW_API.rows.list(db_name="db1", table_name="table1")
     assert RowList([Row(key="row1", columns={"c1": 1, "c2": "2"})]) == res_list
     assert "columns=" not in mock_raw_row_response.calls[0].request.path_url