Fixed the unit tests that jbalogh's commit broke.

This commit is contained in:
Matt Basta 2010-07-14 16:23:47 -07:00
Родитель 224b2e18e0
Коммит ebc3c136e8
22 изменённых файлов: 123 добавлений и 150 удалений

Просмотреть файл

@ -1,8 +1,8 @@
import os
from rdf import RDFParser
from xpi import XPIManager
from errorbundler import ErrorBundle
from validator.rdf import RDFParser
from validator.xpi import XPIManager
from validator.errorbundler import ErrorBundle
def _do_test(path, test, failure=True,
require_install=False, set_type=0):

Просмотреть файл

@ -1,7 +1,7 @@
import unittest
import os
from chromemanifest import ChromeManifest
from validator.chromemanifest import ChromeManifest
def test_open():
"Open a chrome file and ensure that data can be pulled from it."

Просмотреть файл

@ -1,19 +1,19 @@
import os
import decorator
import testcases
import testcases.conduit
from errorbundler import ErrorBundle
from xpi import XPIManager
from rdf import RDFParser
import validator.decorator as decorator
import validator.testcases as testcases
import validator.testcases.conduit as conduit
from validator.errorbundler import ErrorBundle
from validator.xpi import XPIManager
from validator.rdf import RDFParser
from helper import _do_test
from constants import *
from validator.constants import *
def test_outright():
"Tests the Conduit detector against an outright toolbar."
_do_test("tests/resources/conduit/basta_bar.xpi",
testcases.conduit.test_conduittoolbar,
conduit.test_conduittoolbar,
failure=True,
require_install=True,
set_type=PACKAGE_EXTENSION)
@ -22,7 +22,7 @@ def test_white():
"Tests a non-Conduit addon against the library."
_do_test("tests/resources/conduit/pass.xpi",
testcases.conduit.test_conduittoolbar,
conduit.test_conduittoolbar,
failure=False,
require_install=True,
set_type=PACKAGE_EXTENSION)
@ -32,7 +32,7 @@ def test_params():
the install.rdf file that indiciate Conduit-ion."""
_do_test("tests/resources/conduit/conduit_params.xpi",
testcases.conduit.test_conduittoolbar,
conduit.test_conduittoolbar,
failure=True,
require_install=True,
set_type=PACKAGE_EXTENSION)
@ -42,7 +42,7 @@ def test_updateurl():
parameter set to that of a Conduit Toolbar's."""
_do_test("tests/resources/conduit/conduit_updateurl.xpi",
testcases.conduit.test_conduittoolbar,
conduit.test_conduittoolbar,
failure=True,
require_install=True,
set_type=PACKAGE_EXTENSION)
@ -52,7 +52,7 @@ def test_structure():
folders which resemble those of a Conduit toolbar."""
_do_test("tests/resources/conduit/conduit_structure.xpi",
testcases.conduit.test_conduittoolbar,
conduit.test_conduittoolbar,
failure=True,
require_install=True,
set_type=PACKAGE_EXTENSION)
@ -62,7 +62,7 @@ def test_chrome():
chrome.manifest entries that indicate a Conduit toolbar."""
_do_test("tests/resources/conduit/conduit_chrome.xpi",
testcases.conduit.test_conduittoolbar,
conduit.test_conduittoolbar,
failure=True,
require_install=True,
set_type=PACKAGE_EXTENSION)

Просмотреть файл

@ -2,11 +2,11 @@ import os
from StringIO import StringIO
import xpi
import testcases.content as content
from errorbundler import ErrorBundle
import validator.xpi as xpi
import validator.testcases.content as content
from validator.errorbundler import ErrorBundle
from helper import _do_test
from constants import *
from validator.constants import *
def test_ignore_macstuff():
"Tests that the content manager will ignore Mac-generated files"

Просмотреть файл

