update transform test to fail on missing transform (#3085)
Co-authored-by: brokensound77 <brokensound77@users.noreply.github.com> Co-authored-by: Jonhnathan <26856693+w0rk3r@users.noreply.github.com> Co-authored-by: Terrance DeJesus <99630311+terrancedejesus@users.noreply.github.com>
This commit is contained in:
+17
-8
@@ -1177,20 +1177,29 @@ class TestNoteMarkdownPlugins(BaseRuleTest):
|
||||
for rule in self.production_rules.rules:
|
||||
has_transform = rule.contents.get('transform') is not None
|
||||
has_note = rule.contents.data.get('note') is not None
|
||||
note = rule.contents.data.note
|
||||
|
||||
if has_transform and not has_note:
|
||||
self.fail(f'{self.rule_str(rule)} transformed defined with no note')
|
||||
elif not has_transform:
|
||||
continue
|
||||
if has_transform:
|
||||
if not has_note:
|
||||
self.fail(f'{self.rule_str(rule)} transformed defined with no note')
|
||||
else:
|
||||
if not has_note:
|
||||
continue
|
||||
|
||||
note_template = PatchedTemplate(note)
|
||||
identifiers = [i for i in note_template.get_identifiers() if '_' in i]
|
||||
|
||||
if not has_transform:
|
||||
if identifiers:
|
||||
self.fail(f'{self.rule_str(rule)} note contains plugin placeholders with no transform entries')
|
||||
else:
|
||||
continue
|
||||
|
||||
transform = rule.contents.transform
|
||||
transform_counts = {plugin: len(entries) for plugin, entries in transform.to_dict().items()}
|
||||
note = rule.contents.data.note
|
||||
self.assertIsNotNone(note)
|
||||
note_template = PatchedTemplate(note)
|
||||
|
||||
note_counts = defaultdict(int)
|
||||
for identifier in note_template.get_identifiers():
|
||||
for identifier in identifiers:
|
||||
# "$" is used for other things, so this verifies the pattern of a trailing "_" followed by ints
|
||||
if '_' not in identifier:
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user