Merge lp:~carla-sella/ubuntu-calendar-app/calendar-app into lp:ubuntu-calendar-app

Proposed by Carla Sella
Status: Rejected
Rejected by: Olivier Tilloy
Proposed branch: lp:~carla-sella/ubuntu-calendar-app/calendar-app
Merge into: lp:ubuntu-calendar-app
Diff against target: 71 lines (+28/-12)
1 file modified
tests/autopilot/calendar_app/tests/test_calendar.py (+28/-12)
To merge this branch: bzr merge lp:~carla-sella/ubuntu-calendar-app/calendar-app
Reviewer Review Type Date Requested Status
Olivier Tilloy (community) Disapprove
Carla Sella (community) Needs Resubmitting
Ubuntu Calendar Developers Pending
Ubuntu Phone Apps Jenkins Bot continuous-integration Pending
Review via email: mp+180929@code.launchpad.net

This proposal supersedes a proposal from 2013-08-12.

Description of the change

Calendar app autopilot new event test.
Re-submitted merge as there were problems with the motion fields, I modified the code for these fields a part the time picker that is a bit more complex.
Launching pep8 on the test gives me this error:
tests/autopilot/calendar_app/tests/test_calendar.py:29:32: E712 comparison to True should be 'if cond is not True:' or 'if not cond:'
but if I change what I put in the code the test does not work anymore :P.

To post a comment you must log in.
Revision history for this message
Nicholas Skaggs (nskaggs) wrote : Posted in a previous version of this proposal

Going to give this a whirl on a device -- if anyone can try it on a galaxy nexus or nexus 4, that would be great. I'll try on the nexus 10.

Revision history for this message
Olivier Tilloy (osomon) wrote : Posted in a previous version of this proposal

101 +## @unittest.skip("Adding a new event is broken, needs fixing. "
102 +## "See http://pad.lv/1206048.")

Instead of commented out, the skip decorator should be removed altogether, as bug #1206048 is now fixed.

Revision history for this message
Olivier Tilloy (osomon) wrote : Posted in a previous version of this proposal

30 + objectName: "OKButton"

That’s a very generic name, probably too generic. If in the future the app gets more popups, there will probably be several "OK buttons".

Revision history for this message
Olivier Tilloy (osomon) wrote : Posted in a previous version of this proposal

84 +from time import sleep

This import is unused, can you please remove it?

Revision history for this message
Olivier Tilloy (osomon) wrote : Posted in a previous version of this proposal

79 +import math

Same for this import, it seems it is unused.

Revision history for this message
Olivier Tilloy (osomon) wrote : Posted in a previous version of this proposal

148 + self.pointing_device.drag(x_Hscroller+(width_Hscroller/4),
149 + (y_Hscroller+((height_Hscroller/4)*3)),
150 + x_Hscroller+(width_Hscroller/4),
151 + (y_Hscroller+((height_Hscroller/4)*2)))

You should ensure you always pass integers as parameters to .drag(…), so you need to surround each parameter with int(…).

review: Needs Fixing
Revision history for this message
Olivier Tilloy (osomon) wrote : Posted in a previous version of this proposal

182 + #---> TODO input end time

So this MR is not complete yet, is it? If not complete, please set its status to "Work in progress", and set it back to "Needs review" once it is actually ready. Thanks!

Revision history for this message
Carla Sella (carla-sella) wrote : Posted in a previous version of this proposal

The test is complete for now even if it can be improved, but for the moment we want to run it as it is.

Revision history for this message
Carla Sella (carla-sella) : Posted in a previous version of this proposal
review: Needs Resubmitting
Revision history for this message
Nicholas Skaggs (nskaggs) wrote : Posted in a previous version of this proposal

A minor nitpick; I would add eventually to these lines:

self.assertThat(title_label, NotEquals(None))

and

self.assertThat(save_button, NotEquals(None))

Revision history for this message
Carla Sella (carla-sella) wrote : Posted in a previous version of this proposal

If I add eventually to the two lines you suggested, I get this error: TypeError: Eventually is only usable with attributes that have a wait_for function or callable objects.

Revision history for this message
Olivier Tilloy (osomon) wrote : Posted in a previous version of this proposal

172 + save_button = self.main_window.get_event_save_button()
173 + self.assertThat(lambda: save_button, Eventually(NotEquals(None)))

179 + title_label = self.main_window.get_title_label(eventTitle)
180 + self.assertThat(lambda: title_label, Eventually(NotEquals(None)))

This is not doing what you think it does: because 'save_button' and 'title_label' are assigned before defining the lambda function, they contain static values, so the lambda is useless. For it to be useful, you need to use it like that:

    lambda: self.main_window.get_event_save_button()
    lambda: self.main_window.get_title_label(eventTitle)

