Skip to content

Commit

Permalink
fixed marker tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Chilipp committed Jan 4, 2019
1 parent 074918f commit 23fd504
Showing 1 changed file with 35 additions and 18 deletions.
53 changes: 35 additions & 18 deletions tests/widgets/test_marker_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from psyplot_gui.compat.qtcompat import QTest, Qt
import straditize.cross_mark as cm
import unittest
import pandas as pd


class MarkerControlTest(bt.StraditizeWidgetsTestCase):
Expand Down Expand Up @@ -110,8 +111,10 @@ def test_goto_right_mark_01_single(self):
ax.set_xlim(minx - 1, minx + 1)
ax.set_ylim(miny - 1, miny + 1)
self.marker_control.go_to_right_mark()
self.assertEqual(list(ax.get_xlim()), [maxx - 1, maxx + 1])
self.assertEqual(list(ax.get_ylim()), [maxy - 1, maxy + 1])
xi = pd.Interval(*ax.get_xlim(), closed='both')
self.assertIn(maxx, xi)
yi = pd.Interval(*sorted(ax.get_ylim()), closed='both')
self.assertIn(maxy, yi)

def test_goto_right_mark_02_multi(self):
"""Test the navigation button to the right mark for multiple edges
Expand All @@ -128,8 +131,10 @@ def test_goto_right_mark_02_multi(self):
ax.set_xlim(minx - 1, minx + 1)
ax.set_ylim(miny + 1, miny - 1)
self.marker_control.go_to_right_mark()
self.assertEqual(list(ax.get_xlim()), [maxx - 1, maxx + 1])
self.assertEqual(list(ax.get_ylim()), [miny + 1, miny - 1])
xi = pd.Interval(*ax.get_xlim(), closed='both')
self.assertIn(maxx, xi)
yi = pd.Interval(*sorted(ax.get_ylim()), closed='both')
self.assertIn(miny, yi)

def test_goto_left_mark_01_single(self):
"""Test the navigation button to the right mark for one edge per mark
Expand All @@ -140,8 +145,10 @@ def test_goto_left_mark_01_single(self):
ax.set_xlim(maxx - 1, maxx + 1)
ax.set_ylim(maxy - 1, maxy + 1)
self.marker_control.go_to_left_mark()
self.assertEqual(list(ax.get_xlim()), [minx - 1, minx + 1])
self.assertEqual(list(ax.get_ylim()), [miny - 1, miny + 1])
xi = pd.Interval(*ax.get_xlim(), closed='both')
self.assertIn(minx, xi)
yi = pd.Interval(*sorted(ax.get_ylim()), closed='both')
self.assertIn(miny, yi)

def test_goto_left_mark_02_multi(self):
"""Test the navigation button to the right mark for multiple edges
Expand All @@ -158,20 +165,24 @@ def test_goto_left_mark_02_multi(self):
ax.set_xlim(maxx - 1, maxx + 1)
ax.set_ylim(miny + 1, miny - 1)
self.marker_control.go_to_left_mark()
self.assertEqual(list(ax.get_xlim()), [minx - 1, minx + 1])
self.assertEqual(list(ax.get_ylim()), [miny + 1, miny - 1])
xi = pd.Interval(*ax.get_xlim(), closed='both')
self.assertIn(minx, xi)
yi = pd.Interval(*sorted(ax.get_ylim()), closed='both')
self.assertIn(miny, yi)

def test_goto_lower_mark_01_single(self):
"""Test the navigation button to the right mark for one edge per mark
"""
ax = self.straditizer.ax
minx, maxx = sorted(self.data_xlim)
miny, maxy = sorted(self.data_ylim)
ax.set_xlim(minx - 1, minx + 1)
ax.set_ylim(miny - 1, miny + 1)
ax.set_xlim(minx - 0.5, minx + 1)
ax.set_ylim(miny - 0.5, miny + 1)
self.marker_control.go_to_lower_mark()
self.assertEqual(list(ax.get_xlim()), [maxx - 1, maxx + 1])
self.assertEqual(list(ax.get_ylim()), [maxy - 1, maxy + 1])
xi = pd.Interval(*ax.get_xlim(), closed='both')
self.assertIn(maxx, xi)
yi = pd.Interval(*sorted(ax.get_ylim()), closed='both')
self.assertIn(maxy, yi)

def test_goto_lower_mark_02_multi(self):
"""Test the navigation button to the right mark for multiple edges
Expand All @@ -188,8 +199,10 @@ def test_goto_lower_mark_02_multi(self):
ax.set_xlim(minx - 1, minx + 1)
ax.set_ylim(miny + 1, miny - 1)
self.marker_control.go_to_lower_mark()
self.assertEqual(list(ax.get_xlim()), [minx - 1, minx + 1])
self.assertEqual(list(ax.get_ylim()), [maxy + 1, maxy - 1])
xi = pd.Interval(*ax.get_xlim(), closed='both')
self.assertIn(minx, xi)
yi = pd.Interval(*sorted(ax.get_ylim()), closed='both')
self.assertIn(maxy, yi)

def test_goto_upper_mark_01_single(self):
"""Test the navigation button to the right mark for one edge per mark
Expand All @@ -200,8 +213,10 @@ def test_goto_upper_mark_01_single(self):
ax.set_xlim(maxy - 1, maxy + 1)
ax.set_ylim(maxy - 1, maxy + 1)
self.marker_control.go_to_upper_mark()
self.assertEqual(list(ax.get_xlim()), [minx - 1, minx + 1])
self.assertEqual(list(ax.get_ylim()), [miny - 1, miny + 1])
xi = pd.Interval(*ax.get_xlim(), closed='both')
self.assertIn(minx, xi)
yi = pd.Interval(*sorted(ax.get_ylim()), closed='both')
self.assertIn(miny, yi)

def test_goto_upper_mark_02_multi(self):
"""Test the navigation button to the right mark for multiple edges
Expand All @@ -218,8 +233,10 @@ def test_goto_upper_mark_02_multi(self):
ax.set_xlim(minx - 1, minx + 1)
ax.set_ylim(maxy + 1, maxy - 1)
self.marker_control.go_to_upper_mark()
self.assertEqual(list(ax.get_xlim()), [minx - 1, minx + 1])
self.assertEqual(list(ax.get_ylim()), [miny + 1, miny - 1])
xi = pd.Interval(*ax.get_xlim(), closed='both')
self.assertIn(minx, xi)
yi = pd.Interval(*sorted(ax.get_ylim()), closed='both')
self.assertIn(miny, yi)


if __name__ == '__main__':
Expand Down

0 comments on commit 23fd504

Please sign in to comment.