'Test _check_mako_file_is_safe in mixed contexts provides
appropriate violations'

def test_check_mako_expressions_in_mixed_contexts(self):

    linter = MakoTemplateLinter()
    results = FileResults('')
    mako_template = textwrap.dedent('\n                                                <%page    expression_filter="h"/>\n                                                ${x    |    h}\n                                                <script    type="text/javascript">\n                                                                ${x    |    h}\n                                                </script>\n                                                ${x    |    h}\n                                                <%static:require_module    module_name="${x}"    class_name="TestFactory">\n                                                                ${x    |    h}\n                                                </%static:require_module>\n                                                ${x    |    h}\n                                ')
    linter._check_mako_file_is_safe(mako_template, results)
    self.assertEqual(len(results.violations), 5)
    self.assertEqual(results.violations[0].rule, Rules.mako_unwanted_html_filter)
    self.assertEqual(results.violations[1].rule, Rules.mako_invalid_js_filter)
    self.assertEqual(results.violations[2].rule, Rules.mako_unwanted_html_filter)
    self.assertEqual(results.violations[3].rule, Rules.mako_invalid_js_filter)
    self.assertEqual(results.violations[4].rule, Rules.mako_unwanted_html_filter)