And since you’re comparing to None, instead of using Equals (or NotEquals), you should use the identity matcher, Is, like that:

    self.assertThat(…, Eventually(Not(Is(None))))

review: Needs Fixing
Revision history for this message
Carla Sella (carla-sella) wrote : Posted in a previous version of this proposal

Thanks Olivier, I fixed the two asserts, hope they are ok now.

review: Needs Resubmitting
Revision history for this message
Olivier Tilloy (osomon) wrote : Posted in a previous version of this proposal

42 - def get_month_view(self):
43 - return self.app.select_single("MonthView")

Removing this breaks all the other existing tests. Please revert this change.

review: Needs Fixing
Revision history for this message
Olivier Tilloy (osomon) wrote : Posted in a previous version of this proposal

92 - @unittest.skip("Adding a new event is broken, needs fixing. "
93 - "See http://pad.lv/1206048.")

Now that you removed this decorator, the "import unittest" line should be removed from tests/autopilot/calendar_app/tests/test_calendar.py.

review: Needs Fixing
Revision history for this message
Olivier Tilloy (osomon) wrote : Posted in a previous version of this proposal

pyflakes reports 4 warnings, all of them easily fixable by just removing unused code:

tests/autopilot/calendar_app/tests/test_calendar.py:17: 'unittest' imported but unused
tests/autopilot/calendar_app/tests/test_calendar.py:47: local variable 'end_time_field' is assigned to but never used
tests/autopilot/calendar_app/tests/test_calendar.py:82: local variable 'minutesBeforeChange' is assigned to but never used
tests/autopilot/calendar_app/tests/test_calendar.py:120: local variable 'title_label' is assigned to but never used

Revision history for this message
Carla Sella (carla-sella) wrote : Posted in a previous version of this proposal

Hope everything's fine now :p.
Thanks Olilvier.

review: Needs Resubmitting
Revision history for this message
Olivier Tilloy (osomon) wrote : Posted in a previous version of this proposal

> 42 - def get_month_view(self):
> 43 - return self.app.select_single("MonthView")
>
> Removing this breaks all the other existing tests. Please revert this change.

This one still needs to be fixed, all the other autopilot tests are currently failing because of this removal.

Revision history for this message
Carla Sella (carla-sella) : Posted in a previous version of this proposal
review: Needs Resubmitting
Revision history for this message
Olivier Tilloy (osomon) wrote : Posted in a previous version of this proposal

Looks good, thanks Carla!

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote : Posted in a previous version of this proposal

Apparently the builder is now considering pep8 warnings as errors…
I’ll fix all the warnings in trunk in a separate branch and we’ll get it merged first, so that you have to address only those that are related to your changes in this branch.

Revision history for this message
Olivier Tilloy (osomon) wrote : Posted in a previous version of this proposal

> Apparently the builder is now considering pep8 warnings as errors…
> I’ll fix all the warnings in trunk in a separate branch and we’ll get it
> merged first, so that you have to address only those that are related to your
> changes in this branch.

In fact it appears all the pep8 warnings were introduced by your changes, the trunk is "clean".
To get a list of all the warnings, simply install 'pep8' on your machine, and from within your branch, run `pep8 tests`.
This will print out a list of warnings, usually self-explanatory on how to fix them.

Revision history for this message
Carla Sella (carla-sella) : Posted in a previous version of this proposal
review: Needs Resubmitting
Revision history for this message
Olivier Tilloy (osomon) wrote : Posted in a previous version of this proposal

I’m still getting 20 pep8 warnings:

$ pep8 tests
tests/autopilot/calendar_app/tests/test_calendar.py:78:50: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:78:67: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:79:51: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:79:70: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:79:73: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:80:50: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:80:67: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:81:51: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:81:70: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:81:73: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:94:50: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:94:67: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:95:51: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:95:70: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:95:73: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:96:50: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:96:67: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:97:51: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:97:70: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:97:73: E225 missing whitespace around operator

If you add whitespaces around the "+" operator, this should fix it.

Revision history for this message
Carla Sella (carla-sella) : Posted in a previous version of this proposal
review: Needs Resubmitting
Revision history for this message
Olivier Tilloy (osomon) wrote : Posted in a previous version of this proposal

Yes, looks like all the warnings are fixed now! Thanks for your patience Carla :)

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Carla Sella (carla-sella) wrote :

Re-submitted for approval as there were problems with motion fields that I tried to fix (a part the time picker).

review: Needs Resubmitting
Revision history for this message
Olivier Tilloy (osomon) wrote :

Please do not re-use a merge request that was already merged. It’s ok to re-use the same branch (although most of the time it makes sense to start from a new branch), but then submit a new MR.

This is not the right approach. If you need to ensure that a text field has active focus before inputting text in it, do something like that:

    self.pointing_device.click_object(field)
    field.activeFocus.wait_for(True)
    self.keyboard.type(text)
    self.assertThat(field.text, Eventually(Equals(text)))

Also note that I’m addressing similar issues in this test case (it’s failing when run on devices) there: https://code.launchpad.net/~osomon/ubuntu-calendar-app/fix-ap-tests-new-event/+merge/180847. I’d appreciate if you could review it. Thanks!

review: Disapprove
Revision history for this message
Olivier Tilloy (osomon) wrote :

By the way, regarding the pep8 warning that you’re seeing, it would go away if you replaced "inputField.focus != True" by "!inputField.focus".

And I suggest reading http://unity.ubuntu.com/autopilot/tutorial/good_tests.html?highlight=wait_for#prefer-wait-for-and-eventually-to-sleep for tips on how to write efficient autopilot tests.

Revision history for this message
Carla Sella (carla-sella) wrote :

Hello Olivier, sorry for the inconvenience, I will do what you suggest.
Thanks.

Revision history for this message
Olivier Tilloy (osomon) wrote :

No worries! Autopilot tests are tricky to get right because of timing issues, especially when they have to be run across different devices and form factors.

Note that my MR was merged yesterday, and today the tests are green in the dashboard (see http://reports.qa.ubuntu.com/smokeng/saucy/image/3672/calendar-app-autopilot/), so it looks like we’re in good shape to start writing more tests, if you’re interested.

Revision history for this message
Carla Sella (carla-sella) wrote :

Ok, sure, thanks.

Unmerged revisions

92. By Carla Sella

Fixed code on animation fields, except the time picker.

91. By Carla Sella

Work in progress for fixing new event test.

90. By Carla Sella

Added a couple of minor fixes.

89. By Carla Sella

Added asserts for error on location field in new event test.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/calendar_app/tests/test_calendar.py'
2--- tests/autopilot/calendar_app/tests/test_calendar.py 2013-08-15 12:36:28 +0000
3+++ tests/autopilot/calendar_app/tests/test_calendar.py 2013-08-19 19:10:08 +0000
4@@ -15,11 +15,25 @@
5
6 import time
7
8+from time import sleep
9 from calendar_app.tests import CalendarTestCase
10
11
12 class TestMainWindow(CalendarTestCase):
13
14+ def _input_string_in_field(self, inputField, inputString):
15+ #poll clicking for focus for lack of better method,
16+ #due to screen switching animation
17+ #is there a property we can use instead?
18+ timeout = 0
19+ while inputField.focus != True and timeout < 10:
20+ self.pointing_device.click_object(inputField)
21+ sleep(1)
22+ timeout += 1
23+ self.keyboard.type(inputString)
24+ self.assertThat(inputField.text, Eventually(Equals(inputString)))
25+ self.keyboard.press_and_release('Enter')
26+
27 def test_timeline_view_shows(self):
28 """test timeline view"""
29
30@@ -50,12 +64,12 @@
31
32 #input a new event name
33 self.assertThat(
34- self.main_window.get_new_event().visible, Eventually(Equals(True)))
35- eventTitle = "Test event" + str(time.time())
36-
37- self.pointing_device.click_object(event_name_field)
38- self.keyboard.type(eventTitle)
39- self.assertThat(event_name_field.text, Eventually(Equals(eventTitle)))
40+ lambda: self.main_window.get_new_event().visible,
41+ Eventually(Equals(True)))
42+ inputString = "Test event" + str(time.time())
43+ eventTitle = inputString
44+ self._input_string_in_field(event_name_field, inputString)
45+ self.assertThat(event_name_field.text, Eventually(Equals(inputString)))
46
47 #input start time
48 self.assertThat(
49@@ -110,14 +124,16 @@
50 Eventually(Equals(True)))
51
52 #input location
53- self.pointing_device.click_object(location_field)
54- self.keyboard.type("My location")
55- self.assertThat(location_field.text, Eventually(Equals("My location")))
56+ self.assertThat(
57+ lambda: location_field.visible, Eventually(Equals(True)))
58+ inputString = "My location"
59+ self._input_string_in_field(location_field, inputString)
60
61 #input people
62- self.pointing_device.click_object(people_field)
63- self.keyboard.type("Me")
64- self.assertThat(people_field.text, Eventually(Equals("Me")))
65+ self.assertThat(
66+ lambda: people_field.visible, Eventually(Equals(True)))
67+ inputString = "Me"
68+ self._input_string_in_field(people_field, inputString)
69
70 #click save button
71 save_button = self.main_window.get_event_save_button()

Subscribers

People subscribed via source and target branches

to status/vote changes: