File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55import io
66import json
77import sys
8+ import unittest .mock
89from contextlib import redirect_stderr
910from typing import TYPE_CHECKING , Any
1011from unittest .mock import Mock
@@ -1463,9 +1464,21 @@ def test_chart_with_url_data():
14631464 .encode (x = "Horsepower:Q" , y = "Miles_per_Gallon:Q" )
14641465 )
14651466
1466- marimo_chart = altair_chart (chart )
1467- assert isinstance (marimo_chart .dataframe , pl .DataFrame )
1468- assert len (marimo_chart .dataframe ) > 0
1467+ fake_payload = json .dumps (
1468+ [
1469+ {"Horsepower" : 130 , "Miles_per_Gallon" : 18.0 },
1470+ {"Horsepower" : 165 , "Miles_per_Gallon" : 15.0 },
1471+ {"Horsepower" : 150 , "Miles_per_Gallon" : 18.0 },
1472+ ]
1473+ ).encode ("utf-8" )
1474+
1475+ with unittest .mock .patch (
1476+ "urllib.request.urlopen" ,
1477+ return_value = io .BytesIO (fake_payload ),
1478+ ):
1479+ marimo_chart = altair_chart (chart )
1480+ assert isinstance (marimo_chart .dataframe , pl .DataFrame )
1481+ assert len (marimo_chart .dataframe ) > 0
14691482
14701483
14711484@pytest .mark .skipif (not HAS_DEPS , reason = "optional dependencies not installed" )
You can’t perform that action at this time.
0 commit comments