Skip to content
This repository has been archived by the owner on Feb 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #167 from justinpotts/services_status
Browse files Browse the repository at this point in the history
Created a test for verifying links under services return status code 200
  • Loading branch information
Matt Brandt committed Aug 25, 2014
2 parents d494869 + fbe3d05 commit 1cc3b3b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
13 changes: 12 additions & 1 deletion pages/edit_profile.py
Expand Up @@ -39,14 +39,16 @@ class EditProfile(Base):
_selected_month_locator = (By.CSS_SELECTOR, '#id_date_mozillian_month > option[selected="selected"]')
_selected_year_locator = (By.CSS_SELECTOR, '#id_date_mozillian_year > option[selected="selected"]')
_find_group_page = (By.PARTIAL_LINK_TEXT, 'find the group')
_services_bugzilla_locator = (By.ID, 'services-bugzilla-url')
_services_mozilla_reps_locator = (By.ID, 'services-mozilla-reps')

def click_update_button(self):
self.selenium.find_element(*self._update_button_locator).click()
return Profile(self.testsetup)

def click_cancel_button(self):
self.selenium.find_element(*self._cancel_button_locator).click()

def click_find_group_link(self):
self.selenium.find_element(*self._find_group_page).click()
return GroupsPage(self.testsetup)
Expand Down Expand Up @@ -144,3 +146,12 @@ def delete_skill_buttons(self):
def select_random_year(self):
return self.select_year(random.choice(self.years_values[1:]))

def get_services_urls(self):
locs = [self._services_bugzilla_locator, self._services_mozilla_reps_locator]
urls = []

for element in locs:
url = self.selenium.find_element(*element).get_attribute('href')
urls.append(url)

return urls
2 changes: 1 addition & 1 deletion pages/link_crawler.py
Expand Up @@ -46,7 +46,7 @@ def collect_links(self, url, relative=True, name=True, **kwargs):
lambda u: u if u.startswith('http') else '%s%s' % (self.base_url, u), urls)

def verify_status_code_is_ok(self, url):
r = requests.get(url)
r = requests.get(url, verify=False)
if not r.status_code == requests.codes.ok:
return u'{0.url} returned: {0.status_code} {0.reason}'.format(r)
else:
Expand Down
25 changes: 25 additions & 0 deletions tests/test_profile.py
Expand Up @@ -6,9 +6,11 @@

import pytest
import time

from unittestzero import Assert
from selenium.webdriver.common.by import By
from pages.home_page import Home
from pages.link_crawler import LinkCrawler
from tests.base_test import BaseTest


Expand Down Expand Up @@ -345,3 +347,26 @@ def test_private_groups_field_when_not_logged_in(self, mozwebqa):

Assert.false(profile_page.is_groups_present,
u'Profile: ' + profile_page.get_url_current_page())

@pytest.mark.credentials
@pytest.mark.nondestructive
def test_that_links_in_the_services_page_return_200_code(self, mozwebqa):
home_page = Home(mozwebqa)
home_page.login()

edit_profile_page = home_page.header.click_edit_profile_menu_item()
crawler = LinkCrawler(mozwebqa)
urls = edit_profile_page.get_services_urls()
bad_urls = []

Assert.greater(
len(urls), 0, u'something went wrong. no links found.')

for url in urls:
check_result = crawler.verify_status_code_is_ok(url)
if check_result is not True:
bad_urls.append(check_result)

Assert.equal(
0, len(bad_urls),
u'%s bad links found. ' % len(bad_urls) + ', '.join(bad_urls))

0 comments on commit 1cc3b3b

Please sign in to comment.