File: test_plotutils.py

package info (click to toggle)
orange3 3.40.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 15,908 kB
  • sloc: python: 162,745; ansic: 622; makefile: 322; sh: 93; cpp: 77
file content (25 lines) | stat: -rw-r--r-- 815 bytes parent folder | download | duplicates (2)
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
import unittest
from unittest.mock import patch

import numpy as np
from AnyQt.QtCore import QPointF

from Orange.widgets.visualize.utils.plotutils import InteractiveViewBox


class TestInteractiveViewBox(unittest.TestCase):

    def test_update_scale_box(self):
        view_box = InteractiveViewBox(graph=None)
        with patch.object(view_box, "mapToView", lambda x: x):
            view_box.updateScaleBox(QPointF(0, 0), QPointF(2, 2))
            tr = view_box.rbScaleBox.transform()
            self.assertFalse(tr.isRotating())
            trm = [[tr.m11(), tr.m12(), tr.m13()],
                   [tr.m21(), tr.m22(), tr.m23()],
                   [tr.m31(), tr.m32(), tr.m33()]]
            np.testing.assert_equal(trm, [[2, 0, 0], [0, 2, 0], [0, 0, 1]])


if __name__ == '__main__':
    unittest.main()