Merge lp:~nik-jov-92/ubuntu-calculator-app/multiple_equals into lp:~acerisara/ubuntu-calculator-app/operation-after-clear

Proposed by Nikola Jovanovic
Status: Needs review
Proposed branch: lp:~nik-jov-92/ubuntu-calculator-app/multiple_equals
Merge into: lp:~acerisara/ubuntu-calculator-app/operation-after-clear
Diff against target: 68 lines (+40/-2)
2 files modified
app/tests/autopilot/ubuntu_calculator_app/__init__.py (+25/-2)
app/tests/autopilot/ubuntu_calculator_app/tests/test_main.py (+15/-0)
To merge this branch: bzr merge lp:~nik-jov-92/ubuntu-calculator-app/multiple_equals
Reviewer Review Type Date Requested Status
Bartosz Kosiorek (community) Disapprove
Nicholas Skaggs Pending
Andrea Cerisara Pending
Review via email: mp+245826@code.launchpad.net

Description of the change

Implemented test for bug #1400890. Test named "test_multiple_equals".

To post a comment you must log in.
Revision history for this message
Bartosz Kosiorek (gang65) wrote :

Thanks Nikola. Great job!

First please take a look at our README file (into "Clean/Beautiful Code" section).
It will be great if you will follow these rules.
Please take a look at my inline comments.

Please also modify this Merge Request, to merge into:
lp:ubuntu-calculator-app/reboot
https://code.launchpad.net/~ubuntu-calculator-dev/ubuntu-calculator-app/reboot

review: Needs Fixing
Revision history for this message
Andrea Cerisara (acerisara) wrote :

In addition to what Bartosz said (even though in this case I would prefer to check explicitly for the size), please merge trunk and use _assert_result_is / _assert_history_contains to check the results of a calculation.

Revision history for this message
Nikola Jovanovic (nik-jov-92) wrote :

Mr. Andrea,

I'm sorry for late responding. I will get right on it, just one little question is there a way to set a breakpoint like in Visual Studio so I can review it by lines of code and is there a way to print something in the terminal as autopilot goes? Thank you for your time and review I will get right on it :-)

Best Regards,
Nikola Jovanovic
<email address hidden>

> To: <email address hidden>
> From: <email address hidden>
> Subject: Re: [Merge] lp:~nik-jov-92/ubuntu-calculator-app/multiple_equals into lp:~acerisara/ubuntu-calculator-app/operation-after-clear
> Date: Fri, 9 Jan 2015 21:40:11 +0000
>
> In addition to what Bartosz said (even though in this case I would prefer to check explicitly for the size), please merge trunk and use _assert_result_is / _assert_history_contains to check the results of a calculation.
> --
> https://code.launchpad.net/~nik-jov-92/ubuntu-calculator-app/multiple_equals/+merge/245826
> You are the owner of lp:~nik-jov-92/ubuntu-calculator-app/multiple_equals.

Revision history for this message
Andrea Cerisara (acerisara) wrote :

Ciao Nikola,

to print something in the terminal, print(obj). To debug you can use pdb, take a look at https://docs.python.org/3/library/pdb.html. Let me know how it goes :)

Revision history for this message
Niklas Wenzel (nikwen) wrote :

The bug has been fixed now, so I think we can close this MP.

Revision history for this message
Bartosz Kosiorek (gang65) :
review: Disapprove

Unmerged revisions

49. By Nikola Jovanovic

fix testcase for multiple equals

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/tests/autopilot/ubuntu_calculator_app/__init__.py'
2--- app/tests/autopilot/ubuntu_calculator_app/__init__.py 2014-12-27 10:06:06 +0000
3+++ app/tests/autopilot/ubuntu_calculator_app/__init__.py 2015-01-08 10:14:59 +0000
4@@ -61,12 +61,23 @@
5 return calc.wait_select_single('QQuickText',
6 objectName='result').text.strip()
7
8+ def size(self):
9+ _retValue = 0
10+
11+ history = self.app.select_many('QQuickRectangle', objectName='mainItem')
12+
13+ if (history > 0):
14+ _retValue = 1
15+
16+ return _retValue
17+
18
19 class MainView(ubuntuuitoolkit.MainView):
20 """Calculator MainView Autopilot emulator."""
21
22- BUTTONS = {'clear': 'clearButton', '*': 'multiplyButton',
23- '8': 'eightButton', '9': 'nineButton', '=': 'equalsButton'}
24+ BUTTONS = {'clear': 'clearButton', '*': 'multiplyButton', '1': 'oneButton', '2': 'twoButton',
25+ '3': 'threeButton', '4': 'fourButton', '5': 'fiveButton', '6': 'sixButton',
26+ '7': 'sevenButton', '8': 'eightButton', '9': 'nineButton', '=': 'equalsButton'}
27
28 def __init__(self, *args):
29 super(MainView, self).__init__(*args)
30@@ -94,3 +105,15 @@
31 def get_result(self):
32 return self.wait_select_single('TextField',
33 objectName='textInputField').displayText
34+
35+
36+
37+ """def check_for_equality(self, expression):
38+ isEqual = False
39+
40+ history = self.get_history()
41+ if history == expression:
42+ isEqual = True
43+
44+ return isEqual"""
45+
46
47=== modified file 'app/tests/autopilot/ubuntu_calculator_app/tests/test_main.py'
48--- app/tests/autopilot/ubuntu_calculator_app/tests/test_main.py 2014-12-27 10:06:06 +0000
49+++ app/tests/autopilot/ubuntu_calculator_app/tests/test_main.py 2015-01-08 10:14:59 +0000
50@@ -27,3 +27,18 @@
51 Eventually(Equals('81')))
52
53 self.assertTrue(self.app.main_view.get_history().contains('9×9=81'))
54+
55+
56+ def test_multiple_equals(self):
57+ self.app.main_view.insert('2*8=')
58+ self.assertThat(self.app.main_view.get_result, Eventually(Equals('16')))
59+
60+ self.assertEqual(1, self.app.main_view.get_history().size())
61+ self.assertTrue(self.app.main_view.get_history().contains('2x8=16'))
62+
63+ self.app.main_view.press('=')
64+ self.app.main_view.press('=')
65+ self.app.main_view.press('=')
66+
67+ self.assertEqual(1, self.app.main_view.get_history().size())
68+ self.assertTrue(self.app.main_view.get_history().contains('2x8=16'))

Subscribers

People subscribed via source and target branches