def testMissing(self): root = self.createSyntaxTree() with self.assertLogs(level='ERROR') as cm: check_syntax(root, ['MooseApp'], self._cache, object_prefix='source', syntax_prefix='syntax') self.assertIn('missing a markdown file', cm.output[0]) with self.assertLogs(level='WARNING') as cm: check_syntax(root, ['MooseApp'], self._cache, object_prefix='source', syntax_prefix='syntax', allow_missing_markdown=True) self.assertIn('missing a markdown file', cm.output[0])
def testIsStub(self, *args): root = self.createSyntaxTree() with self.assertLogs(level='ERROR') as cm: check_syntax(root, ['MooseApp'], self._cache, object_prefix='source', syntax_prefix='syntax') self.assertIn('is a stub file', cm.output[0]) with self.assertLogs(level='WARNING') as cm: check_syntax(root, ['MooseApp'], self._cache, object_prefix='source', syntax_prefix='syntax', allow_hidden=True) self.assertIn('is a stub file', cm.output[0])
def testDuplicateFiles(self): root = self.createSyntaxTree() with self.assertLogs(level='ERROR') as cm: check_syntax(root, ['MooseApp'], self._cache, object_prefix='source') self.assertIn('Located multiple files for the desired markdown: Kernels/index.md', cm.output[0]) with self.assertLogs(level='WARNING') as cm: check_syntax(root, ['MooseApp'], self._cache, object_prefix='source', allow_duplicate_files=True) self.assertIn('Located multiple files for the desired markdown: Kernels/index.md', cm.output[0])
def testAttributes(self): root = self.createSyntaxTree() check_syntax(root, ['MooseApp'], self._cache, object_prefix='source', syntax_prefix='syntax') self.assertEqual(root(0)['_md_path'], 'syntax/Kernels/index.md') self.assertEqual(root(0)['_md_file'], os.path.join(self.MOOSE_DIR, 'framework', 'doc', 'content', 'syntax', 'Kernels', 'index.md')) self.assertEqual(root(0)['_is_stub'], False) self.assertEqual(root(0,0)['_md_path'], 'source/kernels/Diffusion.md') self.assertEqual(root(0,0)['_md_file'], os.path.join(self.MOOSE_DIR, 'framework', 'doc', 'content', 'source', 'kernels', 'Diffusion.md')) self.assertEqual(root(0,0)['_is_stub'], False)
def testMissingDescription(self): root = self.createSyntaxTree() root(0,0).description = None with self.assertLogs(level='ERROR') as cm: check_syntax(root, ['MooseApp'], self._cache, object_prefix='source', syntax_prefix='syntax') self.assertIn('Diffusion is missing a class description', cm.output[0]) with self.assertLogs(level='WARNING') as cm: check_syntax(root, ['MooseApp'], self._cache, object_prefix='source', syntax_prefix='syntax', allow_missing_description=True) self.assertIn('Diffusion is missing a class description', cm.output[0])
def testNonHideStub(self): root = self.createSyntaxTree() with self.assertLogs(level='ERROR') as cm: check_syntax(root, ['MooseApp'], self._cache, object_prefix='source', syntax_prefix='syntax') self.assertIn('Kernels has a stub markdown page and is not hidden', cm.output[1]) with self.assertLogs(level='WARNING') as cm: check_syntax(root, ['MooseApp'], self._cache, object_prefix='source', syntax_prefix='syntax', allow_non_hidden_stub=True) self.assertIn('Kernels has a stub markdown page and is not hidden', cm.output[1])
def testHidden(self): root = self.createSyntaxTree() root(0, 0).hidden = True with self.assertLogs(level='ERROR') as cm: check_syntax(root, ['MooseApp'], self._cache, object_prefix='source', syntax_prefix='syntax') self.assertIn('Diffusion is marked as hidden', cm.output[0]) with self.assertLogs(level='WARNING') as cm: check_syntax(root, ['MooseApp'], self._cache, object_prefix='source', syntax_prefix='syntax', allow_hidden=True) self.assertIn('Diffusion is marked as hidden', cm.output[0])
def testHideNonStub(self): root = self.createSyntaxTree() root(0, 0).hidden = True with self.assertLogs(level='ERROR') as cm: check_syntax(root, ['MooseApp'], self._cache, object_prefix='source', syntax_prefix='syntax') self.assertIn('Diffusion is hidden but the content is not a stub.', cm.output[1]) with self.assertLogs(level='WARNING') as cm: check_syntax(root, ['MooseApp'], self._cache, object_prefix='source', syntax_prefix='syntax', allow_hidden_non_stub=True) self.assertIn('Diffusion is hidden but the content is not a stub.', cm.output[1])
def testGiantIfStatement(self): root = moosesyntax.SyntaxNode(None, '') syn = moosesyntax.SyntaxNode(root, 'Block') act = moosesyntax.ActionNode(syn, 'AddObject') obj = moosesyntax.ActionNode(syn, 'Object') def reset(): for x in [syn, act, obj]: x['called'] = False x.test = False # Syntax/Object/Action in 'App' reset() act.group = 'App' obj.group = 'App' check_syntax(root, ['App'], []) self.assertTrue(syn['called']) self.assertTrue(act['called']) self.assertTrue(obj['called']) # Syntax/Action in 'App'; Object in 'Other' reset() act.group = 'App' obj.group = 'Other' check_syntax(root, ['App'], []) self.assertFalse(syn['called']) self.assertTrue(act['called']) self.assertFalse(obj['called']) # Syntax/Object/Action in 'App', Object is test reset() act.group = 'App' obj.group = 'App' obj.test = True check_syntax(root, ['App'], []) self.assertTrue(syn['called']) self.assertTrue(act['called']) self.assertFalse(obj['called']) # Syntax/Object/Action in 'App', Object is test, but tests object allowed check_syntax(root, ['App'], [], allow_test_objects=True) self.assertTrue(syn['called']) self.assertTrue(act['called']) self.assertTrue(obj['called']) # Syntax/Action in 'App'; Object in 'Other', check against 'App' reset() syn.group = 'App' act.group = 'App' obj.group = 'Other' check_syntax(root, ['App'], []) self.assertFalse(syn['called']) self.assertTrue(act['called']) self.assertFalse(obj['called']) # Syntax/Action in 'App'; Object in 'Other', check against 'App' and 'Other' check_syntax(root, ['App', 'Other'], []) self.assertTrue(syn['called']) self.assertTrue(act['called']) self.assertTrue(obj['called']) # Syntax/Action in 'App'; Object in 'Other', check against 'App' and 'Other', with Object as test object reset() obj.test = True check_syntax(root, ['App', 'Other'], []) self.assertTrue(syn['called']) self.assertTrue(act['called']) self.assertFalse(obj['called']) # Syntax/Action in 'App'; Object in 'Other', check against 'App' and 'Other', with Object as test object, but allowing test objects check_syntax(root, ['App', 'Other'], [], allow_test_objects=True) self.assertTrue(syn['called']) self.assertTrue(act['called']) self.assertTrue(obj['called'])