|
1 | | -import json |
2 | 1 | from pathlib import Path |
3 | 2 |
|
4 | 3 | import pytest |
@@ -110,12 +109,19 @@ def test_run_includes_list_of_records_table(tmp_path, dummy_preset, dummy_config |
110 | 109 | # The result should have 'BLOB_SCHEDULE' in config_vars |
111 | 110 | assert "BLOB_SCHEDULE" in spec_obj.config_vars |
112 | 111 | # The value should be a list of dicts with type constructors applied |
113 | | - var = json.loads(spec_obj.config_vars["BLOB_SCHEDULE"].value) |
114 | | - assert isinstance(var, list) |
115 | | - assert var[0]["EPOCH"] == "Epoch(269568)" |
116 | | - assert var[0]["MAX_BLOBS_PER_BLOCK"] == "uint64(6)" |
117 | | - assert var[1]["EPOCH"] == "Epoch(364032)" |
118 | | - assert var[1]["MAX_BLOBS_PER_BLOCK"] == "uint64(9)" |
| 112 | + assert ( |
| 113 | + spec_obj.config_vars["BLOB_SCHEDULE"].value |
| 114 | + == """( |
| 115 | + frozendict({ |
| 116 | + "EPOCH": Epoch(269568), |
| 117 | + "MAX_BLOBS_PER_BLOCK": uint64(6), |
| 118 | + }), |
| 119 | + frozendict({ |
| 120 | + "EPOCH": Epoch(364032), |
| 121 | + "MAX_BLOBS_PER_BLOCK": uint64(9), |
| 122 | + }), |
| 123 | +)""" |
| 124 | + ) |
119 | 125 |
|
120 | 126 |
|
121 | 127 | def test_run_includes_list_of_records_table_minimal(tmp_path, dummy_preset, dummy_config): |
@@ -144,26 +150,33 @@ def test_run_includes_list_of_records_table_minimal(tmp_path, dummy_preset, dumm |
144 | 150 | spec_obj = m2s.run() |
145 | 151 | assert "BLOB_SCHEDULE" in spec_obj.config_vars |
146 | 152 | # The result should follow the config, not the table |
147 | | - var = json.loads(spec_obj.config_vars["BLOB_SCHEDULE"].value) |
148 | | - assert isinstance(var, list) |
149 | | - assert var[0]["EPOCH"] == "Epoch(2)" |
150 | | - assert var[0]["MAX_BLOBS_PER_BLOCK"] == "uint64(3)" |
151 | | - assert var[1]["EPOCH"] == "Epoch(4)" |
152 | | - assert var[1]["MAX_BLOBS_PER_BLOCK"] == "uint64(5)" |
| 153 | + assert ( |
| 154 | + spec_obj.config_vars["BLOB_SCHEDULE"].value |
| 155 | + == """( |
| 156 | + frozendict({ |
| 157 | + "EPOCH": Epoch(2), |
| 158 | + "MAX_BLOBS_PER_BLOCK": uint64(3), |
| 159 | + }), |
| 160 | + frozendict({ |
| 161 | + "EPOCH": Epoch(4), |
| 162 | + "MAX_BLOBS_PER_BLOCK": uint64(5), |
| 163 | + }), |
| 164 | +)""" |
| 165 | + ) |
153 | 166 |
|
154 | 167 |
|
155 | 168 | def test_run_includes_python_function(tmp_path, dummy_preset, dummy_config): |
156 | | - md_content = """ |
| 169 | + md_content = ''' |
157 | 170 | #### `compute_epoch_at_slot` |
158 | 171 |
|
159 | 172 | ```python |
160 | 173 | def compute_epoch_at_slot(slot: Slot) -> Epoch: |
161 | | - \"\"\" |
| 174 | + """ |
162 | 175 | Return the epoch number at slot. |
163 | | - \"\"\" |
| 176 | + """ |
164 | 177 | return Epoch(slot // SLOTS_PER_EPOCH) |
165 | 178 | ``` |
166 | | -""" |
| 179 | +''' |
167 | 180 | file = tmp_path / "function.md" |
168 | 181 | file.write_text(md_content) |
169 | 182 | m2s = MarkdownToSpec( |
|
0 commit comments