| 104 | def test_basemodel_with_clean_schema(self) -> None: |
| 105 | class Clean(BaseModel): |
| 106 | x: int = 0 |
| 107 | |
| 108 | out = _pydantic_schema_str(Clean) |
| 109 | parsed = json.loads(out) |
| 110 | # Clean schema path -> emits standard "properties" key. |
| 111 | self.assertIn("properties", parsed) |
| 112 | |
| 113 | def test_annotated_union_emits_one_of(self) -> None: |
| 114 | out = _pydantic_schema_str(PaperInput) |
| 115 | parsed = json.loads(out) |
| 116 | self.assertIn("oneOf", parsed) |
| 117 | # PaperInput has 5 variants; not all need schema-rendering, but |
| 118 | # the rendered list should be non-empty. |
| 119 | self.assertGreater(len(parsed["oneOf"]), 0) |
| 120 | |
| 121 | def test_baseinput_subclass_directly(self) -> None: |
| 122 | out = _pydantic_schema_str(ArxivIdentifier) |
| 123 | parsed = json.loads(out) |
| 124 | self.assertEqual(parsed["properties"]["type"]["default"], "arxiv") |
| 125 | |
| 126 | def test_fallback_for_unknown_type(self) -> None: |
| 127 | out = _pydantic_schema_str(int) |
| 128 | # Falls back to repr. |
| 129 | self.assertEqual(out, repr(int)) |
| 130 | |
| 131 | |
| 132 | class ResolveMagicInputTests(unittest.IsolatedAsyncioTestCase): |
| 133 | async def test_happy_path_returns_tuple(self) -> None: |
| 134 | captured: dict[str, object] = {} |
| 135 | |
| 136 | def _capture_agent(*_a: object, **kwargs: object) -> object: |
| 137 | captured.update(kwargs) |
| 138 | return MagicMock(name="agent") |
| 139 | |
| 140 | # Build a fake resolver result whose final_output is a populated |
| 141 | # ResolvedFlowConfig. |
| 142 | resolved = ResolvedFlowConfig[NewsWindow, NewsCollectionCfg]( |
| 143 | input_obj=_news_window(), |
| 144 | cfg_obj=NewsCollectionCfg(retain_raw_html=True), |
| 145 | ) |
| 146 | fake_result = MagicMock() |
| 147 | fake_result.final_output = resolved |
| 148 | with ( |
| 149 | patch("quantmind.magic.Agent", side_effect=_capture_agent), |
| 150 | patch( |
| 151 | "quantmind.magic.Runner.run", |
| 152 | new=AsyncMock(return_value=fake_result), |
| 153 | ), |
| 154 | ): |
| 155 | inp, cfg = await resolve_magic_input( |
| 156 | "collect the last day of pr-newswire", |
| 157 | target_flow=collect_news, |
| 158 | ) |
| 159 | self.assertIs(inp, resolved.input_obj) |
| 160 | self.assertIs(cfg, resolved.cfg_obj) |
| 161 | # Resolver agent was given a name derived from the flow. |
| 162 | self.assertEqual(captured["name"], "magic_resolver_collect_news") |
| 163 | self.assertEqual(captured["model"], "gpt-5.6-luna") |
nothing calls this directly
no outgoing calls
no test coverage detected