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

link checking test for /about page #59

Merged
merged 4 commits into from
Feb 7, 2013

Conversation

sashakruglov
Copy link
Contributor

Addresses issue #55

@sashakruglov
Copy link
Contributor Author

This test doesn't use Webdriver at all and doesn't use PageObjects.

parsed_html = BeautifulSoup(about_page.text)

bad_urls = []
urls = [ancor['href'] for ancor in parsed_html.find(id='main').findAll('a')]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's probably the weakest place - hardcoded id of main area of the page (to avoid collecting anchors from footer or header).

@m8ttyB
Copy link
Contributor

m8ttyB commented Feb 6, 2013

This looks great to me and runs as expected. I like the use of BeautifulSoup to pull the urls from the page. By not hard coding the urls this is more future proof. Thanks @sashakruglov! This will increase our coverage greatly.

py.test --baseurl=http://mozillians.allizom.org -ktest_that_links_in_the_about_page_return_200_code
====================== test session starts ======================
platform darwin -- Python 2.7.2 -- pytest-2.2.4
collected 18 items 

tests/test_about_page.py .

17 tests deselected by "-ktest_that_links_in_the_about_page_return_200_code -m 'nondestructive'" 
============ 1 passed, 17 deselected in 3.95 seconds ============

@klrmn
Copy link

klrmn commented Feb 6, 2013

I haven't run it but i like it. i kinda think this test should be put in the templates project and expanded to crawl thru all links with the same base_url.

@m8ttyB
Copy link
Contributor

m8ttyB commented Feb 6, 2013

@klrmn curiously good smelling idea. Perhaps when we tackle that in a refactor when we work on issue #56.

parsed_html = BeautifulSoup(about_page.text)

bad_urls = []
urls = [anchor['href'] for anchor in parsed_html.find(id='main').findAll('a')]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you might want to explicitly filter out javascript urls here (the ones with href #). this project may not have them on this page, but many projects/pages do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@klrmn This rule needs additional refinements.

There is couple of links with # on this page, but they lead to different web-site. And this sounds like a bad idea.
We can filter URLs with # but only if they are for the same web page that is under test. So, if we are checking:
https://mozillians-dev.allizom.org/en-US/about, we can omit URL like https://mozillians-dev.allizom.org/en-US/about#LALALA.

I might be wrong, but this is not javascript URL. So maybe I just misunderstood your idea.

@m8ttyB
Copy link
Contributor

m8ttyB commented Feb 6, 2013

I'm going to make the call this pull request good. We can integrate @klrmn's ideas in a later pull reuqest.

@sashakruglov if you would fix a few small nits I'll merge this
Here are a few lines to fix that pep8 identified:

pep8 tests/test_about_page.py 
tests/test_about_page.py:33:80: E501 line too long (86 > 79 characters)
tests/test_about_page.py:38:80: E501 line too long (90 > 79 characters)
tests/test_about_page.py:39:80: E501 line too long (100 > 79 characters)

@sashakruglov
Copy link
Contributor Author

@m8ttyB fixed PEP8 violations

@bebef1987
Copy link
Contributor

LGTM
Merging it in

bebef1987 added a commit that referenced this pull request Feb 7, 2013
link checking test for /about page
@bebef1987 bebef1987 merged commit ac4c8e2 into mozilla:master Feb 7, 2013
@sashakruglov sashakruglov deleted the issue_55 branch February 7, 2013 14:00
@sashakruglov sashakruglov mentioned this pull request Feb 8, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants