Commit 95ad2abd authored by Yori 'AGy' Fournier's avatar Yori 'AGy' Fournier
Browse files

create test100 for MyData and test200 for MyAxes tested and validated.

parent 4e69af9d
......@@ -128,6 +128,14 @@ from .myFig4Test import MyFig4Test
from .myPlot4Test import somePlottingRoutine
from .test import myTest
from .test import test400, test300, test401, test402
testList = [test400, test300, test401, test402]
from .test import test100
from .test import test200
from .test import test300
from .test import test400, test401, test402
testList = [test100,
test200,
test300,
test400,
test401,
test402]
from . import readStupidData, readStupidData2
from . import MyFig, MyWin
from . import SEVR, WARN, DBUG
from . import SEVR, WARN, DBUG, SPCE
from . import _G_WINDOWS
......@@ -35,28 +35,116 @@ def myTest(function, expected, failed, debug):
# TEST 4.* for testing MyWin
# TEST 4.00: test create of MyFig and PRINT TO SCREEN (EXPECTED: TRUE)
def test400(debug):
# TEST 1.00: test the Data Structure (EXPECTED: TRUE)
def test100(debug):
status = True
from . import MyData
data1 = readStupidData('data1')
fig = MyFig(inputarg=data1)
win = MyWin(fig)
data = MyData()
try:
if win.canvas.figure.keywords['debug']:
pass
if data.name == 'default':
status = True
except:
print(SEVR + "I can not access the figure from the manager...")
else:
status = False
win.close()
del win
del fig
del data1
if data.data is None:
status = True
else:
status = False
return(status)
# TEST 2.00: test MyAxes Constructor
#
# REMARK: Require to test MyFig First
#
def test200(debug):
# local import
from . import MyData, MyFig, MyAxes
from . import rcParams
# set some global variable for the test
rcParams['font.size'] = 22
MyFig.FIGSIZE = (8., 6.)
# create stupid data
data = MyData()
data.data = [[0, 0], [1, 1]] # Dummy data
# create a figure
fig = MyFig(inputarg=data, dpi=75.)
# set ratio and frameRect
ratio = 4. / 6. # float
frameRect = [0, 0, 0.5, 1.0] # [x0, y0, x1, y1]
# create the MyAxes object.
ax = MyAxes(fig, ratio, frameRect)
# Some debug info if needed
if(debug):
# supposed values
# figWidth = 8.
# figHeight = 6.
# figDpi = 75.
print
print(DBUG + "figWidth = " + str(fig.get_figwidth()) + " should be 8.")
print(SPCE + "figHeight = " + str(fig.get_figheight()) + " should be 6.")
print(SPCE + "figDpi = " + str(fig.get_dpi()) + " should be 75.")
print(SPCE + "ratio = " + str(ratio) + " should be 4. / 6. = 0.6666...")
print
# fontsize = 22 / 75
print(DBUG + "fontsize = " + str(rcParams['font.size'] / 75.) + " should be 22. / 75. = 0.2933..")
print
# maxWidth = 8. * 0.5 - 8. * 22 / 75 = 124 / 75
# maxHeight = 6. * 1.0 - 4 * 22 / 75 = 362 / 75
print(DBUG + "maxHeight = " + str(fig.get_figheight() * frameRect[3] - 4. * rcParams['font.size'] / fig.get_dpi()) + " should be 362 / 75 = 4.82666...")
print(SPCE + "maxWidth = " + str(fig.get_figwidth() * frameRect[2] - 8. * rcParams['font.size'] / fig.get_dpi()) + " should be 124 / 75 = 1.65333...")
print
# hypoWidth = 362 / 75 / (4. / 6.) = 7.24
# hypoHeight = 124 / 75 * (4. / 6.) = 496 / 450
print(DBUG + "hypoWidth = " + str((fig.get_figheight() * frameRect[3] - 4. * rcParams['font.size'] / fig.get_dpi()) / ratio) + " should be 7.24")
print(SPCE + "hypoHeight = " + str((fig.get_figwidth() * frameRect[2] - 8. * rcParams['font.size'] / fig.get_dpi()) * ratio) + " should be 496 /450 = 1.10222...")
print
# hypoWidth > maxWidth --> Fit Height
print(DBUG + "hypoWidth should be > maxWidth.")
print
# height = 496 / 450 / 6. = 0.183...
# width = 124 / 75 / 8. = 0.62 / 3. = 0.206...
# posX = 4 * 22 / 75 / 8 = 11 / 75 = 0.1466...
# posY = 3 * 22 / 75 / 6 = 11 / 75 = 0.1466...
hypoHeight = (fig.get_figwidth() * frameRect[2] - 8. * rcParams['font.size'] / fig.get_dpi()) * ratio
maxWidth = fig.get_figwidth() * frameRect[2] - 8. * rcParams['font.size'] / fig.get_dpi()
print(DBUG + "height = " + str(hypoHeight / fig.get_figheight()) + " should be " + str(496. / 450. / 6.))
print(SPCE + "width = " + str(maxWidth / fig.get_figwidth()) + " should be 0.2066...")
print
# the expected value for rect
rect = [11. / 75., 11. / 75., 0.62 / 3., 496. / 450. / 6.]
# the value of rect
axRect = [ax._position.x0, ax._position.y0, ax._position.width, ax._position.height]
# debug infos
if(debug):
print(DBUG + "ax._position = \n" +
SPCE + " [ " + str(axRect[0]) + ", \n" +
SPCE + " " + str(axRect[1]) + ", \n" +
SPCE + " " + str(axRect[2]) + ", \n" +
SPCE + " " + str(axRect[3]) + " ] \n")
print(SPCE + "should be equal to: \n" +
SPCE + " [ " + str(rect[0]) + ", \n" +
SPCE + " " + str(rect[1]) + ", \n" +
SPCE + " " + str(rect[2]) + ", \n" +
SPCE + " " + str(rect[3]) + " ] \n")
# if rect has expected value
if axRect == rect:
status = True
else:
status = False
return(status)
......@@ -82,6 +170,32 @@ def test300(debug):
return(status)
# TEST 4.00: test create of MyFig and PRINT TO SCREEN (EXPECTED: TRUE)
def test400(debug):
status = True
data1 = readStupidData('data1')
fig = MyFig(inputarg=data1)
win = MyWin(fig)
try:
if win.canvas.figure.keywords['debug']:
pass
status = True
except:
print(SEVR + "I can not access the figure from the manager...")
status = False
win.close()
del win
del fig
del data1
return(status)
# TEST 401: Verify the well behaving of closeWindow (EXPECTED: TRUE)
def test401(debug):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment