forked from diffpy/diffpy.pdfgui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestphaseconfigurepanel.py
86 lines (71 loc) · 2.65 KB
/
testphaseconfigurepanel.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env python
##############################################################################
#
# diffpy.pdfgui Complex Modeling Initiative
# (c) 2019 Brookhaven Science Associates,
# Brookhaven National Laboratory.
# All rights reserved.
#
# File coded by: Pavol Juhas
#
# See AUTHORS.txt for a list of people who contributed.
# See LICENSE.txt for license information.
#
##############################################################################
"""
Unit tests for PhaseConfigurePanel class.
"""
import unittest
import wx
from diffpy.pdfgui.gui.mainframe import MainFrame
from diffpy.pdfgui.gui.phaseconfigurepanel import PhaseConfigurePanel
from diffpy.pdfgui.tests.testutils import GUITestCase, clickcell, datafile, overrideclipboard, tooltiptext
# ----------------------------------------------------------------------------
class TestPhaseConfigurePanel(GUITestCase):
@classmethod
def setUpClass(cls):
GUITestCase.setUpClass()
GUITestCase.setCmdArgs([datafile("lcmo.ddp")])
cls.app = wx.App()
cls.frame = MainFrame(None, -1, "")
tree = cls.frame.treeCtrlMain
fits = tree.GetChildren(tree.root)
phases = tree.GetPhases(fits[0])
cls.frame.makeTreeSelection(phases[0])
return
@classmethod
def tearDownClass(cls):
cls.frame.Close()
cls.app.Destroy()
GUITestCase.tearDownClass()
return
def setUp(self):
self.panel = self.frame.rightPanel.notebook_phase.GetPage(0)
assert isinstance(self.panel, PhaseConfigurePanel)
return
def test_restrictConstrainedParameters(self):
"check restrictConstrainedParameters function"
panel = self.panel
grid = self.panel.gridAtoms
self.assertTrue(panel.textCtrlScaleFactor.IsEditable())
self.assertFalse(panel.textCtrlDelta1.IsEditable())
self.assertTrue(grid.IsReadOnly(0, 1))
self.assertFalse(grid.IsReadOnly(0, 3))
self.assertEqual("@1", tooltiptext(panel.textCtrlA))
return
def test_onCellRightClick(self):
"check right-click handling over the atoms grid."
# disable modal gridAtoms.PopupMenu
ga = self.panel.gridAtoms
ga.PopupMenu = lambda menu, pos: None
try:
with overrideclipboard():
clickcell(ga, "right", 0, 1)
finally:
del ga.PopupMenu
self.assertIsNotNone(self.panel.insertID)
return
# End of class TestPhaseConfigurePanel
# ----------------------------------------------------------------------------
if __name__ == "__main__":
unittest.main()