Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

Commit

Permalink
Merge pull request #750 from justinpotts/fix_flake8_errors
Browse files Browse the repository at this point in the history
Fixed flake8 errors
  • Loading branch information
Matt Brandt committed Feb 23, 2015
2 parents 34a9883 + 6fb6db7 commit bb8d210
Show file tree
Hide file tree
Showing 30 changed files with 81 additions and 91 deletions.
1 change: 1 addition & 0 deletions conftest.py
Expand Up @@ -6,6 +6,7 @@

import py


def pytest_runtest_setup(item):
pytest_mozwebqa = py.test.config.pluginmanager.getplugin("mozwebqa")
pytest_mozwebqa.TestSetup.services_base_url = item.config.option.services_base_url
Expand Down
1 change: 0 additions & 1 deletion pages/__init__.py
@@ -1 +0,0 @@

1 change: 0 additions & 1 deletion pages/desktop/__init__.py
@@ -1 +0,0 @@

2 changes: 1 addition & 1 deletion pages/desktop/addons_site.py
Expand Up @@ -88,7 +88,7 @@ def date(self):
def delete(self):
self._root_element.find_element(*self._delete_review_locator).click()
WebDriverWait(self.selenium, self.timeout).until(lambda s:
self.marked_for_deletion == 'Marked for deletion')
self.marked_for_deletion == 'Marked for deletion')

@property
def marked_for_deletion(self):
Expand Down
16 changes: 7 additions & 9 deletions pages/desktop/base.py
Expand Up @@ -23,8 +23,6 @@ class Base(Page):
_footer_locator = (By.CSS_SELECTOR, "#footer")

def login(self, method="normal", user="default"):
from pages.desktop.user import Login

if method == "normal":
login = self.header.click_login_normal()
login.login_user_normal(user)
Expand Down Expand Up @@ -131,20 +129,20 @@ def _extract_integers(self, regex_pattern, *locator):

class HeaderRegion(Page):

#other applications
# other applications
_other_applications_locator = (By.ID, "other-apps")
_other_applications_menu_locator = (By.CLASS_NAME, "other-apps")

#Search box
# Search box
_search_button_locator = (By.CSS_SELECTOR, ".search-button")
_search_textbox_locator = (By.ID, "search-q")

#Not LoggedIn
# Not LoggedIn
_login_browser_id_locator = (By.CSS_SELECTOR, "a.browserid-login")
_register_locator = (By.CSS_SELECTOR, "#aux-nav li.account a:nth-child(1)")
_login_normal_locator = (By.CSS_SELECTOR, "#aux-nav li.account a:nth-child(2)")

#LoggedIn
# LoggedIn
_account_controller_locator = (By.CSS_SELECTOR, "#aux-nav .account a.user")
_account_dropdown_locator = (By.CSS_SELECTOR, "#aux-nav .account ul")
_logout_locator = (By.CSS_SELECTOR, "li.nomenu.logout > a")
Expand All @@ -154,15 +152,15 @@ class HeaderRegion(Page):
_complete_themes_menu_locator = (By.CSS_SELECTOR, '#site-nav div > a.complete-themes > b')

def site_navigation_menu(self, value):
#used to access one specific menu
# used to access one specific menu
for menu in self.site_navigation_menus:
if menu.name == value.upper():
return menu
raise Exception("Menu not found: '%s'. Menus: %s" % (value, [menu.name for menu in self.site_navigation_menus]))

@property
def site_navigation_menus(self):
#returns a list containing all the site navigation menus
# returns a list containing all the site navigation menus
WebDriverWait(self.selenium, self.timeout).until(lambda s: len(s.find_elements(*self._site_navigation_menus_locator)) >= self._site_navigation_min_number_menus)
from pages.desktop.regions.header_menu import HeaderMenu
return [HeaderMenu(self.testsetup, web_element) for web_element in self.selenium.find_elements(*self._site_navigation_menus_locator)]
Expand Down Expand Up @@ -297,7 +295,7 @@ def is_my_favorites_menu_present(self):
ActionChains(self.selenium).move_to_element(hover_element).perform()
menu_text = self.selenium.find_element(*self._account_dropdown_locator).text

if not 'My Profile' in menu_text:
if 'My Profile' not in menu_text:
print "ActionChains is being flakey again"
return 'My Favorites' in menu_text

Expand Down
14 changes: 7 additions & 7 deletions pages/desktop/details.py
Expand Up @@ -65,9 +65,9 @@ class Details(Base):
_devs_comments_toggle_locator = (By.CSS_SELECTOR, "#developer-comments h2 a")
_devs_comments_message_locator = (By.CSS_SELECTOR, "#developer-comments div.content")

#more about this addon
# more about this addon
_website_locator = (By.CSS_SELECTOR, ".links a.home")
#other_addons
# other_addons
_other_addons_by_author_locator = (By.CSS_SELECTOR, "#author-addons > ul.listing-grid > section li > div.addon")
_other_addons_by_author_text_locator = (By.CSS_SELECTOR, '#author-addons > h2')
_reviews_section_header_locator = (By.CSS_SELECTOR, '#reviews > h2')
Expand All @@ -93,7 +93,7 @@ class Details(Base):
_paypal_login_dialog_locator = (By.CSS_SELECTOR, '#page .content')

