~carla-sella/ubuntu-calendar-app/fix-dayview-default-view

« back to all changes in this revision

Viewing changes to tests/autopilot/calendar_app/tests/test_management.py

  • Committer: Kunal Parmar
  • Date: 2015-04-19 00:27:46 UTC
  • mfrom: (607.1.24 ubuntu-calendar-app)
  • Revision ID: pkunal.parmar@gmail.com-20150419002746-mr8ckw2tr1r0vkxv
conflict resolved

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
 
2
#
 
3
# Copyright (C) 2013, 2014 Canonical Ltd
 
4
#
 
5
# This program is free software: you can redistribute it and/or modify
 
6
# it under the terms of the GNU General Public License version 3 as
 
7
# published by the Free Software Foundation.
 
8
#
 
9
# This program is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
# GNU General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU General Public License
 
15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
 
 
17
"""
 
18
Calendar app autopilot tests calendar management.
 
19
"""
 
20
 
 
21
 
 
22
from testtools.matchers import NotEquals, Equals
 
23
from autopilot.matchers import Eventually
 
24
 
 
25
from calendar_app import data
 
26
 
 
27
from calendar_app.tests import CalendarAppTestCaseWithVcard
 
28
 
 
29
 
 
30
class TestManagement(CalendarAppTestCaseWithVcard):
 
31
 
 
32
    def test_change_calendar_color(self):
 
33
        """ Test changing calendar color   """
 
34
        calendar_choice_popup = \
 
35
            self.app.main_view.go_to_calendar_choice_popup()
 
36
        original_calendar_color = \
 
37
            calendar_choice_popup.get_calendar_color()
 
38
        calendar_choice_popup.open_color_picker_dialog()
 
39
        colorPickerDialog = self.app.main_view.get_color_picker_dialog()
 
40
        colorPickerDialog.change_calendar_color("color6")
 
41
 
 
42
        final_calendar_color = \
 
43
            calendar_choice_popup.get_calendar_color()
 
44
 
 
45
        self.assertThat(
 
46
            original_calendar_color, NotEquals(final_calendar_color))
 
47
 
 
48
    def test_unselect_calendar(self):
 
49
        """ Test unselecting calendar
 
50
 
 
51
          First adding an Event to then check it no longer appears after
 
52
          deselecting the Personal calendar  """
 
53
        test_event = data.Event.make_unique()
 
54
        new_event_page = self.app.main_view.go_to_new_event()
 
55
        new_event_page.add_event(test_event)
 
56
 
 
57
        self.assertThat(lambda: self._event_exists(test_event.name),
 
58
                        Eventually(Equals(True)))
 
59
 
 
60
        calendar_choice_popup = \
 
61
            self.app.main_view.go_to_calendar_choice_popup()
 
62
        original_checbox_status = \
 
63
            calendar_choice_popup.get_checkbox_status()
 
64
        calendar_choice_popup.press_check_box_button()
 
65
 
 
66
        self.assertThat(
 
67
            original_checbox_status,
 
68
            NotEquals(calendar_choice_popup.get_checkbox_status()))
 
69
 
 
70
        self.app.main_view.press_header_custombackbutton()
 
71
        self.app.main_view.go_to_day_view()
 
72
 
 
73
        self.assertThat(lambda: self._event_exists(test_event.name),
 
74
                        Eventually(Equals(False)))
 
75
 
 
76
    def _event_exists(self, event_name):
 
77
        try:
 
78
            day_view = self.app.main_view.go_to_day_view()
 
79
            day_view.get_event(event_name, True)
 
80
        except Exception:
 
81
            return False
 
82
        return True