'Test _check_mako_file_is_safe with different page defaults'

@data({'template': '\n    <%page    expression_filter="h"/>', 'rule': None}, {'template': '\n    <%page    args="section_data"    expression_filter="h"    />    ', 'rule': None}, {'template': '\n    ##    <%page    expression_filter="h"/>', 'rule': Rules.mako_missing_default}, {'template': '\n    <%page    expression_filter="h"    />    \n    <%page    args="section_data"/>', 'rule': Rules.mako_multiple_page_tags}, {'template': '\n    <%page    expression_filter="h"    />    \n    ##    <%page    args="section_data"/>', 'rule': None}, {'template': '\n    <%page    args="section_data"    />    ', 'rule': Rules.mako_missing_default}, {'template': '\n    <%page    args="section_data"/>    <some-other-tag    expression_filter="h"    />    ', 'rule': Rules.mako_missing_default}, {'template': '\n', 'rule': Rules.mako_missing_default})
def test_check_page_default(self, data):

    linter = MakoTemplateLinter()
    results = FileResults('')
    linter._check_mako_file_is_safe(data['template'], results)
    num_violations = (0 if (data['rule'] is None) else 1)
    self.assertEqual(len(results.violations), num_violations)
    if (num_violations > 0):
        self.assertEqual(results.violations[0].rule, data['rule'])