def __init__(self, testsetup, addon_name=None):
#formats name for url
# formats name for url
Base.__init__(self, testsetup)
if (addon_name is not None):
self.addon_name = addon_name.replace(" ", "-")
Expand Down Expand Up @@ -362,15 +362,15 @@ def click_website_link(self):
def support_url(self):
support_url = self.selenium.find_element(*self._support_link_locator).get_attribute('href')
match = re.findall("http", support_url)
#staging url
# staging url
if len(match) > 1:
return self._extract_url_from_link(support_url)
#production url
# production url
else:
return support_url

def _extract_url_from_link(self, url):
#parses out extra certificate stuff from urls in staging only
# parses out extra certificate stuff from urls in staging only
return urlparse.unquote(re.search('\w+://.*/(\w+%3A//.*)', url).group(1))

@property
Expand Down Expand Up @@ -399,7 +399,7 @@ def collection_widget_login_link(self):

class ImagePreviewer(Page):

#navigation
# navigation
_next_locator = (By.CSS_SELECTOR, 'section.previews div.carousel > a.next')
_prev_locator = (By.CSS_SELECTOR, 'section.previews div.carousel > a.prev')

Expand Down
6 changes: 3 additions & 3 deletions pages/desktop/discovery.py
Expand Up @@ -53,8 +53,8 @@ def __init__(self, testsetup, path):
else:
self.selenium.get(self.base_url + path)
self.selenium.maximize_window()
#resizing this page for elements that disappear when the window is < 1000
#self.selenium.set_window_size(1000, 1000) Commented because this selenium call is still in beta
# resizing this page for elements that disappear when the window is < 1000
# self.selenium.set_window_size(1000, 1000) Commented because this selenium call is still in beta
WebDriverWait(self.selenium, self.timeout).until(lambda s: self.selenium.find_element(*self._promo_box_locator).size['height'] == 273)

@property
Expand Down Expand Up @@ -145,7 +145,7 @@ def is_visible(self):

def wait_for_next_promo(self):
WebDriverWait(self.selenium, self.timeout).until(lambda s:
self._root_element.find_element(*self._heading_locator).is_displayed())
self._root_element.find_element(*self._heading_locator).is_displayed())


class DiscoveryThemesDetail(Base):
Expand Down
2 changes: 1 addition & 1 deletion pages/desktop/home.py
Expand Up @@ -18,7 +18,7 @@ class Home(Base):
_first_addon_locator = (By.CSS_SELECTOR, ".summary > a > h3")
_other_applications_link_locator = (By.ID, "other-apps")

#Most Popular List
# Most Popular List
_most_popular_item_locator = (By.CSS_SELECTOR, "ol.toplist li")
_most_popular_list_heading_locator = (By.CSS_SELECTOR, "#homepage > .secondary h2")

Expand Down
1 change: 0 additions & 1 deletion pages/desktop/regions/__init__.py
@@ -1 +0,0 @@

4 changes: 2 additions & 2 deletions pages/desktop/regions/image_viewer.py
Expand Up @@ -13,13 +13,13 @@
class ImageViewer(Page):

_image_viewer = (By.CSS_SELECTOR, '#lightbox > section')
#controls
# controls
_next_locator = (By.CSS_SELECTOR, 'div.controls > a.control.next')
_previous_locator = (By.CSS_SELECTOR, 'div.controls > a.control.prev')
_caption_locator = (By.CSS_SELECTOR, 'div.caption span')
_close_locator = (By.CSS_SELECTOR, 'div.content > a.close')

#content
# content
_images_locator = (By.CSS_SELECTOR, 'div.content > img')
_current_image_locator = (By.CSS_SELECTOR, 'div.content > img[style*="opacity: 1"]')

Expand Down
6 changes: 3 additions & 3 deletions pages/desktop/regions/paginator.py
Expand Up @@ -12,17 +12,17 @@

class Paginator(Page):

#Numbering
# Numbering
_page_number_locator = (By.CSS_SELECTOR, 'nav.paginator .num > a:nth-child(1)')
_total_page_number_locator = (By.CSS_SELECTOR, 'nav.paginator .num > a:nth-child(2)')

#Navigation
# Navigation
_first_page_locator = (By.CSS_SELECTOR, 'nav.paginator .rel a:nth-child(1)')
_prev_locator = (By.CSS_SELECTOR, 'nav.paginator .rel a.prev')
_next_locator = (By.CSS_SELECTOR, 'nav.paginator .rel a.next')
_last_page_locator = (By.CSS_SELECTOR, 'nav.paginator .rel a:nth-child(4)')

