Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

Commit

Permalink
Merge pull request #35 from bebef1987/404
Browse files Browse the repository at this point in the history
404 tests
  • Loading branch information
retornam committed Apr 12, 2012
2 parents 067ef49 + dbba481 commit 5d7a139
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 7 deletions.
2 changes: 1 addition & 1 deletion mozwebqa.cfg
@@ -1,4 +1,4 @@
[DEFAULT] [DEFAULT]
api = webdriver api = webdriver
baseurl = https://www-dev.allizom.org/b/ baseurl = https://www-dev.allizom.org/b


5 changes: 3 additions & 2 deletions pages/desktop/base.py
Expand Up @@ -2,12 +2,13 @@


# This Source Code Form is subject to the terms of the Mozilla Public # 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 # 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/. # file, You can obtain one at http://mozilla.org/MPL/2.0/


from pages.page import Page
from selenium.webdriver.common.by import By from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support.ui import WebDriverWait


from pages.page import Page



class Base(Page): class Base(Page):


Expand Down
1 change: 0 additions & 1 deletion pages/desktop/contribute.py
Expand Up @@ -6,7 +6,6 @@


from selenium.webdriver.common.by import By from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select from selenium.webdriver.support.select import Select

from pages.desktop.base import Base from pages.desktop.base import Base
from pages.page import Page from pages.page import Page


Expand Down
44 changes: 44 additions & 0 deletions pages/desktop/mission.py
@@ -0,0 +1,44 @@
#!/usr/bin/env python

# 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 pages.desktop.base import Base
from selenium.webdriver.common.by import By


class MissionPage(Base):

_mission_sidebar_link = (By.CSS_SELECTOR, '.sidebar > nav > ul > li:nth-of-type(1) > a')
_forums_sidebar_link = (By.CSS_SELECTOR, '.sidebar > nav > ul > li:nth-of-type(2) > a')
_governance_sidebar_link = (By.CSS_SELECTOR, '.sidebar > nav > ul > li:nth-of-type(3) > a')
_history_sidebar_link = (By.CSS_SELECTOR, '.sidebar > nav > ul > li:nth-of-type(4) > a')
_home_breadcrumb_link = (By.CSS_SELECTOR, '.breadcrumbs > a')
_mission_breadcrumb_link = (By.CSS_SELECTOR, '.breadcrumbs > span')
_video_section = (By.CSS_SELECTOR, '.mozilla-video-control-overlay')
_our_projects_learn_more_link = (By.CSS_SELECTOR, '.reference:nth-of-type(1) > .more')
_get_involved_learn_more_link = (By.CSS_SELECTOR, '.reference:nth-of-type(2) > .more')

def go_to_page(self):
self.open('/en-US/mission')

@property
def are_sidebar_links_visible(self):
self.is_element_visible(*self._mission_sidebar_link)
self.is_element_visible(*self._forums_sidebar_link)
self.is_element_visible(*self._governance_sidebar_link)
self.is_element_visible(*self._history_sidebar_link)
return True

@property
def are_breadcrumb_links_visible(self):
self.is_element_visible(*self._home_breadcrumb_link)
self.is_element_visible(*self._mission_breadcrumb_link)
return True

@property
def are_learn_more_links_visible(self):
self.is_element_visible(*self._our_projects_learn_more_link)
self.is_element_visible(*self._get_involved_learn_more_link)
return True
28 changes: 28 additions & 0 deletions tests/test_404.py
@@ -0,0 +1,28 @@
#!/usr/bin/env python

# 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/.


import pytest
import requests
from unittestzero import Assert


@pytest.mark.skip_selenium
class TestStatus(object):

@pytest.mark.nondestructive
def test_status_code_returns_404(self, mozwebqa):
url=mozwebqa.base_url+'/abck'
response=requests.get(url)
Assert.equal(response.status_code, 404)

@pytest.mark.nondestructive
def test_xrobots_tag_is_present(self, mozwebqa):
'''Test for X-Robots-Tag header'''
url=mozwebqa.base_url
response=requests.get(url)
Assert.contains("x-robots-tag", response.headers.keys())
Assert.contains('noodp', response.headers.values())
3 changes: 2 additions & 1 deletion tests/test_contribute.py
Expand Up @@ -5,8 +5,9 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.


import pytest import pytest
from unittestzero import Assert
from pages.desktop.contribute import Contribute from pages.desktop.contribute import Contribute
from unittestzero import Assert





class TestContribute: class TestContribute:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_homepage.py
Expand Up @@ -5,8 +5,8 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.


import pytest import pytest
from unittestzero import Assert
from pages.desktop.home import Home from pages.desktop.home import Home
from unittestzero import Assert




class TestHomepage: class TestHomepage:
Expand Down
23 changes: 23 additions & 0 deletions tests/test_mission.py
@@ -0,0 +1,23 @@
from pages.desktop.mission import MissionPage
from unittestzero import Assert


class TestMissionPage:

def test_sidebar_links(self, mozwebqa):
missionPage = MissionPage(mozwebqa)
missionPage.go_to_page()
Assert.true(missionPage.are_sidebar_links_visible)
Assert.true(missionPage.are_breadcrumb_links_visible)
Assert.true(missionPage.are_learn_more_links_visible)

def test_header_section_present(self, mozwebqa):
missionPage = MissionPage(mozwebqa)
missionPage.go_to_page()
missionPage.toggle_tabzilla_dropdown()
Assert.true(missionPage.are_tabzilla_links_present)

def test_footer_section_present(self, mozwebqa):
missionPage = MissionPage(mozwebqa)
missionPage.go_to_page()
Assert.true(missionPage.are_footer_links_present)
3 changes: 2 additions & 1 deletion tests/test_technology.py
Expand Up @@ -2,10 +2,11 @@


# This Source Code Form is subject to the terms of the Mozilla Public # 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 # 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/. # file, You can obtain one at http://mozilla.org/MPL/2.0/


import pytest import pytest
from unittestzero import Assert from unittestzero import Assert

from pages.desktop.technology_page import TechnologyPage from pages.desktop.technology_page import TechnologyPage




Expand Down

0 comments on commit 5d7a139

Please sign in to comment.