Пример #1
0
    def test_new_from_thumbnail(self):
        "Can't create a document from a thumbnail image"
        with temp_directory_with_files(TESTDATA / 'test_segment.png') as tempdir:
            doc = InselectDocument.new_from_scan(tempdir / 'test_segment.png')
            doc.ensure_thumbnail(width=2048)
            doc = None

            self.assertRaises(InselectError, InselectDocument.new_from_scan,
                              tempdir / 'test_segment_thumbnail.png')
Пример #2
0
    def test_new_from_scan(self):
        "New document is created and saved"
        with temp_directory_with_files(TESTDATA / 'test_segment.png') as tempdir:
            doc = InselectDocument.new_from_scan(tempdir / 'test_segment.png')
            self.assertTrue(doc.document_path.is_file())
            self.assertEqual(tempdir / 'test_segment.png', doc.scanned.path)

            # Saved on time should be within last 2 seconds
            now = datetime.now(pytz.timezone("UTC"))
            created_on = doc.properties['Created on']
            self.assertLessEqual((now - created_on).seconds, 2)
Пример #3
0
 def test_new_from_thumbnail(self):
     "Can't create a document from a thumbnail image"
     with temp_directory_with_files(TESTDATA / 'shapes.png') as tempdir:
         doc = InselectDocument.new_from_scan(tempdir / 'shapes.png',
                                              thumbnail_width_pixels=2048)
         thumbnail = tempdir / 'shapes_thumbnail.jpg'
         self.assertTrue(thumbnail.is_file())
         self.assertTrue(doc.thumbnail.available)
         self.assertEqual(2048, doc.thumbnail.array.shape[1])
         self.assertRaises(InselectError, InselectDocument.new_from_scan,
                           thumbnail)
Пример #4
0
    def test_new_from_scan(self):
        "New document is created and saved"
        with temp_directory_with_files(TESTDATA / 'shapes.png') as tempdir:
            doc = InselectDocument.new_from_scan(tempdir / 'shapes.png')
            self.assertTrue(doc.document_path.is_file())
            self.assertEqual(tempdir / 'shapes.png', doc.scanned.path)

            # Saved on time should be within last 2 seconds
            now = datetime.now(pytz.timezone("UTC"))
            created_on = doc.properties['Created on']
            self.assertLessEqual((now - created_on).seconds, 2)
Пример #5
0
 def test_new_from_thumbnail(self):
     "Can't create a document from a thumbnail image"
     with temp_directory_with_files(TESTDATA / 'test_segment.png') as tempdir:
         doc = InselectDocument.new_from_scan(
             tempdir / 'test_segment.png',
             thumbnail_width_pixels=2048
         )
         thumbnail = tempdir / 'test_segment_thumbnail.jpg'
         self.assertTrue(thumbnail.is_file())
         self.assertEqual(2048, doc.thumbnail.array.shape[1])
         self.assertRaises(InselectError, InselectDocument.new_from_scan,
                           thumbnail)
Пример #6
0
 def test_new_from_scan(self):
     "New document is created and saved"
     with temp_directory_with_files(TESTDATA / 'test_segment.png') as tempdir:
         doc = InselectDocument.new_from_scan(tempdir / 'test_segment.png')
         self.assertTrue(doc.document_path.is_file())
         self.assertEqual(tempdir / 'test_segment.png', doc.scanned.path)