This repository has been archived by the owner on Jun 20, 2023. It is now read-only.
/
test_init.py
657 lines (546 loc) · 26.4 KB
/
test_init.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
from unittest.mock import Mock
from pyramid import testing
from pytest import raises
from pytest import fixture
import colander
@fixture
def sheet_meta(sheet_meta):
from adhocracy_core.sheets import AnnotationRessourceSheet
from adhocracy_core.interfaces import ISheet
class SheetASchema(colander.MappingSchema):
count = colander.SchemaNode(colander.Int(),
missing=colander.drop,
default=0)
meta = sheet_meta._replace(isheet=ISheet,
schema_class=SheetASchema,
sheet_class=AnnotationRessourceSheet,
readable=True,
editable=True,
creatable=True)
return meta
class TestBaseResourceSheet:
@fixture
def mock_node_unique_references(self):
from adhocracy_core.schema import UniqueReferences
from adhocracy_core.schema import SheetReference
mock = Mock(spec=UniqueReferences)
mock.readonly = False
mock.name = 'references'
mock.backref = False
mock.reftype = SheetReference
mock.default = []
mock.clone.return_value = mock
return mock
@fixture
def mock_node_single_reference(self):
from adhocracy_core.schema import Reference
from adhocracy_core.schema import SheetReference
mock = Mock(spec=Reference)
mock.readonly = False
mock.name = 'reference'
mock.backref = False
mock.reftype = SheetReference
mock.default = []
mock.clone.return_value = mock
return mock
@fixture
def context(self, context, mock_graph):
context.__graph__ = mock_graph
return context
@fixture
def inst(self, sheet_meta, context, registry):
inst = self.get_class()(sheet_meta, context, registry)
inst._get_data_appstruct = Mock(spec=inst._get_data_appstruct)
inst._get_data_appstruct.return_value = {}
inst._store_data = Mock(spec=inst._store_data)
return inst
def get_class(self):
from adhocracy_core.sheets import BaseResourceSheet
return BaseResourceSheet
def test_create_valid(self, registry, sheet_meta, context):
from zope.interface.verify import verifyObject
from adhocracy_core.interfaces import IResourceSheet
inst = self.get_class()(sheet_meta, context, registry)
assert inst.context == context
assert inst.meta == sheet_meta
assert inst.registry == registry
assert inst.request is None
assert inst.creating is None
assert IResourceSheet.providedBy(inst)
assert verifyObject(IResourceSheet, inst)
def test_create_valid_with_request(self, registry, sheet_meta, context,
request_):
inst = self.get_class()(sheet_meta, context, registry,
request=request_)
assert inst.request == request_
def test_create_valid_with_creating(self, registry, sheet_meta, context,
resource_meta):
inst = self.get_class()(sheet_meta, context, registry,
creating=resource_meta)
assert inst.creating == resource_meta
def test_get_schema_with_bindings(self, inst):
schema = inst.get_schema_with_bindings()
assert schema.bindings == {'context': inst.context,
'request': inst.request,
'registry': inst.registry,
'creating': inst.creating,
}
def test_get_schema_with_bindings_add_name(self, inst):
schema = inst.get_schema_with_bindings()
assert schema.name == inst.meta.isheet.__identifier__
def test_get_schema_with_bindings_add_required_if_create_mandatory(
self, inst):
from adhocracy_core.interfaces import IResource
inst.creating = IResource
inst.meta = inst.meta._replace(create_mandatory=True)
schema = inst.get_schema_with_bindings()
assert schema.missing is colander.required
def test_get_schema_with_bindings_add_dropt_if_not_create_mandatory(
self, inst):
schema = inst.get_schema_with_bindings()
assert schema.missing is colander.drop
def test_get_with_default(self, inst):
assert inst.get() == {'count': 0}
def test_get_with_deferred_default(self, inst):
"""A dictionary with 'registry', 'context', 'creating' and 'request' is
passed to deferred default functions.
"""
schema = inst.schema.bind()
@colander.deferred
def default(node, kw):
return len(kw)
schema['count'].default = default
inst.schema = schema
assert inst.get() == {'count': 4}
def test_get_with_omit_defaults(self, inst):
assert inst.get(omit_defaults=True) == {}
def test_get_non_empty(self, inst):
inst._get_data_appstruct.return_value = {'count': 11}
assert inst.get() == {'count': 11}
def test_get_with_custom_query(self, inst, sheet_catalogs,
mock_node_unique_references):
from adhocracy_core.interfaces import search_result
node = mock_node_unique_references
inst.schema.children.append(node)
sheet_catalogs.search.return_value = search_result
appstruct = inst.get({'depth': 100})
query = sheet_catalogs.search.call_args[0][0]
assert query.depth == 100
def test_get_raise_if_query_key_is_no_search_query_key(self, inst):
with raises(ValueError):
inst.get({'WRONG': 100})
def test_set(self, inst):
assert inst.set({'count': 11}) is True
inst._store_data.assert_called_with({'count': 11})
def test_set_ignore_not_changed_valued(self, inst):
inst._get_data_appstruct.return_value = {'count': 11,
'count2': None}
inst.set({'count': 11,
'count2': 2})
inst._store_data.assert_called_with({'count2': 2})
def test_set_empty(self, inst):
assert inst.set({}) is False
assert inst.get() == {'count': 0}
def test_set_omit_str(self, inst):
assert inst.set({'count': 11}, omit='count') is False
def test_set_omit_tuple(self, inst):
assert inst.set({'count': 11}, omit=('count',)) is False
def test_set_omit_wrong_key(self, inst):
assert inst.set({'count': 11}, omit=('wrongkey',)) is True
def test_set_omit_readonly(self, inst):
inst.schema['count'].readonly = True
inst.set({'count': 11})
assert inst.get() == {'count': 0}
def test_set_references(self, inst, context, mock_graph,
mock_node_unique_references, registry):
from adhocracy_core.interfaces import ISheet
node = mock_node_unique_references
inst.schema.children.append(node)
inst.context._graph = mock_graph
target = testing.DummyResource()
inst.set({'references': [target]})
mock_graph.set_references_for_isheet.assert_called_with(
context, ISheet, {'references': [target]}, registry,
send_event=True)
def test_get_valid_back_references(self, inst, context, sheet_catalogs,
mock_node_unique_references):
from adhocracy_core.interfaces import ISheet
from adhocracy_core.interfaces import search_result
from adhocracy_core.interfaces import search_query
from adhocracy_core.interfaces import Reference
node = mock_node_unique_references
node.backref = True
inst.schema.children.append(node)
source = testing.DummyResource()
result = search_result._replace(elements=[source])
sheet_catalogs.search.return_value = result
appstruct = inst.get()
reference = Reference(None, ISheet, '', context)
query = search_query._replace(references=[reference],
resolve=True,
allows=(('admin'), 'view')
)
sheet_catalogs.search.call_args[0] == query
assert appstruct['references'] == [source]
def test_get_omit_valid_back_references(self, inst, context, sheet_catalogs,
mock_node_unique_references):
from adhocracy_core.interfaces import search_result
node = mock_node_unique_references
node.backref = True
inst.schema.children.append(node)
source = testing.DummyResource()
result = search_result._replace(elements=[source])
sheet_catalogs.search.return_value = result
appstruct = inst.get(add_back_references=False)
assert not sheet_catalogs.search.called
assert appstruct['references'] == []
def test_set_reference(self, inst, context, mock_graph,
mock_node_single_reference, registry):
from adhocracy_core.interfaces import ISheet
node = mock_node_single_reference
inst.schema.children.append(node)
target = testing.DummyResource()
inst.set({'reference': target})
graph_set_args = mock_graph.set_references_for_isheet.call_args[0]
assert graph_set_args == (context, ISheet, {'reference': target}, registry)
def test_set_reference_without_send_events(
self, inst, context, mock_graph, mock_node_single_reference,
registry):
node = mock_node_single_reference
inst.schema.children.append(node)
target = testing.DummyResource()
inst.set({'reference': target})
graph_set_kwargs = mock_graph.set_references_for_isheet.call_args[1]
assert graph_set_kwargs == {'send_event': True}
def test_get_reference(self, inst, context, sheet_catalogs,
mock_node_single_reference):
from adhocracy_core.interfaces import ISheet
from adhocracy_core.interfaces import search_result
from adhocracy_core.interfaces import search_query
from adhocracy_core.interfaces import Reference
node = mock_node_single_reference
inst.schema.children.append(node)
target = testing.DummyResource()
result = search_result._replace(elements=[target])
sheet_catalogs.search.return_value = result
appstruct = inst.get()
reference = Reference(context, ISheet, 'reference', None)
query = search_query._replace(references=[reference],
resolve=True,
)
assert sheet_catalogs.search.call_args[0][0] == query
assert appstruct['reference'] == target
def test_get_reference_without_permission_check(
self, inst, context, sheet_catalogs, mock_node_single_reference):
from adhocracy_core.interfaces import ISheet
from adhocracy_core.interfaces import search_query
from adhocracy_core.interfaces import Reference
node = mock_node_single_reference
inst.schema.children.append(node)
appstruct = inst.get()
reference = Reference(context, ISheet, 'reference', None)
query = search_query._replace(references=[reference],
resolve=True,
allows=(('admin'), 'view')
)
assert sheet_catalogs.search.call_args[0][0] == query._replace(allows=())
def test_get_references(self, inst, context, sheet_catalogs,
mock_node_unique_references):
from adhocracy_core.interfaces import ISheet
from adhocracy_core.interfaces import search_result
from adhocracy_core.interfaces import search_query
from adhocracy_core.interfaces import Reference
node = mock_node_unique_references
inst.schema.children.append(node)
target = testing.DummyResource()
result = search_result._replace(elements=[target])
sheet_catalogs.search.return_value = result
appstruct = inst.get()
reference = Reference(context, ISheet, 'references', None)
query = search_query._replace(references=[reference],
resolve=True,
sort_by='reference'
)
assert sheet_catalogs.search.call_args[0][0] == query
def test_get_back_reference(self, inst, context, sheet_catalogs,
mock_node_single_reference):
from adhocracy_core.interfaces import ISheet
from adhocracy_core.interfaces import search_result
from adhocracy_core.interfaces import Reference
node = mock_node_single_reference
node.backref = True
inst.schema.children.append(node)
source = testing.DummyResource()
result = search_result._replace(elements=[source])
sheet_catalogs.search.return_value = result
appstruct = inst.get()
reference = Reference(None, ISheet, '', context)
assert sheet_catalogs.search.call_args[0][0].references == [reference]
assert appstruct['reference'] == source
def test_notify_resource_sheet_modified(self, inst, context, config):
from adhocracy_core.interfaces import IResourceSheetModified
from adhocracy_core.testing import create_event_listener
events = create_event_listener(config, IResourceSheetModified)
inst.set({'count': 2})
assert IResourceSheetModified.providedBy(events[0])
assert events[0].object == context
assert events[0].registry == config.registry
assert events[0].old_appstruct == {'count': 0}
assert events[0].new_appstruct == {'count': 2}
assert events[0].autoupdated is False
def test_notify_resource_sheet_modified_autoupdated(self, inst, config):
from adhocracy_core.interfaces import IResourceSheetModified
from adhocracy_core.testing import create_event_listener
events = create_event_listener(config, IResourceSheetModified)
inst.set({'count': 2}, autoupdated=True)
assert events[0].autoupdated
def test_serialize(self, inst, request_):
from . import BaseResourceSheet
inst.request = request_
inst.get = Mock(spec=BaseResourceSheet.get)
inst.get.return_value = {'elements': [],
'count': 2}
assert inst.serialize() == {'count': '2'}
default_params = {'only_visible': True,
'allows': (request_.effective_principals, 'view'),
}
assert inst.get.call_args[1]['params'] == default_params
assert inst.get.call_args[1]['omit_defaults'] is True
def test_serialize_with_params(self, inst, request_):
inst.request = request_
inst.get = Mock()
inst.get.return_value = {'elements': []}
cstruct = inst.serialize(params={'name': 'child'})
assert 'name' in inst.get.call_args[1]['params']
def test_serialize_filter_by_view_permission(self, inst, request_):
inst.request = request_
inst.get = Mock()
inst.get.return_value = {}
cstruct = inst.serialize()
assert inst.get.call_args[1]['params']['allows'] == \
(request_.effective_principals, 'view')
def test_serialize_filter_by_view_permission_disabled(self, inst,
request_):
inst.request = request_
inst.registry.settings['adhocracy.filter_by_view_permission'] = "False"
inst.get = Mock()
inst.get.return_value = {}
cstruct = inst.serialize()
assert 'allows' not in inst.get.call_args[1]['params']
def test_serialize_filter_by_only_visible(self, inst, request_):
inst.request = request_
inst.get = Mock()
inst.get.return_value = {}
cstruct = inst.serialize()
assert inst.get.call_args[1]['params']['only_visible']
def test_serialize_filter_by_only_visible_disabled(self, inst, request_):
inst.request = request_
inst.registry.settings['adhocracy.filter_by_visible'] = "False"
inst.get = Mock()
inst.get.return_value = {}
cstruct = inst.serialize()
assert 'only_visible' not in inst.get.call_args[1]['params']
def test_serialize_with_back_references(self, inst, request_):
inst.request = request_
inst.get = Mock()
inst.get.return_value = {}
inst.serialize()
assert inst.get.call_args[1]['add_back_references'] is True
def test_serialize_omit_back_references(self, inst, request_):
inst.request = request_
inst.get = Mock()
inst.get.return_value = {}
inst.serialize(add_back_references=False)
assert inst.get.call_args[1]['add_back_references'] is False
class TestAnnotationRessourceSheet:
@fixture
def sheet_meta(self, sheet_meta):
from . import AnnotationRessourceSheet
class SheetASchema(colander.MappingSchema):
count = colander.SchemaNode(colander.Int(),
missing=colander.drop,
default=0)
other = colander.SchemaNode(colander.Int(),
missing=colander.drop,
default=0)
return sheet_meta._replace(sheet_class=AnnotationRessourceSheet,
schema_class=SheetASchema)
@fixture
def inst(self, sheet_meta, context, registry):
from . import AnnotationRessourceSheet
return AnnotationRessourceSheet(sheet_meta, context, registry)
def test_create(self, inst, context, sheet_meta):
from . import BaseResourceSheet
from adhocracy_core.interfaces import IResourceSheet
from zope.interface.verify import verifyObject
assert isinstance(inst, BaseResourceSheet)
assert inst.context == context
assert inst.meta == sheet_meta
assert IResourceSheet.providedBy(inst)
assert verifyObject(IResourceSheet, inst)
def test_delete_field_values(self, inst):
appstruct = {'count': 2, 'other': 3}
setattr(inst.context, inst._annotation_key, appstruct)
inst.delete_field_values(['count'])
assert 'other' in appstruct
assert 'count' not in appstruct
def test_delete_field_values_ignore_if_wrong_field(self, inst):
appstruct = {'count': 2}
setattr(inst.context, inst._annotation_key, appstruct)
inst.delete_field_values(['wrong'])
assert 'count' in appstruct
def test_delete_field_values_remove_data_dict_if_empty(self, inst):
appstruct = {'count': 2}
setattr(inst.context, inst._annotation_key, appstruct)
inst.delete_field_values(['count'])
assert not hasattr(inst.context, inst._annotation_key)
def test_delete_field_values_no_delete_key_if_key_absent(self, inst):
assert inst.delete_field_values(['count']) is None
def test_set_with_other_sheet_name_conflicts(self, inst, sheet_meta,
context, registry):
from adhocracy_core.interfaces import ISheet
class ISheetB(ISheet):
pass
class SheetBSchema(sheet_meta.schema_class):
count = colander.SchemaNode(colander.Int(),
missing=colander.drop,
default=0)
sheet_b_meta = sheet_meta._replace(isheet=ISheetB,
schema_class=SheetBSchema)
inst_b = sheet_meta.sheet_class(sheet_b_meta, context, registry)
inst.set({'count': 1})
inst_b.set({'count': 2})
assert inst.get() == {'count': 1, 'other': 0}
assert inst_b.get() == {'count': 2, 'other': 0}
def test_set_with_subtype_and_name_conflicts(self, inst, sheet_meta,
context, registry):
class ISheetB(sheet_meta.isheet):
pass
class SheetBSchema(sheet_meta.schema_class):
count = colander.SchemaNode(colander.Int(),
missing=colander.drop,
default=0)
sheet_b_meta = sheet_meta._replace(isheet=ISheetB,
schema_class=SheetBSchema)
inst_b = sheet_meta.sheet_class(sheet_b_meta, context, registry)
inst.set({'count': 1, 'other': 0})
inst_b.set({'count': 2})
assert inst.get() == {'count': 1, 'other': 0}
assert inst_b.get() == {'count': 2, 'other': 0}
class TestAttributeResourceSheet:
@fixture
def sheet_meta(self, sheet_meta):
from . import AttributeResourceSheet
return sheet_meta._replace(sheet_class=AttributeResourceSheet)
@fixture
def inst(self, sheet_meta, context, registry):
from . import AttributeResourceSheet
return AttributeResourceSheet(sheet_meta, context, registry)
def test_create(self, inst, context, sheet_meta):
from . import BaseResourceSheet
from adhocracy_core.interfaces import IResourceSheet
from zope.interface.verify import verifyObject
assert isinstance(inst, BaseResourceSheet)
assert inst.context == context
assert inst.meta == sheet_meta
assert IResourceSheet.providedBy(inst)
assert verifyObject(IResourceSheet, inst)
def test_set(self, inst, context):
inst.set({'count': 1})
assert inst.get() == {'count': 1}
assert context.count == 1
def test_set_and_add_dirty_flag_for_persistent_context(self, inst):
from persistent.mapping import PersistentMapping
inst.context = PersistentMapping()
inst.context._p_jar = Mock()
inst.set({'count': 2})
assert inst.context._p_changed is True
def test_set_with_other_sheet_name_conflicts(self, inst, sheet_meta,
context, registry):
"""Different sheets with equalt field names override each other.
This should never happen.
"""
from adhocracy_core.interfaces import ISheet
class ISheetB(ISheet):
pass
class SheetBSchema(sheet_meta.schema_class):
count = colander.SchemaNode(colander.Int(),
missing=colander.drop,
default=0)
sheet_b_meta = sheet_meta._replace(isheet=ISheetB,
schema_class=SheetBSchema)
inst_b = sheet_meta.sheet_class(sheet_b_meta, context, registry)
inst.set({'count': 1})
inst_b.set({'count': 2})
assert inst.get() == {'count': 2}
assert inst_b.get() == {'count': 2}
def test_delete_field_values_ignore_if_wrong_field(self, inst, context):
context.count = 2
inst.delete_field_values(['wrong'])
assert hasattr(context, 'count')
def test_delete_field_values(self, inst, context):
context.count = 2
inst.delete_field_values(['count'])
assert not hasattr(context, 'count')
def test_delete_field_and_add_dirty_flag_for_persistent_context(self, inst):
from persistent.mapping import PersistentMapping
inst.context = PersistentMapping()
inst.context._p_jar = Mock()
inst.context.count = 2
inst.delete_field_values(['count'])
assert inst.context._p_changed
class TestAddSheetToRegistry:
@fixture
def registry(self, registry_with_content):
return registry_with_content
def call_fut(self, sheet_meta, registry):
from adhocracy_core.sheets import add_sheet_to_registry
return add_sheet_to_registry(sheet_meta, registry)
def test_register_valid_empty_mapping_schema(self, sheet_meta, registry):
from adhocracy_core.schema import MappingSchema
sheet_meta = sheet_meta._replace(schema_class=MappingSchema)
self.call_fut(sheet_meta, registry)
assert registry.content.sheets_meta == {sheet_meta.isheet: sheet_meta}
def test_register_valid_sheet_sheet_meta(self, sheet_meta, registry):
self.call_fut(sheet_meta, registry)
assert registry.content.sheets_meta == {sheet_meta.isheet: sheet_meta}
def test_register_valid_sheet_sheet_meta_replace_exiting(self, sheet_meta,
registry):
self.call_fut(sheet_meta, registry)
meta_b = sheet_meta._replace(permission_view='META_B')
self.call_fut(meta_b, registry)
assert registry.content.sheets_meta == {sheet_meta.isheet: meta_b}
def test_register_non_valid_readonly_and_createmandatory(self, sheet_meta, registry):
meta = sheet_meta._replace(editable=False,
creatable=False,
create_mandatory=True)
with raises(AssertionError):
self.call_fut(meta, registry)
def test_register_non_valid_non_isheet(self, sheet_meta, registry):
from zope.interface import Interface
meta = sheet_meta._replace(isheet=Interface)
with raises(AssertionError):
self.call_fut(meta, registry)
def test_register_non_valid_schema_without_default_values(self, sheet_meta, registry):
del sheet_meta.schema_class.__class_schema_nodes__[0].default
with raises(AssertionError):
self.call_fut(sheet_meta, registry)
def test_register_non_valid_schema_with_default_colander_drop(self, sheet_meta, registry):
sheet_meta.schema_class.__class_schema_nodes__[0].default = colander.drop
with raises(AssertionError):
self.call_fut(sheet_meta, registry)
def test_register_non_valid_non_mapping_schema(self, sheet_meta, registry):
meta = sheet_meta._replace(schema_class=colander.TupleSchema)
with raises(AssertionError):
self.call_fut(meta, registry)
def test_register_non_valid_schema_subclass_has_changed_field_type(self, sheet_meta, registry):
class SheetABSchema(sheet_meta.schema_class):
count = colander.SchemaNode(colander.String(),
missing=colander.drop,
default='D')
class ISheetAB(sheet_meta.isheet):
pass
meta_b = sheet_meta._replace(isheet=ISheetAB,
schema_class=SheetABSchema)
with raises(AssertionError):
self.call_fut(meta_b, registry)