forked from RyanBalfanz/PyPDS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
50 lines (40 loc) · 1.19 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python2.6
# encoding: utf-8
"""
tests.py
Created by Balfanz, Ryan on 2010-09-19.
Copyright (c) 2010 __MyCompanyName__. All rights reserved.
"""
import os
import unittest
from pds.core.common import open_pds
from pds.core.parser import Parser
from pds.imageextractor import ImageExtractor
class untitledTests(unittest.TestCase):
def setUp(self):
self.parser = Parser()
self.imageExtractor = ImageExtractor()
self.testImagePath = "./I18584006BTR.IMG"
assert os.path.exists(self.testImagePath)
def test_open_pds(self):
"""docstring for test_open_pds_file"""
p = self.parser
try:
f = open_pds(self.testImagePath)
p.parse(f)
except:
raise
def test_get_labels(self):
"""docstring for test_get_labels"""
p = self.parser
labels = p.parse(open_pds(self.testImagePath))
self.assertNotEqual(None, labels)
def test_get_image(self):
"""docstring for test_get_image"""
ie = self.imageExtractor
img, labels = ie.extract(open_pds(self.testImagePath))
self.assertNotEqual(None, img)
imageSize = map(int, (labels["IMAGE"]["LINE_SAMPLES"], labels["IMAGE"]["LINES"]))
self.assertEqual(tuple(imageSize), img.size)
if __name__ == '__main__':
unittest.main()