mozilla/mcom-tests — Issue #27: Fix test_download.py to accomodate/follow 302s
Author: stephendonner
Created: 2012-02-28 20:26:38+00:00
State: open

Our test_downloads_platform_xxx tests (from https://github.com/mozilla/mcom-tests/blob/master/test_download.py) fail like so:

self =
mozwebqa =

@xfail(reason="Dunno? marking until i figure this out")
def test_windows_download_button_returns_status_code_200(self, mozwebqa):
url = '%s/products/download.html' % mozwebqa.base_url
response = requests.get(url)
html = BeautifulStoneSoup(response.content)
link = html.find('li', 'os_windows').a['href']
print link
response = requests.head(link)
> Assert.equal(response.status_code, 200)

test_download.py:78:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = , first = 302, second = 200
msg = None

@classmethod
def equal(self, first, second, msg=None):
> assert first == second, msg
E assert 302 == 200

Below is the server response, with status codes:

[12:12:41.266] GET http://www.mozilla.org/products/download.html?product=firefox-10.0.2&os=win&lang=en-US [HTTP/1.1 301 Moved Permanently 30ms]
[12:12:42.158] GET http://download.mozilla.org/?product=firefox-10.0.2&os=win&lang=en-US [HTTP/1.1 302 Found 18ms]
[12:12:42.270] GET http://mozilla.cdn.leaseweb.com/firefox/releases/10.0.2/win32/en-US/Firefox%20Setup%2010.0.2.exe [HTTP/1.1 200 OK 4596ms]

We should fix the test in the cleanest, more reliable way possible