Exemplo n.º 1
0
def test_module_json_parser():
    contents = """
{
  "author": "Name Surname <*****@*****.**>",
  "description": "This is Yotta library",
  "homepage": "https://yottabuild.org",
  "keywords": [
    "mbed",
    "Yotta"
  ],
  "licenses": [
    {
      "type": "Apache-2.0",
      "url": "https://spdx.org/licenses/Apache-2.0"
    }
  ],
  "name": "YottaLibrary",
  "repository": {
    "type": "git",
    "url": "[email protected]:username/repo.git"
  },
  "version": "1.2.3",
  "customField": "Custom Value"
}
"""

    mp = parser.ModuleJsonManifestParser(contents)
    assert not jsondiff.diff(
        mp.as_dict(),
        {
            "name": "YottaLibrary",
            "description": "This is Yotta library",
            "homepage": "https://yottabuild.org",
            "keywords": ["mbed", "Yotta"],
            "license": "Apache-2.0",
            "platforms": ["*"],
            "frameworks": ["mbed"],
            "export": {
                "exclude": ["tests", "test", "*.doxyfile", "*.pdf"]
            },
            "authors": [{
                "email": "*****@*****.**",
                "name": "Name Surname"
            }],
            "version": "1.2.3",
            "repository": {
                "type": "git",
                "url": "[email protected]:username/repo.git"
            },
            "customField": "Custom Value",
        },
    )
Exemplo n.º 2
0
def test_module_json_parser():
    contents = """
{
  "author": "Name Surname <*****@*****.**>",
  "description": "This is Yotta library",
  "homepage": "https://yottabuild.org",
  "keywords": [
    "mbed",
    "Yotta"
  ],
  "licenses": [
    {
      "type": "Apache-2.0",
      "url": "https://spdx.org/licenses/Apache-2.0"
    }
  ],
  "name": "YottaLibrary",
  "repository": {
    "type": "git",
    "url": "[email protected]:username/repo.git"
  },
  "version": "1.2.3",
  "dependencies": {
    "usefulmodule": "^1.2.3",
    "simplelog": "ARMmbed/simplelog#~0.0.1"
  },
  "customField": "Custom Value"
}
"""

    raw_data = parser.ModuleJsonManifestParser(contents).as_dict()
    raw_data["dependencies"] = sorted(raw_data["dependencies"],
                                      key=lambda a: a["name"])
    assert not jsondiff.diff(
        raw_data,
        {
            "name":
            "YottaLibrary",
            "description":
            "This is Yotta library",
            "homepage":
            "https://yottabuild.org",
            "keywords": ["mbed", "Yotta"],
            "license":
            "Apache-2.0",
            "platforms": ["*"],
            "frameworks": ["mbed"],
            "export": {
                "exclude": ["tests", "test", "*.doxyfile", "*.pdf"]
            },
            "authors": [{
                "email": "*****@*****.**",
                "name": "Name Surname"
            }],
            "version":
            "1.2.3",
            "repository": {
                "type": "git",
                "url": "[email protected]:username/repo.git"
            },
            "dependencies": [
                {
                    "name": "simplelog",
                    "version": "ARMmbed/simplelog#~0.0.1",
                    "frameworks": ["mbed"],
                },
                {
                    "name": "usefulmodule",
                    "version": "^1.2.3",
                    "frameworks": ["mbed"]
                },
            ],
            "customField":
            "Custom Value",
        },
    )