# Path: validator/json_parser.py
# class ManifestJsonParser(object):
#     """Parser wrapper for manifest.json files."""
# 
#     def __init__(self, err, data, namespace=None):
#         self.err = err
#         self.data = json.loads(unicodehelper.decode(data))
# 
#     def get_applications(self):
#         """Return the list of supported applications."""
#         if ('applications' not in self.data or
#                 'gecko' not in self.data['applications']):
#             return []
#         app = self.data['applications']['gecko']
#         min_version = app.get('strict_min_version', u'42.0')
#         max_version = app.get('strict_max_version', u'*')
#         return [{u'guid': FIREFOX_GUID,
#                  u'min_version': min_version,
#                  u'max_version': max_version}]


import json
from validator.constants import FIREFOX_GUID
from validator.json_parser import ManifestJsonParser
                "id": "my@awesome.addon"
            }
        }
    }"""

manifest_json_with_versions = """{
        "name": "My Awesome Addon",
        "version": "1.25",

        "applications": {
            "gecko": {
                "id": "my@awesome.addon",
                "strict_min_version": "43.0",
                "strict_max_version": "50.*"
            }
        }
    }"""


def test_parser():
    parser = ManifestJsonParser(None, manifest_json)
    assert parser.data == json.loads(manifest_json)


def test_parser_no_applications():
    parser = ManifestJsonParser(None, """{"name": "foo"}""")
    assert parser.get_applications() == []


def test_get_applications():

# Path: validator/json_parser.py
# class ManifestJsonParser(object):
#     """Parser wrapper for manifest.json files."""
# 
#     def __init__(self, err, data, namespace=None):
#         self.err = err
#         self.data = json.loads(unicodehelper.decode(data))
# 
#     def get_applications(self):
#         """Return the list of supported applications."""
#         if ('applications' not in self.data or
#                 'gecko' not in self.data['applications']):
#             return []
#         app = self.data['applications']['gecko']
#         min_version = app.get('strict_min_version', u'42.0')
#         max_version = app.get('strict_max_version', u'*')
#         return [{u'guid': FIREFOX_GUID,
#                  u'min_version': min_version,
#                  u'max_version': max_version}]


# Path: tests/test_json_parser.py
import json
from validator.constants import FIREFOX_GUID
from validator.json_parser import ManifestJsonParser

                "id": "my@awesome.addon"
            }
        }
    }"""

manifest_json_with_versions = """{
        "name": "My Awesome Addon",
        "version": "1.25",

        "applications": {
            "gecko": {
                "id": "my@awesome.addon",
                "strict_min_version": "43.0",
                "strict_max_version": "50.*"
            }
        }
    }"""


def test_parser():
    parser = ManifestJsonParser(None, manifest_json)
    assert parser.data == json.loads(manifest_json)


def test_parser_no_applications():
    parser = ManifestJsonParser(None, """{"name": "foo"}""")
    assert parser.get_applications() == []


def test_get_applications():

    parser = ManifestJsonParser(None, manifest_json)