@ -1,4 +1,4 @@
import decorator
import validator.decorator as decorator
def test_tiers():
"""Tests to make sure that the decorator module is properly

Просмотреть файл

@ -2,8 +2,8 @@
import json
from StringIO import StringIO
import errorbundler
from errorbundler import ErrorBundle
import validator.errorbundler as errorbundler
from validator.errorbundler import ErrorBundle
#{"messages": [{"message": "Invalid chrome.manifest object/predicate.", "type": "error", "description": "'override' entry does not match chrome://*/locale/*"}], "detected_type": 4, "success": false}

Просмотреть файл

@ -1,8 +1,8 @@
import testcases.installrdf
from errorbundler import ErrorBundle
from rdf import RDFParser
import validator.testcases.installrdf as installrdf
from validator.errorbundler import ErrorBundle
from validator.rdf import RDFParser
from helper import _do_test
from constants import *
from validator.constants import *
def _test_value(value, test, failure=True):
"Tests a value against a test."
@ -20,40 +20,40 @@ def test_pass_id():
"Tests that valid IDs will be accepted."
_test_value("{12345678-1234-1234-1234-123456789012}",
testcases.installrdf._test_id,
installrdf._test_id,
False)
_test_value("abc@foo.bar",
testcases.installrdf._test_id,
installrdf._test_id,
False)
_test_value("a+bc@foo.bar",
testcases.installrdf._test_id,
installrdf._test_id,
False)
def test_fail_id():
"Tests that invalid IDs will not be accepted."
_test_value("{1234567-1234-1234-1234-123456789012}",
testcases.installrdf._test_id)
installrdf._test_id)
_test_value("!@foo.bar",
testcases.installrdf._test_id)
installrdf._test_id)
def test_pass_version():
"Tests that valid versions will be accepted."
_test_value("1.2.3.4",
testcases.installrdf._test_version,
installrdf._test_version,
False)
_test_value("1a.2+.3b",
testcases.installrdf._test_version,
installrdf._test_version,
False)
def test_fail_version():
"Tests that invalid versions will not be accepted."
_test_value("2.0 alpha",
testcases.installrdf._test_version)
installrdf._test_version)
_test_value("whatever",
testcases.installrdf._test_version)
installrdf._test_version)
def _run_test(filename, failure=True):
"Runs a test on an install.rdf file"
@ -65,7 +65,7 @@ def _run_test(filename, failure=True):
file_.close()
parser = RDFParser(data)
testcases.installrdf._test_rdf(err, parser)
installrdf._test_rdf(err, parser)
if failure: # pragma: no cover
assert err.failed()

Просмотреть файл

@ -1,7 +1,7 @@
import testcases.l10ncompleteness as l10n
from errorbundler import ErrorBundle
import validator.testcases.l10ncompleteness as l10n
from validator.errorbundler import ErrorBundle
from helper import _do_test
from constants import *
from validator.constants import *
def test_pass():
"Test a package with localization that should pass validation."

Просмотреть файл

@ -2,7 +2,7 @@ import os
from StringIO import StringIO
import testcases.l10n.dtd as dtd
import validator.testcases.l10n.dtd as dtd
def test_passing_file():
"Tests a valid DTD file by passing in a file path."

Просмотреть файл

@ -1,10 +1,10 @@
import testcases.l10ncompleteness as l10n
from testcases.l10n.dtd import DTDParser
from testcases.l10n.properties import PropertiesParser
from xpi import XPIManager
from errorbundler import ErrorBundle
import validator.testcases.l10ncompleteness as l10n
from validator.testcases.l10n.dtd import DTDParser
from validator.testcases.l10n.properties import PropertiesParser
from validator.xpi import XPIManager
from validator.errorbundler import ErrorBundle
from helper import _do_test
from constants import *
from validator.constants import *
def test_chromemanifest():
"Make sure it only accepts packs with chrome.manifest files."

Просмотреть файл

@ -2,7 +2,7 @@ import os
from StringIO import StringIO
import testcases.l10n.properties as properties
import validator.testcases.l10n.properties as properties
def test_passing_file():
"Tests a valid properties file by passing in a file path."

Просмотреть файл

@ -1,14 +1,14 @@
import testcases
import testcases.langpack
from chromemanifest import ChromeManifest
from errorbundler import ErrorBundle
import validator.testcases as testcases
import validator.testcases.langpack as langpack
from validator.chromemanifest import ChromeManifest
from validator.errorbundler import ErrorBundle
from helper import _do_test
def test_langpack_valid():
"Tests that a language pack has a valid chrome manifest file."
_do_test("tests/resources/langpack/pass.xpi",
testcases.langpack.test_langpack_manifest,
langpack.test_langpack_manifest,
False)
def test_langpack_bad_subject():
@ -16,28 +16,28 @@ def test_langpack_bad_subject():
chrome.manifest file."""
_do_test("tests/resources/langpack/fail.xpi",
testcases.langpack.test_langpack_manifest)
langpack.test_langpack_manifest)
def test_langpack_bad_uri_pred():
"""Tests that a language pack has an invalid URI specified for its
'override' predicates."""
_do_test("tests/resources/langpack/fail_uri_pred.xpi",
testcases.langpack.test_langpack_manifest)
langpack.test_langpack_manifest)
def test_langpack_bad_uri_obj():
"""Tests that a language pack has an invalid URI specified for its
'override' objects."""
_do_test("tests/resources/langpack/fail_uri_obj.xpi",
testcases.langpack.test_langpack_manifest)
langpack.test_langpack_manifest)
def test_unsafe_html():
"Tests for unsafe HTML in obstract files."
err = ErrorBundle(None, True)
testcases.langpack.test_unsafe_html(err, None, """
langpack.test_unsafe_html(err, None, """
This is an <b>innocent</b> file.
Nothing to <a href="#anchor">suspect</a> here.
<img src="chrome://asdf/locale/asdf" />
@ -45,13 +45,13 @@ def test_unsafe_html():
assert not err.failed()
testcases.langpack.test_unsafe_html(err, "asdf", """
langpack.test_unsafe_html(err, "asdf", """
This is not an <script>innocent</script> file.""")
assert err.failed()
err = ErrorBundle(None, True)
testcases.langpack.test_unsafe_html(err, "asdf", """
langpack.test_unsafe_html(err, "asdf", """
Nothing to <a href="http://foo.bar/">suspect</a> here.""")
assert err.failed()
@ -61,6 +61,6 @@ def test_has_chrome_manifest():
"""Makes sure the module fails when a chrome.manifest file is not
available."""
assert testcases.langpack.test_langpack_manifest(None,
{},
None) is None
assert langpack.test_langpack_manifest(None,
{},
None) is None

Просмотреть файл

@ -1,11 +1,9 @@
import os
import decorator
import testcases
import testcases.library_blacklist
from errorbundler import ErrorBundle
from xpi import XPIManager
from rdf import RDFParser
import validator.testcases.library_blacklist as libblacklist
from validator.errorbundler import ErrorBundle
from validator.xpi import XPIManager
from validator.rdf import RDFParser
def test_blacklisted_files():
@ -18,9 +16,9 @@ def test_blacklisted_files():
contents = package.get_file_data()
err = ErrorBundle(None, True)
testcases.library_blacklist.test_library_blacklist(err,
contents,
package)
libblacklist.test_library_blacklist(err,
contents,
package)
err.print_summary()

Просмотреть файл

@ -1,7 +1,5 @@
import testcases
import testcases.markup
import testcases.markup.csstester
from errorbundler import ErrorBundle
import validator.testcases.markup.csstester as csstester
from validator.errorbundler import ErrorBundle
def _do_test(path, should_fail=False):
@ -11,7 +9,7 @@ def _do_test(path, should_fail=False):
err = ErrorBundle(None, True)
testcases.markup.csstester.test_css_file(err, "css.css", data)
csstester.test_css_file(err, "css.css", data)
err.print_summary()

Просмотреть файл

@ -1,6 +1,6 @@
import testcases.markup.markuptester
from errorbundler import ErrorBundle
from constants import *
import validator.testcases.markup.markuptester as markuptester
from validator.errorbundler import ErrorBundle
from validator.constants import *
def _do_test(path, should_fail=False, type_=None):
@ -15,7 +15,7 @@ def _do_test(path, should_fail=False, type_=None):
if type_:
err.set_type(type_)
parser = testcases.markup.markuptester.MarkupParser(err, True)
parser = markuptester.MarkupParser(err, True)
parser.process(filename, data, extension)
err.print_summary(True)
@ -32,7 +32,7 @@ def test_local_url_detector():
"Tests that local URLs can be detected."
err = ErrorBundle(None, True)
mp = testcases.markup.markuptester.MarkupParser(err)
mp = markuptester.MarkupParser(err)
tester = mp._is_url_local
assert tester("chrome://xyz/content/abc")
@ -60,91 +60,73 @@ def test_xul_file():
def test_xml_bad_nesting():
"Tests an XML file that has badly nested elements."
_do_test("tests/resources/markup/markuptester/bad_nesting.xml",
True)
_do_test("tests/resources/markup/markuptester/bad_nesting.xml", True)
def test_xml_overclosing():
"Tests an XML file that has overclosed elements"
_do_test("tests/resources/markup/markuptester/overclose.xml",
True)
_do_test("tests/resources/markup/markuptester/overclose.xml", True)
def test_xml_extraclosing():
"Tests an XML file that has extraclosed elements"
_do_test("tests/resources/markup/markuptester/extraclose.xml",
True)
_do_test("tests/resources/markup/markuptester/extraclose.xml", True)
def test_html_ignore_comment():
"Tests that HTML comment values are ignored"
_do_test(
"tests/resources/markup/markuptester/ignore_comments.html")
_do_test("tests/resources/markup/markuptester/ignore_comments.html")
def test_html_css_style():
"Tests that CSS within an element is passed to the CSS tester"
_do_test("tests/resources/markup/markuptester/css_style.html",
True)
_do_test("tests/resources/markup/markuptester/css_style.html", True)
def test_html_css_inline():
"Tests that inline CSS is passed to the CSS tester"
_do_test("tests/resources/markup/markuptester/css_inline.html",
True)
_do_test("tests/resources/markup/markuptester/css_inline.html", True)
def test_xul_evil():
"Tests for evil kinds of scripts and iframes in XUL."
_do_test(
"tests/resources/markup/markuptester/remote_src.xul", True)
_do_test("tests/resources/markup/markuptester/remote_src.xul", True)
_do_test(
"tests/resources/markup/markuptester/bad_iframe_remote.xul",
True)
_do_test(
"tests/resources/markup/markuptester/bad_iframe_chrome.xul",
True)
_do_test(
"tests/resources/markup/markuptester/"
"bad_iframe_remote_missing.xul",
True)
_do_test("tests/resources/markup/markuptester/bad_iframe_remote.xul", True)
_do_test("tests/resources/markup/markuptester/bad_iframe_chrome.xul", True)
_do_test("tests/resources/markup/markuptester/"
"bad_iframe_remote_missing.xul",
True)
def test_lp_passing():
"Tests a valid language pack file."
_do_test(
"tests/resources/markup/markuptester/_langpack/lp_safe.html",
False,
PACKAGE_LANGPACK)
_do_test("tests/resources/markup/markuptester/_langpack/lp_safe.html",
False,
PACKAGE_LANGPACK)
def test_lp_unsafe():
"Tests a language pack file that contains unsafe elements."
_do_test(
"tests/resources/markup/markuptester/_langpack/lp_unsafe.html",
True,
PACKAGE_LANGPACK)
_do_test("tests/resources/markup/markuptester/_langpack/lp_unsafe.html",
True,
PACKAGE_LANGPACK)
def test_lp_remote():
"Tests a language pack file that contains remote references."
_do_test(
"tests/resources/markup/markuptester/_langpack/lp_remote.html",
True,
PACKAGE_LANGPACK)
_do_test("tests/resources/markup/markuptester/_langpack/lp_remote.html",
True,
PACKAGE_LANGPACK)
def test_invalid_markup():
"Tests an markup file that is simply broken."
# Test for the banned test element
_do_test("tests/resources/markup/markuptester/bad_banned.xml",
True)
_do_test("tests/resources/markup/markuptester/bad_banned.xml", True)
result = _do_test("tests/resources/markup/markuptester/bad.xml",
True)
result = _do_test("tests/resources/markup/markuptester/bad.xml", True)
assert result.warnings
result = _do_test("tests/resources/markup/markuptester/"
"bad_script.xml",
False)
result = _do_test("tests/resources/markup/markuptester/bad_script.xml",
False)
assert result.infos

Просмотреть файл

@ -1,6 +1,6 @@
import os
import typedetection
import validator.typedetection as typedetection
from StringIO import StringIO
def _do_test(url, failure=True):

Просмотреть файл

@ -1,6 +1,5 @@
import testcases
import testcases.packagelayout as packagelayout
from errorbundler import ErrorBundle
import validator.testcases.packagelayout as packagelayout
from validator.errorbundler import ErrorBundle
from helper import _do_test
def test_blacklisted_files():
@ -9,7 +8,7 @@ def test_blacklisted_files():
safe."""
_do_test("tests/resources/packagelayout/ext_blacklist.xpi",
testcases.packagelayout.test_blacklisted_files,
packagelayout.test_blacklisted_files,
True)

Просмотреть файл

@ -2,8 +2,8 @@ import os
from StringIO import StringIO
import rdf
from rdf import RDFParser
import validator.rdf as rdf
from validator.rdf import RDFParser
def _load_rdf(file_):
"Loads an RDF file into a string."

Просмотреть файл

@ -1,7 +1,6 @@
import testcases
import testcases.targetapplication as targetapp
from constants import *
from errorbundler import ErrorBundle
import validator.testcases.targetapplication as targetapp
from validator.constants import *
from validator.errorbundler import ErrorBundle
from helper import _do_test
def test_valid_targetapps():
@ -88,5 +87,3 @@ def test_is_ff4():
True)
assert results.get_resource("ff4")

Просмотреть файл

@ -1,22 +1,21 @@
import testcases
import testcases.themes
from chromemanifest import ChromeManifest
import validator.testcases.themes as themes
from validator.chromemanifest import ChromeManifest
from helper import _do_test
def test_theme_chrome_manifest():
"Tests that a theme has a valid chrome manifest file."
_do_test("tests/resources/themes/pass.jar",
testcases.themes.test_theme_manifest,
themes.test_theme_manifest,
False)
def test_theme_bad_chrome_manifest():
"Tests that a theme has an invalid chrome manifest file."
_do_test("tests/resources/themes/fail.jar",
testcases.themes.test_theme_manifest)
themes.test_theme_manifest)
def test_no_chrome_manifest():
"Tests that validation is skipped if there is no chrome manifest."
assert testcases.themes.test_theme_manifest(None, {}, None) is None
assert themes.test_theme_manifest(None, {}, None) is None

Просмотреть файл

@ -1,10 +1,10 @@
import os
from errorbundler import ErrorBundle
from rdf import RDFParser
from xpi import XPIManager
from constants import *
import typedetection
from validator.errorbundler import ErrorBundle
from validator.rdf import RDFParser
from validator.xpi import XPIManager
from validator.constants import *
import validator.typedetection as typedetection
def _test_type(file_, expectation, failure=False):
"Tests a file against the expectations"

Просмотреть файл

@ -1,7 +1,7 @@
import zipfile
from zipfile import ZipFile
from xpi import XPIManager
from validator.xpi import XPIManager
def test_open():
"Test that the manager will open the package"