redesign the test objects #109

Merged
merged 4 commits into from Aug 20, 2012

3 participants

@bebef1987

moved the work flow methods to the base test page

@klrmn

i haven't read the code deeply (it looks like it's been moved, but not otherwise changed), but the modified tests run well.

@stephendonner stephendonner and 1 other commented on an outdated diff Aug 10, 2012
tests/base_test.py
+
+ from pages.desktop.consumer_pages.home import Home
+ home_page = Home(mozwebqa)
+ home_page.go_to_homepage()
+
+ if user == None:
+ from mocks.mock_user import MockUser
+ user = MockUser()
+ home_page.create_new_user(user)
+
+ home_page.login(user)
+
+ return home_page, user
+
+ def _developer_page_login_to_paypal(self, mozwebqa):
+ """ login to pay pall developer pages"""
@stephendonner
stephendonner added a line comment Aug 10, 2012

Nit: PayPal

@bebef1987
bebef1987 added a line comment Aug 10, 2012

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@stephendonner stephendonner and 1 other commented on an outdated diff Aug 10, 2012
tests/base_test.py
+ Assert.true(developer_paypal_page.is_user_logged_in)
+ return developer_paypal_page
+
+ def _open_payment_settings_page(self, current_page):
+ """ navigate to payment_settings_page from the current page"""
+
+ # go to Payment Settings page
+ settings_page = current_page.footer.click_account_settings()
+ Assert.true(settings_page.is_the_current_page)
+
+ payment_settings_page = settings_page.click_payment_menu()
+ Assert.equal('Payment Settings', payment_settings_page.header_title)
+ return payment_settings_page
+
+ def _set_up_pre_approval(self, payment_settings_page):
+ """ Setup preapproval from payments settings page"""
@stephendonner
stephendonner added a line comment Aug 10, 2012

Nit: set up

@bebef1987
bebef1987 added a line comment Aug 10, 2012

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@teodosia teodosia commented on an outdated diff Aug 10, 2012
tests/base_test.py
+
+ from pages.desktop.consumer_pages.home import Home
+ home_page = Home(mozwebqa)
+ home_page.go_to_homepage()
+
+ if user == None:
+ from mocks.mock_user import MockUser
+ user = MockUser()
+ home_page.create_new_user(user)
+
+ home_page.login(user)
+
+ return home_page, user
+
+ def _developer_page_login_to_paypal(self, mozwebqa):
+ """login to PayPall developer pages"""
@teodosia
teodosia added a line comment Aug 10, 2012

s/PayPall/PayPal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@teodosia teodosia commented on the diff Aug 10, 2012
tests/base_test.py
+
+ def _set_up_pre_approval(self, payment_settings_page):
+ """Set up preapproval from payments settings page"""
+
+ # request pre-approval
+ paypal_sandbox = payment_settings_page.click_set_up_pre_approval()
+
+ # login PayPal sandbox will throw a timeout error if login box doesn't appear
+ paypal_sandbox.login_paypal_sandbox(user="sandbox")
+ Assert.true(paypal_sandbox.is_user_logged_in)
+
+ # enact preapproval
+ payment_settings_page = paypal_sandbox.click_approve_button()
+
+ return payment_settings_page
+
@teodosia
teodosia added a line comment Aug 10, 2012

PEP8: base_test.py:70:1: W391 blank line at end of file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@teodosia teodosia commented on an outdated diff Aug 10, 2012
tests/base_test.py
@@ -3,6 +3,7 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from unittestzero import Assert
@teodosia
teodosia added a line comment Aug 10, 2012

We should have a new line here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@teodosia teodosia commented on an outdated diff Aug 10, 2012
tests/desktop/test_users_account.py
@@ -46,8 +46,11 @@ def test_that_user_can_set_up_pre_approval_on_payment_settings_page(self, mozweb
# We have to first log in to PayPal developer to access the PayPal sandbox
self._developer_page_login_to_paypal(mozwebqa)
- # get to payment settings page as 'add_preapproval' user
- payment_settings_page = self._payment_settings_page_as_user(mozwebqa, 'add_preapproval')
+ # Login to consumer pages
+ home_page, user =self._login_to_consumer_pages(mozwebqa, 'add_preapproval')
@teodosia
teodosia added a line comment Aug 10, 2012

test_users_account.py:50:26: E225 missing whitespace around operator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@teodosia teodosia commented on the diff Aug 10, 2012
tests/desktop/test_users_account.py
- payment_settings_page = settings_page.click_payment_menu()
- Assert.equal('Payment Settings', payment_settings_page.header_title)
- return payment_settings_page
-
- def _set_up_pre_approval(self, payment_settings_page):
- # request pre-approval
- paypal_sandbox = payment_settings_page.click_set_up_pre_approval()
-
- # login PayPal sandbox will throw a timeout error if login box doesn't appear
- paypal_sandbox.login_paypal_sandbox(user="sandbox")
- Assert.true(paypal_sandbox.is_user_logged_in)
-
- # enact preapproval
- payment_settings_page = paypal_sandbox.click_approve_button()
-
- return payment_settings_page
@teodosia
teodosia added a line comment Aug 10, 2012

test_users_account.py:107:1: W391 blank line at end of file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@retornam retornam commented on the diff Aug 13, 2012
tests/base_test.py
@@ -13,3 +15,56 @@ def _get_resource_path(self, filename):
import os
path_to_resources_folder = os.path.join(os.path.split(os.path.dirname(__file__))[0], 'resources')
return os.path.join(path_to_resources_folder, filename)
+
+ def _login_to_consumer_pages(self, mozwebqa, user=None):
+ """login to consumer pages using the provided user
+ if the user is not provided a new one will be created"""
+
+ from pages.desktop.consumer_pages.home import Home
@retornam
Mozilla member
retornam added a line comment Aug 13, 2012

why not move the import to the top, instead of doing it inside the method

@bebef1987
bebef1987 added a line comment Aug 20, 2012

this is a base page... so different import error may appear when using this methods in tests

@zacc
zacc added a line comment Aug 20, 2012

Also we only import it when we need it.
It's not needed more than once so no need to import it globally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@retornam retornam commented on the diff Aug 13, 2012
tests/base_test.py
+ home_page = Home(mozwebqa)
+ home_page.go_to_homepage()
+
+ if user == None:
+ from mocks.mock_user import MockUser
+ user = MockUser()
+ home_page.create_new_user(user)
+
+ home_page.login(user)
+
+ return home_page, user
+
+ def _developer_page_login_to_paypal(self, mozwebqa):
+ """login to PayPal developer pages"""
+
+ from pages.desktop.paypal.paypal import PayPal
@retornam
Mozilla member
retornam added a line comment Aug 13, 2012

why do you have the import here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@zacc

Merging

@zacc zacc merged commit 60abfa4 into mozilla:master Aug 20, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment