Exemplo n.º 1
0
 def _compute_is_py3o_native_format(self):
     format = Formats()
     for rec in self:
         if not rec.report_type == "py3o":
             filetype = "pdf"
             rec.is_py3o_native_format = format.get_format(filetype).native
             continue
         filetype = rec.py3o_filetype
         if filetype == False:
             filetype = "pdf"
         rec.is_py3o_native_format = format.get_format(filetype).native
Exemplo n.º 2
0
 def _compute_is_py3o_native_format(self):
     format = Formats()
     for rec in self:
         rec.is_py3o_native_format = False
         if not rec.report_type == "py3o" or not rec.py3o_filetype:
             continue
         filetype = rec.py3o_filetype
         rec.is_py3o_native_format = format.get_format(filetype).native
Exemplo n.º 3
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")
Exemplo n.º 4
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
Exemplo n.º 5
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