#Position
# Position
_start_item_number_locator = (By.CSS_SELECTOR, 'nav.paginator .pos b:nth-child(1)')
_end_item_number_locator = (By.CSS_SELECTOR, 'nav.paginator .pos b:nth-child(2)')
_total_item_number = (By.CSS_SELECTOR, 'nav.paginator .pos b:nth-child(3)')
Expand Down
3 changes: 2 additions & 1 deletion pages/desktop/regions/search_filter.py
Expand Up @@ -32,7 +32,8 @@ def __init__(self, testsetup, lookup):
if ('active' not in is_expanded):
self.selenium.find_element(*self._all_tags_locator).click()
self._root_element = self.selenium.find_element(self._base_locator[0],
"%s[a[contains(@data-params, '%s')]]" % (self._base_locator[1], lookup))
"%s[a[contains(@data-params, '%s')]]"
% (self._base_locator[1], lookup))

@property
def name(self):
Expand Down
2 changes: 1 addition & 1 deletion pages/desktop/search.py
Expand Up @@ -119,7 +119,7 @@ def created_date(self):

@property
def is_compatible(self):
return not 'incompatible' in self._root_element.get_attribute('class')
return 'incompatible' not in self._root_element.get_attribute('class')

@property
def updated_date(self):
Expand Down
2 changes: 1 addition & 1 deletion pages/desktop/themes.py
Expand Up @@ -36,7 +36,7 @@ def theme_count(self):
def click_theme(self, index):
"""Clicks on the theme with the given index in the page."""
WebDriverWait(self.selenium, self.timeout).until(lambda s: self.selenium.find_elements(*self._themes_locator)[index].is_displayed())

self.selenium.find_elements(*self._themes_locator)[index].click()
theme_detail = ThemesDetail(self.testsetup)

Expand Down
1 change: 0 additions & 1 deletion pages/mobile/__init__.py
@@ -1 +0,0 @@

2 changes: 1 addition & 1 deletion pages/mobile/base.py
Expand Up @@ -70,7 +70,7 @@ def is_dropdown_menu_visible(self):

@property
def dropdown_menu_items(self):
#returns a list containing all the menu items
# returns a list containing all the menu items
return [self.MenuItem(self.testsetup, web_element) for web_element in self.selenium.find_elements(*self._menu_items_locator)]

class MenuItem(Page):
Expand Down
4 changes: 2 additions & 2 deletions pages/mobile/details.py
Expand Up @@ -17,9 +17,9 @@ class Details(Base):
_contribute_button_locator = (By.XPATH, "//a[contains(.,'Contribute')]")

def __init__(self, testsetup, addon_name=None):
#formats name for url
# formats name for url
Base.__init__(self, testsetup)
if (addon_name != None):
if (addon_name is not None):
self.addon_name = addon_name.replace(" ", "-")
self.addon_name = re.sub(r'[^A-Za-z0-9\-]', '', self.addon_name).lower()
self.addon_name = self.addon_name[:27]
Expand Down
1 change: 0 additions & 1 deletion pages/mobile/extensions.py
Expand Up @@ -6,7 +6,6 @@

from selenium.webdriver.common.by import By
from pages.mobile.base import Base
from pages.page import Page


class Extensions(Base):
Expand Down
1 change: 0 additions & 1 deletion pages/mobile/regions/sorter.py
Expand Up @@ -5,7 +5,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from selenium.webdriver.common.by import By
from pages.mobile.base import Base
from pages.page import Page


Expand Down
1 change: 0 additions & 1 deletion pages/page.py
Expand Up @@ -7,7 +7,6 @@
Created on Jun 21, 2010
'''
from unittestzero import Assert
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import ElementNotVisibleException
Expand Down
1 change: 0 additions & 1 deletion tests/__init__.py
@@ -1 +0,0 @@

1 change: 0 additions & 1 deletion tests/desktop/__init__.py
@@ -1 +0,0 @@

4 changes: 2 additions & 2 deletions tests/desktop/test_api_only.py
Expand Up @@ -10,8 +10,8 @@

from pages.desktop.addons_api import AddonsAPI

#These tests should only call the api.
#There should be no tests requiring selenium in this class.
# These tests should only call the api.
# There should be no tests requiring selenium in this class.


@pytest.mark.skip_selenium
Expand Down
6 changes: 3 additions & 3 deletions tests/desktop/test_details_page.py
Expand Up @@ -262,14 +262,14 @@ def test_that_breadcrumb_links_in_details_page_work(self, mozwebqa):
@pytest.mark.nondestructive
@pytest.mark.login
def test_that_add_a_review_button_works(self, mozwebqa):
#Step 1: Addons Home Page loads and Addons Details loads
# Step 1: Addons Home Page loads and Addons Details loads
home_page = Home(mozwebqa)

#Step 2:user logs in to submit a review
# Step 2:user logs in to submit a review
home_page.login()
Assert.true(home_page.header.is_user_logged_in)

#Step 3: user loads an addon details page and clicks write a review button
# Step 3: user loads an addon details page and clicks write a review button
details_page = Details(mozwebqa, 'Firebug')
review_box = details_page.click_to_write_review()
Assert.true(review_box.is_review_box_visible)
Expand Down

0 comments on commit bb8d210

Please sign in to comment.