Exemplo n.º 1
0
 def test_choice_field(self):
     # Have to use create here because of how field generation works
     choice = ChoiceOptionFactory.create()
     field = choice.field
     dj_field = field.get_django_field()
     assert_true(isinstance(dj_field, forms.ChoiceField))
     assert_equal(choice.name, dj_field.choices[-1][1])
Exemplo n.º 2
0
    def test_decode(self):
        context = Context()
        document = context.new_document(FileUri(images + 'test1.djvu'))
        message = document.get_message()
        assert_equal(type(message), DocInfoMessage)
        page_job = document.pages[0].decode()
        assert_true(page_job.is_done)
        assert_equal(type(page_job), PageJob)
        assert_true(page_job.is_done)
        assert_false(page_job.is_error)
        assert_equal(page_job.status, JobOK)
        assert_equal(page_job.width, 64)
        assert_equal(page_job.height, 48)
        assert_equal(page_job.size, (64, 48))
        assert_equal(page_job.dpi, 300)
        assert_equal(page_job.gamma, 2.2)
        assert_equal(page_job.version, 24)
        assert_equal(page_job.type, PAGE_TYPE_BITONAL)
        assert_equal((page_job.rotation, page_job.initial_rotation), (0, 0))
        with assert_raises_str(ValueError, 'rotation must be equal to 0, 90, 180, or 270'):
            page_job.rotation = 100
        page_job.rotation = 180
        assert_equal((page_job.rotation, page_job.initial_rotation), (180, 0))
        del page_job.rotation
        assert_equal((page_job.rotation, page_job.initial_rotation), (0, 0))

        with assert_raises_str(ValueError, 'page_rect width/height must be a positive integer'):
            page_job.render(RENDER_COLOR, (0, 0, -1, -1), (0, 0, 10, 10), PixelFormatRgb())

        with assert_raises_str(ValueError, 'render_rect width/height must be a positive integer'):
            page_job.render(RENDER_COLOR, (0, 0, 10, 10), (0, 0, -1, -1), PixelFormatRgb())

        with assert_raises_str(ValueError, 'render_rect must be inside page_rect'):
            page_job.render(RENDER_COLOR, (0, 0, 10, 10), (2, 2, 10, 10), PixelFormatRgb())

        with assert_raises_str(ValueError, 'row_alignment must be a positive integer'):
            page_job.render(RENDER_COLOR, (0, 0, 10, 10), (0, 0, 10, 10), PixelFormatRgb(), -1)

        with assert_raises_regex(MemoryError, r'\AUnable to allocate [0-9]+ bytes for an image memory\Z'):
            x = int((sys.maxsize // 2) ** 0.5)
            page_job.render(RENDER_COLOR, (0, 0, x, x), (0, 0, x, x), PixelFormatRgb(), 8)

        s = page_job.render(RENDER_COLOR, (0, 0, 10, 10), (0, 0, 4, 4), PixelFormatGrey(), 1)
        assert_equal(s, b'\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xEF\xFF\xFF\xFF\xA4\xFF\xFF\xFF\xB8')

        buffer = array.array('B', b'\0')
        with assert_raises_str(ValueError, 'Image buffer is too small (16 > 1)'):
            page_job.render(RENDER_COLOR, (0, 0, 10, 10), (0, 0, 4, 4), PixelFormatGrey(), 1, buffer)

        buffer = array.array('B', b'\0' * 16)
        assert_is(page_job.render(RENDER_COLOR, (0, 0, 10, 10), (0, 0, 4, 4), PixelFormatGrey(), 1, buffer), buffer)
        s = array_tobytes(buffer)
        assert_equal(s, b'\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xEF\xFF\xFF\xFF\xA4\xFF\xFF\xFF\xB8')
Exemplo n.º 3
0
 def test_export_ps(self):
     skip_unless_command_exists('ps2ascii')
     context = Context()
     document = context.new_document(FileUri(images + 'test0.djvu'))
     message = document.get_message()
     assert_equal(type(message), DocInfoMessage)
     assert_true(document.decoding_done)
     assert_false(document.decoding_error)
     assert_equal(document.decoding_status, JobOK)
     assert_equal(document.type, DOCUMENT_TYPE_BUNDLED)
     assert_equal(len(document.pages), 2)
     assert_equal(len(document.files), 3)
     with tempfile.NamedTemporaryFile() as tmp:
         job = document.export_ps(tmp.file)
         assert_equal(type(job), SaveJob)
         assert_true(job.is_done)
         assert_false(job.is_error)
         stdout, stderr = run('ps2ascii', tmp.name, LC_ALL='C')
         assert_equal(stderr, b'')
         stdout = re.sub(br'[\x00\s]+', b' ', stdout)
         assert_equal(stdout, b' ')
     with tempfile.NamedTemporaryFile() as tmp:
         job = document.export_ps(tmp.file, pages=(0, ), text=True)
         assert_equal(type(job), SaveJob)
         assert_true(job.is_done)
         assert_false(job.is_error)
         stdout, stderr = run('ps2ascii', tmp.name, LC_ALL='C')
         assert_equal(stderr, b'')
         stdout = stdout.decode('ASCII')
         stdout = re.sub(r'[\x00\s]+', ' ', stdout)
         stdout = ' '.join(stdout.split()[:3])
         expected = '1 Lorem ipsum'
         assert_multi_line_equal(stdout, expected)
Exemplo n.º 4
0
 def test_export_ps(self):
     skip_unless_command_exists('ps2ascii')
     context = Context()
     document = context.new_document(FileUri(images + 'test0.djvu'))
     message = document.get_message()
     assert_equal(type(message), DocInfoMessage)
     assert_true(document.decoding_done)
     assert_false(document.decoding_error)
     assert_equal(document.decoding_status, JobOK)
     assert_equal(document.type, DOCUMENT_TYPE_BUNDLED)
     assert_equal(len(document.pages), 2)
     assert_equal(len(document.files), 3)
     with tempfile.NamedTemporaryFile() as tmp:
         job = document.export_ps(tmp.file)
         assert_equal(type(job), SaveJob)
         assert_true(job.is_done)
         assert_false(job.is_error)
         stdout, stderr = run('ps2ascii', tmp.name, LC_ALL='C')
         assert_equal(stderr, b'')
         stdout = re.sub(br'[\x00\s]+', b' ', stdout)
         assert_equal(stdout, b' ')
     with tempfile.NamedTemporaryFile() as tmp:
         job = document.export_ps(tmp.file, pages=(0,), text=True)
         assert_equal(type(job), SaveJob)
         assert_true(job.is_done)
         assert_false(job.is_error)
         stdout, stderr = run('ps2ascii', tmp.name, LC_ALL='C')
         assert_equal(stderr, b'')
         stdout = stdout.decode('ASCII')
         stdout = re.sub(r'[\x00\s]+', ' ', stdout)
         stdout = ' '.join(stdout.split()[:3])
         expected = '1 Lorem ipsum'
         assert_multi_line_equal(stdout, expected)
Exemplo n.º 5
0
 def test_widgets_in_fieldsets(self):
     widget = WidgetFactory.create()
     fieldset = FieldsetFactory.create()
     field1 = FieldFactory.create(fieldset=fieldset, widget=widget, form=fieldset.form)
     field2 = FieldFactory.create(fieldset=fieldset, widget=widget, form=fieldset.form)
     layout = fieldset.form.get_layout()
     assert_equal(len(layout), 1)
     assert_true(isinstance(layout[0], LayoutFieldset))
     assert_equal(len(layout[0].fields), 1)
     layout_widget = layout[0].fields[0]
     assert_true(isinstance(layout_widget, Div))
     assert_equal(layout_widget.css_class, widget.widget_type)
     assert_true(field1.key in layout_widget.fields)
     assert_true(field2.key in layout_widget.fields)
Exemplo n.º 6
0
    def test_decode(self):
        context = Context()
        document = context.new_document(FileUri(images + 'test1.djvu'))
        message = document.get_message()
        assert_equal(type(message), DocInfoMessage)
        page_job = document.pages[0].decode()
        assert_true(page_job.is_done)
        assert_equal(type(page_job), PageJob)
        assert_true(page_job.is_done)
        assert_false(page_job.is_error)
        assert_equal(page_job.status, JobOK)
        assert_equal(page_job.width, 64)
        assert_equal(page_job.height, 48)
        assert_equal(page_job.size, (64, 48))
        assert_equal(page_job.dpi, 300)
        assert_equal(page_job.gamma, 2.2)
        assert_equal(page_job.version, 24)
        assert_equal(page_job.type, PAGE_TYPE_BITONAL)
        assert_equal((page_job.rotation, page_job.initial_rotation), (0, 0))
        with assert_raises_str(ValueError,
                               'rotation must be equal to 0, 90, 180, or 270'):
            page_job.rotation = 100
        page_job.rotation = 180
        assert_equal((page_job.rotation, page_job.initial_rotation), (180, 0))
        del page_job.rotation
        assert_equal((page_job.rotation, page_job.initial_rotation), (0, 0))

        with assert_raises_str(
                ValueError,
                'page_rect width/height must be a positive integer'):
            page_job.render(RENDER_COLOR, (0, 0, -1, -1), (0, 0, 10, 10),
                            PixelFormatRgb())

        with assert_raises_str(
                ValueError,
                'render_rect width/height must be a positive integer'):
            page_job.render(RENDER_COLOR, (0, 0, 10, 10), (0, 0, -1, -1),
                            PixelFormatRgb())

        with assert_raises_str(ValueError,
                               'render_rect must be inside page_rect'):
            page_job.render(RENDER_COLOR, (0, 0, 10, 10), (2, 2, 10, 10),
                            PixelFormatRgb())

        with assert_raises_str(ValueError,
                               'row_alignment must be a positive integer'):
            page_job.render(RENDER_COLOR, (0, 0, 10, 10), (0, 0, 10, 10),
                            PixelFormatRgb(), -1)

        with assert_raises_regex(
                MemoryError,
                r'\AUnable to allocate [0-9]+ bytes for an image memory\Z'):
            x = int((sys.maxsize // 2)**0.5)
            page_job.render(RENDER_COLOR, (0, 0, x, x), (0, 0, x, x),
                            PixelFormatRgb(), 8)

        s = page_job.render(RENDER_COLOR, (0, 0, 10, 10), (0, 0, 4, 4),
                            PixelFormatGrey(), 1)
        assert_equal(
            s,
            b'\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xEF\xFF\xFF\xFF\xA4\xFF\xFF\xFF\xB8'
        )

        buffer = array.array('B', b'\0')
        with assert_raises_str(ValueError,
                               'Image buffer is too small (16 > 1)'):
            page_job.render(RENDER_COLOR, (0, 0, 10, 10), (0, 0, 4, 4),
                            PixelFormatGrey(), 1, buffer)

        buffer = array.array('B', b'\0' * 16)
        assert_is(
            page_job.render(RENDER_COLOR, (0, 0, 10, 10), (0, 0, 4, 4),
                            PixelFormatGrey(), 1, buffer), buffer)
        s = array_tobytes(buffer)
        assert_equal(
            s,
            b'\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xEF\xFF\xFF\xFF\xA4\xFF\xFF\xFF\xB8'
        )
Exemplo n.º 7
0
 def test_save(self):
     skip_unless_command_exists('djvudump')
     context = Context()
     original_filename = images + 'test0.djvu'
     document = context.new_document(FileUri(original_filename))
     message = document.get_message()
     assert_equal(type(message), DocInfoMessage)
     assert_true(document.decoding_done)
     assert_false(document.decoding_error)
     assert_equal(document.decoding_status, JobOK)
     assert_equal(document.type, DOCUMENT_TYPE_BUNDLED)
     assert_equal(len(document.pages), 2)
     assert_equal(len(document.files), 3)
     (stdout0, stderr0) = run('djvudump', original_filename, LC_ALL='C')
     assert_equal(stderr0, b'')
     stdout0 = stdout0.replace(b'\r\n', b'\n')
     tmpdir = tempfile.mkdtemp()
     try:
         tmp = open(os.path.join(tmpdir, 'tmp.djvu'), 'wb')
         job = document.save(tmp)
         assert_equal(type(job), SaveJob)
         assert_true(job.is_done)
         assert_false(job.is_error)
         tmp.close()
         (stdout, stderr) = run('djvudump', tmp.name, LC_ALL='C')
         assert_equal(stderr, b'')
         stdout = stdout.replace(b'\r\n', b'\n')
         assert_equal(stdout, stdout0)
     finally:
         shutil.rmtree(tmpdir)
         tmp = None
     tmpdir = tempfile.mkdtemp()
     try:
         tmp = open(os.path.join(tmpdir, 'tmp.djvu'), 'wb')
         job = document.save(tmp, pages=(0, ))
         assert_equal(type(job), SaveJob)
         assert_true(job.is_done)
         assert_false(job.is_error)
         tmp.close()
         stdout, stderr = run('djvudump', tmp.name, LC_ALL='C')
         assert_equal(stderr, b'')
         stdout = stdout.replace(b'\r\n', b'\n')
         stdout0 = stdout0.split(b'\n')
         stdout = stdout.split(b'\n')
         stdout[4] = stdout[4].replace(b' (1)', b'')
         assert_equal(len(stdout), 10)
         assert_equal(stdout[3:-1], stdout0[4:10])
         assert_equal(stdout[-1], b'')
     finally:
         shutil.rmtree(tmpdir)
         tmp = None
     tmpdir = tempfile.mkdtemp()
     try:
         tmpfname = os.path.join(tmpdir, 'index.djvu')
         job = document.save(indirect=tmpfname)
         assert_equal(type(job), SaveJob)
         assert_true(job.is_done)
         assert_false(job.is_error)
         (stdout, stderr) = run('djvudump', tmpfname, LC_ALL='C')
         assert_equal(stderr, b'')
         stdout = stdout.replace(b'\r\n', b'\n')
         stdout = stdout.split(b'\n')
         stdout0 = ([b'      shared_anno.iff -> shared_anno.iff'] + [
             b('      p{n:04}.djvu -> p{n:04}.djvu'.format(n=n))
             for n in range(1, 3)
         ])
         assert_equal(len(stdout), 7)
         assert_equal(stdout[2:-2], stdout0)
         assert_equal(stdout[-1], b'')
     finally:
         shutil.rmtree(tmpdir)
     tmpdir = tempfile.mkdtemp()
     try:
         tmpfname = os.path.join(tmpdir, 'index.djvu')
         job = document.save(indirect=tmpfname, pages=(0, ))
         assert_equal(type(job), SaveJob)
         assert_true(job.is_done)
         assert_false(job.is_error)
         (stdout, stderr) = run('djvudump', tmpfname, LC_ALL='C')
         stdout = stdout.replace(b'\r\n', b'\n')
         assert_equal(stderr, b'')
         stdout = stdout.split(b'\n')
         assert_equal(len(stdout), 5)
         assert_equal(stdout[2],
                      b'      shared_anno.iff -> shared_anno.iff')
         assert_equal(stdout[3], b'      p0001.djvu -> p0001.djvu')
         assert_equal(stdout[-1], b'')
     finally:
         shutil.rmtree(tmpdir)
Exemplo n.º 8
0
 def test_new_document(self):
     context = Context()
     document = context.new_document(FileUri(images + 'test1.djvu'))
     assert_equal(type(document), Document)
     message = document.get_message()
     assert_equal(type(message), DocInfoMessage)
     assert_true(document.decoding_done)
     assert_false(document.decoding_error)
     assert_equal(document.decoding_status, JobOK)
     assert_equal(document.type, DOCUMENT_TYPE_SINGLE_PAGE)
     assert_equal(len(document.pages), 1)
     assert_equal(len(document.files), 1)
     decoding_job = document.decoding_job
     assert_true(decoding_job.is_done)
     assert_false(decoding_job.is_error)
     assert_equal(decoding_job.status, JobOK)
     file = document.files[0]
     assert_is(type(file), File)
     assert_is(file.document, document)
     assert_is(file.get_info(), None)
     assert_equal(file.type, 'P')
     assert_equal(file.n_page, 0)
     page = file.page
     assert_equal(type(page), Page)
     assert_is(page.document, document)
     assert_equal(page.n, 0)
     assert_is(file.size, None)
     assert_equal(file.id, u('test1.djvu'))
     assert_equal(type(file.id), unicode)
     assert_equal(file.name, u('test1.djvu'))
     assert_equal(type(file.name), unicode)
     assert_equal(file.title, u('test1.djvu'))
     assert_equal(type(file.title), unicode)
     dump = document.files[0].dump
     assert_equal(type(dump), unicode)
     assert_equal([line for line in dump.splitlines()], [
         u('  FORM:DJVU [83] '),
         u('    INFO [10]         DjVu 64x48, v24, 300 dpi, gamma=2.2'),
         u('    Sjbz [53]         JB2 bilevel data'),
     ])
     page = document.pages[0]
     assert_equal(type(page), Page)
     assert_is(page.document, document)
     assert_is(page.get_info(), None)
     assert_equal(page.width, 64)
     assert_equal(page.height, 48)
     assert_equal(page.size, (64, 48))
     assert_equal(page.dpi, 300)
     assert_equal(page.rotation, 0)
     assert_equal(page.version, 24)
     file = page.file
     assert_equal(type(file), File)
     assert_equal(file.id, u('test1.djvu'))
     assert_equal(type(file.id), unicode)
     dump = document.files[0].dump
     assert_equal(type(dump), unicode)
     assert_equal([line for line in dump.splitlines()], [
         u('  FORM:DJVU [83] '),
         u('    INFO [10]         DjVu 64x48, v24, 300 dpi, gamma=2.2'),
         u('    Sjbz [53]         JB2 bilevel data'),
     ])
     assert_is(document.get_message(wait=False), None)
     assert_is(context.get_message(wait=False), None)
     with assert_raises_str(IndexError, 'file number out of range'):
         document.files[-1].get_info()
     assert_is(document.get_message(wait=False), None)
     assert_is(context.get_message(wait=False), None)
     with assert_raises_str(IndexError, 'page number out of range'):
         document.pages[-1]
     with assert_raises_str(IndexError, 'page number out of range'):
         document.pages[1]
     assert_is(document.get_message(wait=False), None)
     assert_is(context.get_message(wait=False), None)
Exemplo n.º 9
0
 def test_save(self):
     skip_unless_command_exists('djvudump')
     context = Context()
     original_filename = images + 'test0.djvu'
     document = context.new_document(FileUri(original_filename))
     message = document.get_message()
     assert_equal(type(message), DocInfoMessage)
     assert_true(document.decoding_done)
     assert_false(document.decoding_error)
     assert_equal(document.decoding_status, JobOK)
     assert_equal(document.type, DOCUMENT_TYPE_BUNDLED)
     assert_equal(len(document.pages), 2)
     assert_equal(len(document.files), 3)
     (stdout0, stderr0) = run('djvudump', original_filename, LC_ALL='C')
     assert_equal(stderr0, b'')
     stdout0 = stdout0.replace(b'\r\n', b'\n')
     tmpdir = tempfile.mkdtemp()
     try:
         tmp = open(os.path.join(tmpdir, 'tmp.djvu'), 'wb')
         job = document.save(tmp)
         assert_equal(type(job), SaveJob)
         assert_true(job.is_done)
         assert_false(job.is_error)
         tmp.close()
         (stdout, stderr) = run('djvudump', tmp.name, LC_ALL='C')
         assert_equal(stderr, b'')
         stdout = stdout.replace(b'\r\n', b'\n')
         assert_equal(stdout, stdout0)
     finally:
         shutil.rmtree(tmpdir)
         tmp = None
     tmpdir = tempfile.mkdtemp()
     try:
         tmp = open(os.path.join(tmpdir, 'tmp.djvu'), 'wb')
         job = document.save(tmp, pages=(0,))
         assert_equal(type(job), SaveJob)
         assert_true(job.is_done)
         assert_false(job.is_error)
         tmp.close()
         stdout, stderr = run('djvudump', tmp.name, LC_ALL='C')
         assert_equal(stderr, b'')
         stdout = stdout.replace(b'\r\n', b'\n')
         stdout0 = stdout0.split(b'\n')
         stdout = stdout.split(b'\n')
         stdout[4] = stdout[4].replace(b' (1)', b'')
         assert_equal(len(stdout), 10)
         assert_equal(stdout[3:-1], stdout0[4:10])
         assert_equal(stdout[-1], b'')
     finally:
         shutil.rmtree(tmpdir)
         tmp = None
     tmpdir = tempfile.mkdtemp()
     try:
         tmpfname = os.path.join(tmpdir, 'index.djvu')
         job = document.save(indirect=tmpfname)
         assert_equal(type(job), SaveJob)
         assert_true(job.is_done)
         assert_false(job.is_error)
         (stdout, stderr) = run('djvudump', tmpfname, LC_ALL='C')
         assert_equal(stderr, b'')
         stdout = stdout.replace(b'\r\n', b'\n')
         stdout = stdout.split(b'\n')
         stdout0 = (
             [b'      shared_anno.iff -> shared_anno.iff'] +
             [b('      p{n:04}.djvu -> p{n:04}.djvu'.format(n=n)) for n in range(1, 3)]
         )
         assert_equal(len(stdout), 7)
         assert_equal(stdout[2:-2], stdout0)
         assert_equal(stdout[-1], b'')
     finally:
         shutil.rmtree(tmpdir)
     tmpdir = tempfile.mkdtemp()
     try:
         tmpfname = os.path.join(tmpdir, 'index.djvu')
         job = document.save(indirect=tmpfname, pages=(0,))
         assert_equal(type(job), SaveJob)
         assert_true(job.is_done)
         assert_false(job.is_error)
         (stdout, stderr) = run('djvudump', tmpfname, LC_ALL='C')
         stdout = stdout.replace(b'\r\n', b'\n')
         assert_equal(stderr, b'')
         stdout = stdout.split(b'\n')
         assert_equal(len(stdout), 5)
         assert_equal(stdout[2], b'      shared_anno.iff -> shared_anno.iff')
         assert_equal(stdout[3], b'      p0001.djvu -> p0001.djvu')
         assert_equal(stdout[-1], b'')
     finally:
         shutil.rmtree(tmpdir)
Exemplo n.º 10
0
 def test_new_document(self):
     context = Context()
     document = context.new_document(FileUri(images + 'test1.djvu'))
     assert_equal(type(document), Document)
     message = document.get_message()
     assert_equal(type(message), DocInfoMessage)
     assert_true(document.decoding_done)
     assert_false(document.decoding_error)
     assert_equal(document.decoding_status, JobOK)
     assert_equal(document.type, DOCUMENT_TYPE_SINGLE_PAGE)
     assert_equal(len(document.pages), 1)
     assert_equal(len(document.files), 1)
     decoding_job = document.decoding_job
     assert_true(decoding_job.is_done)
     assert_false(decoding_job.is_error)
     assert_equal(decoding_job.status, JobOK)
     file = document.files[0]
     assert_is(type(file), File)
     assert_is(file.document, document)
     assert_is(file.get_info(), None)
     assert_equal(file.type, 'P')
     assert_equal(file.n_page, 0)
     page = file.page
     assert_equal(type(page), Page)
     assert_is(page.document, document)
     assert_equal(page.n, 0)
     assert_is(file.size, None)
     assert_equal(file.id, u('test1.djvu'))
     assert_equal(type(file.id), unicode)
     assert_equal(file.name, u('test1.djvu'))
     assert_equal(type(file.name), unicode)
     assert_equal(file.title, u('test1.djvu'))
     assert_equal(type(file.title), unicode)
     dump = document.files[0].dump
     assert_equal(type(dump), unicode)
     assert_equal(
         [line for line in dump.splitlines()], [
             u('  FORM:DJVU [83] '),
             u('    INFO [10]         DjVu 64x48, v24, 300 dpi, gamma=2.2'),
             u('    Sjbz [53]         JB2 bilevel data'),
         ]
     )
     page = document.pages[0]
     assert_equal(type(page), Page)
     assert_is(page.document, document)
     assert_is(page.get_info(), None)
     assert_equal(page.width, 64)
     assert_equal(page.height, 48)
     assert_equal(page.size, (64, 48))
     assert_equal(page.dpi, 300)
     assert_equal(page.rotation, 0)
     assert_equal(page.version, 24)
     file = page.file
     assert_equal(type(file), File)
     assert_equal(file.id, u('test1.djvu'))
     assert_equal(type(file.id), unicode)
     dump = document.files[0].dump
     assert_equal(type(dump), unicode)
     assert_equal(
         [line for line in dump.splitlines()], [
             u('  FORM:DJVU [83] '),
             u('    INFO [10]         DjVu 64x48, v24, 300 dpi, gamma=2.2'),
             u('    Sjbz [53]         JB2 bilevel data'),
         ]
     )
     assert_is(document.get_message(wait=False), None)
     assert_is(context.get_message(wait=False), None)
     with assert_raises_str(IndexError, 'file number out of range'):
         document.files[-1].get_info()
     assert_is(document.get_message(wait=False), None)
     assert_is(context.get_message(wait=False), None)
     with assert_raises_str(IndexError, 'page number out of range'):
         document.pages[-1]
     with assert_raises_str(IndexError, 'page number out of range'):
         document.pages[1]
     assert_is(document.get_message(wait=False), None)
     assert_is(context.get_message(wait=False), None)
Exemplo n.º 11
0
 def test_simple_form(self):
     form = FormFactory.build()
     dj_form = form.get_django_form_class()
     assert_true(issubclass(dj_form, forms.Form))
Exemplo n.º 12
0
 def test_choice_field(self):
     field = FieldFactory.build(field_type='char')
     assert_true(isinstance(field.get_django_field(), forms.CharField))
Exemplo n.º 13
0
 def test_percentage_field(self):
     field = FieldFactory.build(field_type='percentage')
     assert_true(isinstance(field.get_django_field(), forms.FloatField))
Exemplo n.º 14
0
 def test_number_field(self):
     field = FieldFactory.build(field_type='number')
     assert_true(isinstance(field.get_django_field(), forms.IntegerField))