Skip to content

Instantly share code, notes, and snippets.

@bobsilverberg
Created January 21, 2013 19:39
Show Gist options
  • Select an option

  • Save bobsilverberg/4588632 to your computer and use it in GitHub Desktop.

Select an option

Save bobsilverberg/4588632 to your computer and use it in GitHub Desktop.
Version of test_product_link_urls_are_valid that doesn't use Selenium
@pytest.mark.skip_selenium
@pytest.mark.nondestructive
def test_product_link_urls_are_valid(self, mozwebqa):
mozillabased_page = MozillaBasedPage(mozwebqa)
url = "%s/projects/mozilla-based/" % mozwebqa.base_url
page_response = requests.get(url)
html = BeautifulStoneSoup(page_response.content)
bad_urls = []
product_list = html.find('ul', 'productlist')
product_links = product_list.findAll('a', href=True)
for link in product_links:
url = link['href']
response_code = mozillabased_page.get_response_code(url)
if response_code != requests.codes.ok:
bad_urls.append('%s is not a valid url - status code: %s.' % (url, response_code))
Assert.equal(0, len(bad_urls), '%s bad urls found: ' % len(bad_urls) + ', '.join(bad_urls))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment