Beispiel #1
0
 def test_real_file(self):
     """Test against the real file if pdfjs was found."""
     try:
         pdfjs.get_pdfjs_res_and_path('build/pdf.js')
     except pdfjs.PDFJSNotFound:
         pytest.skip("No pdfjs found")
     ver = version._pdfjs_version()
     assert ver.split()[0] not in ['no', 'unknown'], ver
    def test_known(self, monkeypatch):
        pdfjs_code = textwrap.dedent("""
            // Initializing PDFJS global object (if still undefined)
            if (typeof PDFJS === 'undefined') {
              (typeof window !== 'undefined' ? window : this).PDFJS = {};
            }

            PDFJS.version = '1.2.109';
            PDFJS.build = '875588d';

            (function pdfjsWrapper() {
              // Use strict in our context only - users might not want it
              'use strict';
        """).strip().encode('utf-8')
        monkeypatch.setattr('qutebrowser.utils.version.pdfjs.get_pdfjs_res',
                            lambda path: pdfjs_code)
        assert version._pdfjs_version() == '1.2.109'
Beispiel #3
0
    def test_known(self, monkeypatch, varname):
        pdfjs_code = textwrap.dedent("""
            // Initializing PDFJS global object (if still undefined)
            if (typeof PDFJS === 'undefined') {
              (typeof window !== 'undefined' ? window : this).PDFJS = {};
            }

            VARNAME = '1.2.109';
            PDFJS.build = '875588d';

            (function pdfjsWrapper() {
              // Use strict in our context only - users might not want it
              'use strict';
        """.replace('VARNAME', varname)).strip().encode('utf-8')
        monkeypatch.setattr(
            'qutebrowser.utils.version.pdfjs.get_pdfjs_res_and_path',
            lambda path: (pdfjs_code, '/foo/bar/pdf.js'))
        assert version._pdfjs_version() == '1.2.109 (/foo/bar/pdf.js)'
Beispiel #4
0
 def test_unknown(self, monkeypatch):
     monkeypatch.setattr(
         'qutebrowser.utils.version.pdfjs.get_pdfjs_res_and_path',
         lambda path: (b'foobar', None))
     assert version._pdfjs_version() == 'unknown (bundled)'
Beispiel #5
0
 def test_not_found(self, mocker):
     mocker.patch('qutebrowser.utils.version.pdfjs.get_pdfjs_res_and_path',
                  side_effect=pdfjs.PDFJSNotFound('/build/pdf.js'))
     assert version._pdfjs_version() == 'no'
 def test_unknown(self, monkeypatch):
     monkeypatch.setattr('qutebrowser.utils.version.pdfjs.get_pdfjs_res',
                         lambda path: b'foobar')
     assert version._pdfjs_version() == 'unknown'
 def test_not_found(self, mocker):
     mocker.patch('qutebrowser.utils.version.pdfjs.get_pdfjs_res',
                  side_effect=pdfjs.PDFJSNotFound)
     assert version._pdfjs_version() == 'no'
Beispiel #8
0
 def test_not_found(self, mocker):
     mocker.patch('qutebrowser.utils.version.pdfjs.get_pdfjs_res_and_path',
                  side_effect=pdfjs.PDFJSNotFound('/build/pdf.js'))
     assert version._pdfjs_version() == 'no'