|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
| 15 | + |
15 | 16 | import pandas as pd |
16 | 17 | import pytest |
17 | 18 |
|
18 | 19 | import bigframes as bf |
| 20 | +import bigframes.pandas as bpd |
19 | 21 |
|
20 | 22 | pytest.importorskip("anywidget") |
21 | 23 |
|
@@ -530,6 +532,34 @@ def test_widget_row_count_reflects_actual_data_available( |
530 | 532 | assert widget.page_size == 2 # Respects the display option |
531 | 533 |
|
532 | 534 |
|
| 535 | +def test_repr_html_raises_when_row_count_is_none(monkeypatch): |
| 536 | + df = bpd.DataFrame({"col1": [1, 2, 3]}) |
| 537 | + |
| 538 | + def mock_retrieve_repr_request_results(*args, **kwargs): |
| 539 | + return df.to_pandas(), None, None |
| 540 | + |
| 541 | + monkeypatch.setattr( |
| 542 | + df._block, "retrieve_repr_request_results", mock_retrieve_repr_request_results |
| 543 | + ) |
| 544 | + |
| 545 | + with pytest.raises(NotImplementedError): |
| 546 | + df._repr_html_() |
| 547 | + |
| 548 | + |
| 549 | +def test_repr_raises_when_row_count_is_none(monkeypatch): |
| 550 | + df = bpd.DataFrame({"col1": [1, 2, 3]}) |
| 551 | + |
| 552 | + def mock_retrieve_repr_request_results(*args, **kwargs): |
| 553 | + return df.to_pandas(), None, None |
| 554 | + |
| 555 | + monkeypatch.setattr( |
| 556 | + df._block, "retrieve_repr_request_results", mock_retrieve_repr_request_results |
| 557 | + ) |
| 558 | + |
| 559 | + with pytest.raises(NotImplementedError): |
| 560 | + df.__repr__() |
| 561 | + |
| 562 | + |
533 | 563 | # TODO(shuowei): Add tests for custom index and multiindex |
534 | 564 | # This may not be necessary for the SQL Cell use case but should be |
535 | 565 | # considered for completeness. |
0 commit comments