Decommission repo
This commit is contained in:
Родитель
baf4eb5865
Коммит
359e161484
|
@ -1,48 +0,0 @@
|
|||
@Library('fxtest@1.6') _
|
||||
|
||||
pipeline {
|
||||
agent any
|
||||
options {
|
||||
ansiColor('xterm')
|
||||
timestamps()
|
||||
timeout(time: 5, unit: 'MINUTES')
|
||||
}
|
||||
environment {
|
||||
PYTEST_ADDOPTS = "-n=10 --color=yes"
|
||||
PULSE = credentials('PULSE')
|
||||
}
|
||||
stages {
|
||||
stage('Lint') {
|
||||
steps {
|
||||
sh "tox -e flake8"
|
||||
}
|
||||
}
|
||||
stage('Test') {
|
||||
steps {
|
||||
sh "tox -e py27"
|
||||
}
|
||||
post {
|
||||
always {
|
||||
archiveArtifacts 'results/*'
|
||||
junit 'results/*.xml'
|
||||
submitToActiveData('results/py27_raw.txt')
|
||||
submitToTreeherder('snippets-tests', 'e2e', 'End-to-end integration tests', 'results/*', 'results/py27_tbpl.txt')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
failure {
|
||||
mail(
|
||||
body: "${BUILD_URL}",
|
||||
from: "firefox-test-engineering@mozilla.com",
|
||||
replyTo: "firefox-test-engineering@mozilla.com",
|
||||
subject: "Build failed in Jenkins: ${JOB_NAME} #${BUILD_NUMBER}",
|
||||
to: "fte-ci@mozilla.com")
|
||||
}
|
||||
changed {
|
||||
ircNotification('#snippets')
|
||||
ircNotification('#fx-test-alerts')
|
||||
}
|
||||
}
|
||||
}
|
42
README.md
42
README.md
|
@ -1,41 +1 @@
|
|||
Snippet-tests
|
||||
=====================
|
||||
|
||||
Automated tests for the Snippets web app
|
||||
|
||||
[![license](https://img.shields.io/badge/license-MPL%202.0-blue.svg)](https://github.com/mozilla/snippets-tests/tree/master#license)
|
||||
[![travis](https://img.shields.io/travis/mozilla/snippets-tests.svg?label=travis)](http://travis-ci.org/mozilla/snippets-tests/)
|
||||
[![stage](https://img.shields.io/jenkins/s/https/webqa-ci.mozilla.com/snippets.stage.svg?label=stage)](https://webqa-ci.mozilla.com/job/snippets.stage/)
|
||||
[![prod](https://img.shields.io/jenkins/s/https/webqa-ci.mozilla.com/snippets.prod.svg?label=prod)](https://webqa-ci.mozilla.com/job/snippets.prod/)
|
||||
[![updates](https://pyup.io/repos/github/mozilla/snippets-tests/shield.svg)](https://pyup.io/repos/github/mozilla/snippets-tests)
|
||||
[![Python 3](https://pyup.io/repos/github/mozilla/snippets-tests/python-3-shield.svg)](https://pyup.io/repos/github/mozilla/snippets-tests/)
|
||||
|
||||
Running Tests
|
||||
-------------
|
||||
|
||||
* [Install Tox](https://tox.readthedocs.io/en/latest/install.html)
|
||||
* Run `tox`
|
||||
|
||||
Writing Tests
|
||||
-------------
|
||||
|
||||
If you want to get involved and add more tests, then there's just a few things
|
||||
we'd like to ask you to do:
|
||||
|
||||
1. Use the [template files][GitHub Templates] for all new tests and page objects
|
||||
2. Follow our simple [style guide][Style Guide]
|
||||
3. Fork this project with your own GitHub account
|
||||
4. Make sure all tests are passing, and submit a pull request with your changes
|
||||
|
||||
[GitHub Templates]: https://github.com/mozilla/mozwebqa-examples
|
||||
[Style Guide]: https://wiki.mozilla.org/QA/Execution/Web_Testing/Docs/Automation/StyleGuide
|
||||
|
||||
License
|
||||
-------
|
||||
This software is licensed under the [MPL] 2.0:
|
||||
|
||||
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/.
|
||||
|
||||
[MPL]: http://www.mozilla.org/MPL/2.0/
|
||||
This repository is no longer being actively maintained, and the content has been removed. Tests for Snippets now live in the [snippets-service](https://github.com/mozmar/snippets-service) repo. Please use the repository history to access the previous content.
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
flake8==3.3.0
|
|
@ -1,8 +0,0 @@
|
|||
beautifulsoup4==4.6.0
|
||||
mozlog==3.4
|
||||
pytest==3.1.2
|
||||
pytest-base-url==1.4.0
|
||||
pytest-html==1.15.1
|
||||
pytest-metadata==1.5.0
|
||||
pytest-xdist==1.17.1
|
||||
requests==2.18.1
|
|
@ -1,93 +0,0 @@
|
|||
# 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 json
|
||||
import re
|
||||
from urlparse import urlparse
|
||||
from xml.dom.minidom import parseString
|
||||
from xml.parsers.expat import ExpatError
|
||||
|
||||
import pytest
|
||||
from bs4 import BeautifulSoup
|
||||
import requests
|
||||
|
||||
|
||||
REQUESTS_TIMEOUT = 20
|
||||
|
||||
|
||||
class TestSnippets:
|
||||
|
||||
test_data = [
|
||||
('/3/Firefox/default/default/default/en-US/release/default/default/default/'),
|
||||
('/3/Firefox/default/default/default/en-US/aurora/default/default/default/'),
|
||||
('/3/Firefox/default/default/default/en-US/beta/default/default/default/')]
|
||||
|
||||
_user_agent_firefox = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:10.0.1) Gecko/20100101 Firefox/10.0.1'
|
||||
|
||||
def _get_redirect(self, url, user_agent=_user_agent_firefox, locale='en-US'):
|
||||
|
||||
headers = {'user-agent': user_agent,
|
||||
'accept-language': locale}
|
||||
|
||||
# verify=False ignores invalid certificate
|
||||
return requests.get(url, headers=headers, verify=False, timeout=REQUESTS_TIMEOUT)
|
||||
|
||||
def assert_valid_url(self, url, path, user_agent=_user_agent_firefox, locale='en-US'):
|
||||
"""Checks if a URL returns a 200 OK response."""
|
||||
|
||||
# Only check http and https links
|
||||
if not urlparse(url).scheme.startswith('http'):
|
||||
return True
|
||||
|
||||
headers = {'user-agent': user_agent,
|
||||
'accept-language': locale}
|
||||
|
||||
# HEAD doesn't return page body.
|
||||
try:
|
||||
r = requests.get(url, headers=headers, timeout=REQUESTS_TIMEOUT,
|
||||
allow_redirects=True, verify=False)
|
||||
except requests.exceptions.RequestException as e:
|
||||
raise AssertionError('Error connecting to {0} in {1}: {2}'.format(
|
||||
url, path, e))
|
||||
assert requests.codes.ok == r.status_code, \
|
||||
'Bad URL {0} found in {1}'.format(url, path)
|
||||
return True
|
||||
|
||||
def _parse_response(self, content):
|
||||
return BeautifulSoup(content)
|
||||
|
||||
@pytest.mark.parametrize(('path'), test_data)
|
||||
def test_snippet_set_present(self, base_url, path):
|
||||
full_url = base_url + path
|
||||
|
||||
r = self._get_redirect(full_url)
|
||||
assert requests.codes.ok == r.status_code, full_url
|
||||
|
||||
soup = self._parse_response(r.content)
|
||||
snippet_script = soup.find('script', type="text/javascript").text
|
||||
snippet_json_string = re.search("JSON.parse\('(.+)'\)", snippet_script).groups()[0]
|
||||
snippet_set = json.loads(snippet_json_string.replace('%u', r'\u').decode('unicode-escape'))
|
||||
|
||||
assert isinstance(snippet_set, list), 'No snippet set found'
|
||||
|
||||
@pytest.mark.parametrize(('path'), test_data)
|
||||
def test_all_links(self, base_url, path):
|
||||
full_url = base_url + path
|
||||
|
||||
soup = self._parse_response(self._get_redirect(full_url).content)
|
||||
snippet_links = soup.select("a")
|
||||
|
||||
for link in snippet_links:
|
||||
self.assert_valid_url(link['href'], path)
|
||||
|
||||
@pytest.mark.parametrize(('path'), test_data)
|
||||
def test_that_snippets_are_well_formed_xml(self, base_url, path):
|
||||
full_url = base_url + path
|
||||
|
||||
r = self._get_redirect(full_url)
|
||||
try:
|
||||
parseString('<div>{}</div>'.format(r.content))
|
||||
except ExpatError as e:
|
||||
raise AssertionError('Snippets at {0} do not contain well formed '
|
||||
'xml: {1}'.format(full_url, e))
|
27
tox.ini
27
tox.ini
|
@ -1,27 +0,0 @@
|
|||
[tox]
|
||||
skipsdist = true
|
||||
envlist = py27, flake8
|
||||
|
||||
[testenv]
|
||||
passenv = PYTEST_ADDOPTS PYTEST_BASE_URL JENKINS_URL JOB_NAME BUILD_NUMBER
|
||||
deps = -rrequirements/tests.txt
|
||||
commands = pytest \
|
||||
--html=results/{envname}.html --self-contained-html \
|
||||
--junit-xml=results/{envname}.xml \
|
||||
--log-raw=results/{envname}_raw.txt \
|
||||
--log-tbpl=results/{envname}_tbpl.txt \
|
||||
{posargs}
|
||||
|
||||
[testenv:flake8]
|
||||
skip_install = true
|
||||
deps = -rrequirements/flake8.txt
|
||||
commands = flake8 {posargs:.}
|
||||
|
||||
[flake8]
|
||||
ignore = E501
|
||||
|
||||
[pytest]
|
||||
addopts = --verbose -r=a
|
||||
testpaths = tests
|
||||
xfail_strict = true
|
||||
base_url = https://snippets.allizom.org
|
Загрузка…
Ссылка в новой задаче