28 from mock
import patch
32 from PyQt5.uic
import loadUi
33 from PyQt5.QtWidgets
import QWidget, QApplication
35 NAME =
"test_hand_calibration" 36 PKG =
"sr_gui_hand_calibration" 42 self.
app = QApplication(sys.argv)
44 ui_file = os.path.join(rospkg.RosPack().get_path(
'sr_gui_hand_calibration'),
'uis',
'SrHandCalibration.ui')
47 self.
mock_file = tempfile.NamedTemporaryFile(delete=
False)
48 self.mock_file.write(
"""sr_calibrations: [\n""" +
49 """["mock", [[0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]]],\n""" +
51 self.mock_file.write(
"""\n\nsr_calibrations_coupled: [\n""" +
52 """[["mock_1", "mock_2"], [[[0.0, 0.0], 0.0, 0.0]]],\n""" +
54 self.mock_file.close()
57 os.remove(self.mock_file.name)
59 @patch(
'sr_gui_hand_calibration.sr_hand_calibration_model.EtherCAT_Hand_Lib')
62 progress_bar=self._widget.progress)
64 self.assertEquals(self.hand_model.progress_bar.value(), 0)
65 self.hand_model.load(self.mock_file.name)
66 self.assertEquals(self.hand_model.progress_bar.value(), 100)
68 if __name__ ==
"__main__":
69 rospy.init_node(
"test_hand_calibration")
70 rostest.rosrun(PKG, NAME, TestHandCalibration)
def test_progress_bar(self, EtherCAT_Hand_Lib)