summaryrefslogtreecommitdiff
path: root/trunk/dimbola/plugins/rotate_plugin_tests.py
blob: f5d790e8eadffbc9cc0b14b15b374d5410412ac4 (plain)
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
# Copyright (C) 2009  Lars Wirzenius <liw@liw.fi>
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import unittest

import rotate_plugin


class RotatePluginNewAngleTests(unittest.TestCase):

    def setUp(self):
        self.plugin = rotate_plugin.RotatePhotos(None)

    def test_rotates_bad_angle_to_zero(self):
        self.assertEqual(self.plugin.new_angle(123, 1), 0)

    def test_rotates_zero_left(self):
        self.assertEqual(self.plugin.new_angle(0, -1), 90)

    def test_rotates_zero_right(self):
        self.assertEqual(self.plugin.new_angle(0, 1), 270)

    def test_rotates_ninety_left(self):
        self.assertEqual(self.plugin.new_angle(90, -1), 180)

    def test_rotates_ninety_right(self):
        self.assertEqual(self.plugin.new_angle(90, 1), 0)

    def test_rotates_oneeighty_left(self):
        self.assertEqual(self.plugin.new_angle(180, -1), 270)

    def test_rotates_oneeighty_right(self):
        self.assertEqual(self.plugin.new_angle(180, 1), 90)

    def test_rotates_twoseventy_left(self):
        self.assertEqual(self.plugin.new_angle(270, -1), 0)

    def test_rotates_twoseventy_right(self):
        self.assertEqual(self.plugin.new_angle(270, 1), 180)