~ubuntu-clock-dev/ubuntu-clock-app/reboot-packaging

« back to all changes in this revision

Viewing changes to tests/autopilot/ubuntu_clock_app/tests/test_alarm.py

  • Committer: carla-sella
  • Date: 2014-07-31 16:58:56 UTC
  • mto: (37.1.1 reboot)
  • mto: This revision was merged to the branch mainline in revision 50.
  • Revision ID: carla.sella@gmail.com-20140731165856-o2g4v4z7ivk9864v
Implemented locale.

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
# Authored by: Nicholas Skaggs <nicholas.skaggs@canonical.com>
 
18
#              Nekhelesh Ramananthan <krnekhelesh@gmail.com>
 
19
 
 
20
"""Tests for the Clock App - Alarm"""
 
21
 
 
22
from __future__ import absolute_import
 
23
 
 
24
import datetime
 
25
 
 
26
from autopilot.matchers import Eventually
 
27
from testtools.matchers import Equals
 
28
from ubuntu_clock_app.tests import ClockAppTestCase
 
29
 
 
30
 
 
31
class TestAlarm(ClockAppTestCase):
 
32
 
 
33
    """Tests the alarm page features"""
 
34
 
 
35
    def setUp(self):
 
36
        """ This is needed to wait for the application to start.
 
37
 
 
38
        In the testfarm, the application may take some time to show up.
 
39
 
 
40
        """
 
41
        super(TestAlarm, self).setUp()
 
42
        self.assertThat(
 
43
            self.main_view.visible, Eventually(Equals(True)))
 
44
 
 
45
        self.page = self.main_view.open_alarm()
 
46
 
 
47
    def test_add_single_type_alarm_must_add_to_alarm_list(self):
 
48
        """Test to check if a single type alarm is saved properly
 
49
 
 
50
        This test saves a single type alarm and verifies if it is added to the
 
51
        alarm list in the alarm page.
 
52
 
 
53
        """
 
54
        tomorrow = datetime.datetime.now() + datetime.timedelta(days=1)
 
55
        time_to_set = datetime.time(6, 10, 0)
 
56
        test_alarm_name = 'Single Test'
 
57
        # TODO this will be affected by the locale. --elopio - 2014-02-27
 
58
        expected_alarm_name = unicode(test_alarm_name)
 
59
        expected_recurrence = unicode(tomorrow.strftime('%A'))
 
60
        expected_enabled_value = True
 
61
        expected_time = unicode("6:10 AM")
 
62
        test_sound_name = "Bliss"
 
63
        expected_alarm_info = (
 
64
            expected_alarm_name, expected_recurrence, expected_enabled_value,
 
65
            expected_time)
 
66
 
 
67
        tomorrow_day = tomorrow.strftime('%A')
 
68
        self.page.add_single_alarm(
 
69
            test_alarm_name, tomorrow_day, time_to_set, test_sound_name)
 
70
 
 
71
        alarmlistPage = self.main_view.get_AlarmList()
 
72
        saved_alarms = alarmlistPage.get_saved_alarms()
 
73
        self.assertIn(expected_alarm_info, saved_alarms)
 
74
 
 
75
        # TODO: Remove this statement once proper support for cleaning the
 
76
        # test alarm environment is added. Until then remove the alarm
 
77
        # created during the test at the end of the test.
 
78
        # -- nik90 - 2014-03-03
 
79
        alarmlistPage.delete_alarm(index=0)