/[escript]/trunk/pyvisi/test/python/test_vtk_lib.py
ViewVC logotype

Contents of /trunk/pyvisi/test/python/test_vtk_lib.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 601 - (show annotations)
Fri Mar 17 06:18:25 2006 UTC (13 years, 7 months ago) by gross
File MIME type: text/x-python
File size: 4125 byte(s)
directories are moved around to match escript convention
1 # Copyright (C) 2004 Paul Cochrane
2 #
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17 # $Id: test_vtk_lib.py,v 1.2 2004/11/24 06:24:06 paultcochrane Exp $
18
19 ## @file test_vtk_lib.py
20
21 import unittest
22 import sys,os,string
23 here = os.getcwd() + '/../../'
24 sys.path.append(here)
25 from pyvisi import * # this should import the general stuff from pyvisi
26 # shouldn't that line be from pyvisi import *??
27 from pyvisi.lib.vtk import * # this should import the vtk interface
28
29 from ESyS import *
30 import Finley
31
32 """
33 Class and functions for testing the vtk interface
34 """
35
36 class TestVTK(unittest.TestCase):
37 """
38 The main test class
39 """
40
41 # tests of plots
42 def testAddArrowPlot(self):
43 scene = Scene()
44 plot = scene.addArrowPlot()
45 self.assertEqual(plot.__class__.__name__, 'ArrowPlot')
46
47 def testArrowPlotBases(self):
48 bases = "%s" % ArrowPlot.__bases__
49 self.assertEqual(bases, '<class \'pyvisi.scene.Plot\'>')
50
51 def testArrowPlotSetData(self):
52 scene = Scene()
53 plot = scene.addArrowPlot()
54 data = Finley.Brick(3,5,7).Nodes().getX() # old esys!!
55 self.assert_(plot.setData(data),msg="Failed to set data in ArrowPlot")
56
57 def testAddContourPlot(self):
58 scene = Scene()
59 plot = scene.addContourPlot()
60 self.assertEqual(plot.__class__.__name__, 'ContourPlot')
61
62 def testContourPlotBases(self):
63 bases = "%s" % ContourPlot.__bases__
64 self.assertEqual(bases, '<class \'pyvisi.scene.Plot\'>')
65
66 def testAddLinePlot(self):
67 scene = Scene()
68 plot = scene.addLinePlot()
69 self.assertEqual(plot.__class__.__name__, 'LinePlot')
70
71 def testLinePlotBases(self):
72 bases = "%s" % LinePlot.__bases__
73 self.assertEqual(bases, '<class \'pyvisi.scene.Plot\'>')
74
75 # end of tests of plots
76
77 def testAddAxes(self):
78 scene = Scene()
79 axes = scene.addAxes()
80 self.assertEqual(axes.__class__.__name__, 'Axes')
81
82 def testAxesBases(self):
83 bases = "%s" % Axes.__bases__
84 self.assertEqual(bases, '<class \'pyvisi.scene.Plot\'>')
85
86 def testAddText(self):
87 scene = Scene()
88 text = scene.addText()
89 self.assertEqual(text.__class__.__name__, 'Text')
90
91 def testAddCamera(self):
92 scene = Scene()
93 camera = scene.addCamera()
94 self.assertEqual(camera.__class__.__name__, 'Camera')
95
96 def testAddImage(self):
97 scene = Scene()
98 image = scene.addImage()
99 self.assertEqual(image.__class__.__name__, 'Image')
100
101 def testTextFontAttr(self):
102 # make sure the font attribute exists and is text
103 scene = Scene()
104 text = scene.addText()
105 self.assert_(text.font.isalpha(), \
106 msg='Text font attribute is not text')
107
108 def testTextChangeFont(self):
109 # now try and set the font to something, and see if that works
110 scene = Scene()
111 text = scene.addText()
112 text.font = "Helvetica"
113 self.assertEqual('Helvetica', text.font)
114 self.assertNotEqual('Times', text.font)
115
116 def testTextNotAlphaNum(self):
117 # text to see if when we set the font to alphanumeric that it barfs
118 scene = Scene()
119 text = scene.addText()
120 text.font = "Times2"
121 self.assert_(not text.font.isalpha(), \
122 msg='Text font attribute is supposed to be text not alphanum')
123
124 if __name__ == '__main__':
125 unittest.main()
126
127 # vim: expandtab shiftwidth=4:

  ViewVC Help
Powered by ViewVC 1.1.26