|
| 1 | +from pyrsistent import pmap |
1 | 2 | import pytest
|
2 | 3 |
|
3 | 4 | from referencing import Anchor, Registry, Resource, Specification, exceptions
|
@@ -177,22 +178,39 @@ def test_combine(self):
|
177 | 178 | one = Resource.opaque(contents={})
|
178 | 179 | two = ID_AND_CHILDREN.create_resource({"foo": "bar"})
|
179 | 180 | three = ID_AND_CHILDREN.create_resource({"baz": "quux"})
|
| 181 | + four = ID_AND_CHILDREN.create_resource({"anchors": {"foo": 12}}) |
180 | 182 |
|
181 | 183 | first = Registry({"http://example.com/1": one})
|
182 |
| - second = Registry({"http://example.com/foo/bar": two}) |
| 184 | + second = Registry().with_resource("http://example.com/foo/bar", two) |
183 | 185 | third = Registry(
|
184 | 186 | {
|
185 | 187 | "http://example.com/1": one,
|
186 | 188 | "http://example.com/baz": three,
|
187 | 189 | },
|
188 | 190 | )
|
189 |
| - assert first.combine(second, third) == Registry( |
| 191 | + fourth = ( |
| 192 | + Registry() |
| 193 | + .with_resource( |
| 194 | + "http://example.com/foo/quux", |
| 195 | + four, |
| 196 | + ) |
| 197 | + .crawl() |
| 198 | + ) |
| 199 | + assert first.combine(second, third, fourth) == Registry( |
190 | 200 | [
|
191 | 201 | ("http://example.com/1", one),
|
192 |
| - ("http://example.com/foo/bar", two), |
193 | 202 | ("http://example.com/baz", three),
|
| 203 | + ("http://example.com/foo/quux", four), |
194 | 204 | ],
|
195 |
| - ) |
| 205 | + anchors=pmap( |
| 206 | + { |
| 207 | + ("http://example.com/foo/quux", "foo"): Anchor( |
| 208 | + name="foo", |
| 209 | + resource=ID_AND_CHILDREN.create_resource(12), |
| 210 | + ), |
| 211 | + }, |
| 212 | + ), |
| 213 | + ).with_resource("http://example.com/foo/bar", two) |
196 | 214 |
|
197 | 215 | def test_combine_with_uncrawled_resources(self):
|
198 | 216 | one = Resource.opaque(contents={})
|
|
0 commit comments