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
=== modified file 'app/tests/autopilot/ubuntu_calculator_app/__init__.py'
--- app/tests/autopilot/ubuntu_calculator_app/__init__.py 2014-12-27 10:06:06 +0000
+++ app/tests/autopilot/ubuntu_calculator_app/__init__.py 2015-01-08 10:14:59 +0000
@@ -61,12 +61,23 @@
61 return calc.wait_select_single('QQuickText',61 return calc.wait_select_single('QQuickText',
62 objectName='result').text.strip()62 objectName='result').text.strip()
6363
64 def size(self):
65 _retValue = 0
66
67 history = self.app.select_many('QQuickRectangle', objectName='mainItem')
68
69 if (history > 0):
70 _retValue = 1
71
72 return _retValue
73
6474
65class MainView(ubuntuuitoolkit.MainView):75class MainView(ubuntuuitoolkit.MainView):
66 """Calculator MainView Autopilot emulator."""76 """Calculator MainView Autopilot emulator."""
6777
68 BUTTONS = {'clear': 'clearButton', '*': 'multiplyButton',78 BUTTONS = {'clear': 'clearButton', '*': 'multiplyButton', '1': 'oneButton', '2': 'twoButton',
69 '8': 'eightButton', '9': 'nineButton', '=': 'equalsButton'}79 '3': 'threeButton', '4': 'fourButton', '5': 'fiveButton', '6': 'sixButton',
80 '7': 'sevenButton', '8': 'eightButton', '9': 'nineButton', '=': 'equalsButton'}
7081
71 def __init__(self, *args):82 def __init__(self, *args):
72 super(MainView, self).__init__(*args)83 super(MainView, self).__init__(*args)
@@ -94,3 +105,15 @@
94 def get_result(self):105 def get_result(self):
95 return self.wait_select_single('TextField',106 return self.wait_select_single('TextField',
96 objectName='textInputField').displayText107 objectName='textInputField').displayText
108
109
110
111 """def check_for_equality(self, expression):
112 isEqual = False
113
114 history = self.get_history()
115 if history == expression:
116 isEqual = True
117
118 return isEqual"""
119
97120
=== modified file 'app/tests/autopilot/ubuntu_calculator_app/tests/test_main.py'
--- app/tests/autopilot/ubuntu_calculator_app/tests/test_main.py 2014-12-27 10:06:06 +0000
+++ app/tests/autopilot/ubuntu_calculator_app/tests/test_main.py 2015-01-08 10:14:59 +0000
@@ -27,3 +27,18 @@
27 Eventually(Equals('81')))27 Eventually(Equals('81')))
2828
29 self.assertTrue(self.app.main_view.get_history().contains('9×9=81'))29 self.assertTrue(self.app.main_view.get_history().contains('9×9=81'))
30
31
32 def test_multiple_equals(self):
33 self.app.main_view.insert('2*8=')
34 self.assertThat(self.app.main_view.get_result, Eventually(Equals('16')))
35
36 self.assertEqual(1, self.app.main_view.get_history().size())
37 self.assertTrue(self.app.main_view.get_history().contains('2x8=16'))
38
39 self.app.main_view.press('=')
40 self.app.main_view.press('=')
41 self.app.main_view.press('=')
42
43 self.assertEqual(1, self.app.main_view.get_history().size())
44 self.assertTrue(self.app.main_view.get_history().contains('2x8=16'))

Subscribers

People subscribed via source and target branches