def test_check_messages_junk(self): bundle = FluentBundle( 'en-US', [FtlResource("unfinished", filename='myfile.ftl')]) checks = bundle.check_messages() self.assertEqual(len(checks), 1) check1_name, check1_error = checks[0] self.assertEqual(check1_name, None) self.assertEqual(type(check1_error), FluentJunkFound) self.assertEqual( check1_error.message, 'Junk found:\n myfile.ftl:1:11: Expected token: "="') self.assertEqual(check1_error.annotations[0].message, 'Expected token: "="')
def test_check_messages_compile_errors(self): bundle = FluentBundle('en-US', [ FtlResource(dedent_ftl(''' foo = { -missing } .bar = { -missing } '''), filename='myfile.ftl') ]) checks = bundle.check_messages() self.assertEqual(len(checks), 2) check1_name, check1_error = checks[0] self.assertEqual(check1_name, 'foo') self.assertEqual(type(check1_error), FluentReferenceError) self.assertEqual(check1_error.args[0], 'myfile.ftl:2:9: Unknown term: -missing') check2_name, check2_error = checks[1] self.assertEqual(check2_name, 'foo.bar') self.assertEqual(type(check2_error), FluentReferenceError) self.assertEqual(check2_error.args[0], 'myfile.ftl:3:14: Unknown term: -missing')