Esempio n. 1
0
 def _get_py3o_filetypes(self):
     formats = Formats()
     names = formats.get_known_format_names()
     selections = []
     for name in names:
         description = name
         if formats.get_format(name).native:
             description = description + " " + _("(Native)")
         selections.append((name, description))
     return selections
Esempio n. 2
0
 def test_no_native_format_without_fusion_server(self):
     report = self.env.ref("report_py3o.res_users_report_py3o")
     formats = Formats()
     is_native = formats.get_format(report.py3o_filetype).native
     self.assertTrue(is_native)
     new_format = None
     for name in formats.get_known_format_names():
         format = formats.get_format(name)
         if not format.native:
             new_format = name
             break
     self.assertTrue(new_format)
     with self.assertRaises(ValidationError) as e:
         report.py3o_filetype = new_format
     self.assertEqual(
         e.exception.name, "Can not use not native format in local fusion. "
         "Please specify a Fusion Server")
Esempio n. 3
0
class TestFormats(unittest.TestCase):

    def tearDown(self):
        pass

    def setUp(self):
        self.formats = Formats()

    def test_valid_format(self):
        """test that a valid format can be found"""
        res = self.formats.get_format(FORMAT_PDF)
        assert isinstance(res, Format)

        assert res.name == "pdf"
        assert res.odfname == "writer_pdf_Export"
        assert res.mimetype == "application/pdf"

    @raises(UnkownFormatException)
    def test_invalid(self):
        self.formats.get_format('invalidformat')

    def test_get_format_names(self):
        names = self.formats.get_known_format_names()
        assert FORMAT_PDF in names