-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix pdfinfo.get_pagecount bug. Add unit tests. Bump version.
- Loading branch information
Showing
8 changed files
with
94 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import os | ||
import unittest | ||
|
||
from mglib.pdfinfo import get_pagecount | ||
|
||
BASE_DIR = os.path.dirname( | ||
os.path.abspath(__file__) | ||
) | ||
|
||
DATA_DIR = os.path.join( | ||
BASE_DIR, "data" | ||
) | ||
|
||
|
||
def get_filepath(filename): | ||
return os.path.join(DATA_DIR, filename) | ||
|
||
|
||
class TestPDFinfo(unittest.TestCase): | ||
|
||
def test_basic_pdf(self): | ||
page_count = get_pagecount(get_filepath("berlin.pdf")) | ||
|
||
self.assertEqual( | ||
page_count, | ||
2 | ||
) | ||
|
||
def test_basic_jpeg(self): | ||
page_count = get_pagecount(get_filepath("berlin.jpeg")) | ||
|
||
self.assertEqual( | ||
page_count, | ||
1 | ||
) | ||
|
||
def test_basic_jpg(self): | ||
page_count = get_pagecount(get_filepath("berlin.jpg")) | ||
|
||
self.assertEqual( | ||
page_count, | ||
1 | ||
) | ||
|
||
def test_basic_png(self): | ||
page_count = get_pagecount(get_filepath("berlin.png")) | ||
|
||
self.assertEqual( | ||
page_count, | ||
1 | ||
) | ||
|
||
def test_basic_tiff(self): | ||
# in case input file has extention tiff extension | ||
# it will internally call get_tiff_pagecount method | ||
page_count = get_pagecount(get_filepath("text.tiff")) | ||
|
||
self.assertEqual( | ||
page_count, | ||
2 | ||
) |