コード例 #1
0
ファイル: webapp.py プロジェクト: almet/amo-validator
def detect_webapp_raw(err, webapp):
    """
    Parse and validate a webapp based on the dict version of the manifest.
    """

    from validator.specs.webapps import WebappSpec
    ws = WebappSpec(webapp, err)
    ws.validate()

    # This magic number brought to you by @cvan (see bug 770755)
    if "name" in webapp and len(webapp["name"]) > 9:
        err.warning(
                err_id=("webapp", "b2g", "name_truncated"),
                warning="App name may be truncated on Firefox OS devices.",
                description="Your app's name is long enough to possibly be "
                            "truncated on Firefox OS devices. Consider using "
                            "a shorter name for your app.")
コード例 #2
0
ファイル: test_webapp.py プロジェクト: almet/amo-validator
    def test_path(self):
        """Test that paths are tested properly for allowances."""

        s = WebappSpec("{}", ErrorBundle())

        eq_(s._path_valid("*"), False)
        eq_(s._path_valid("*", can_be_asterisk=True), True)
        eq_(s._path_valid("/foo/bar"), False)
        eq_(s._path_valid("/foo/bar", can_be_absolute=True), True)
        eq_(s._path_valid("//foo/bar"), False)
        eq_(s._path_valid("//foo/bar", can_be_absolute=True), False)
        eq_(s._path_valid("//foo/bar", can_be_relative=True), False)
        eq_(s._path_valid("http://asdf/"), False)
        eq_(s._path_valid("https://asdf/"), False)
        eq_(s._path_valid("ftp://asdf/"), False)
        eq_(s._path_valid("http://asdf/", can_have_protocol=True), True)
        eq_(s._path_valid("https://asdf/", can_have_protocol=True), True)
        # No FTP for you!
        eq_(s._path_valid("ftp://asdf/", can_have_protocol=True), False)
        eq_(s._path_valid("data:asdf"), False)
        eq_(s._path_valid("data:asdf", can_be_data=True), True)