Exemplo n.º 1
0
def test_check_fails():
    complete = TomlFile(fixtures_dir / "complete.toml")
    content = complete.read()["tool"]["poetry"]
    content["this key is not in the schema"] = ""

    if PY2:
        expected = ("Additional properties are not allowed "
                    "(u'this key is not in the schema' was unexpected)")
    else:
        expected = ("Additional properties are not allowed "
                    "('this key is not in the schema' was unexpected)")

    assert Poetry.check(content) == {"errors": [expected], "warnings": []}
Exemplo n.º 2
0
    def handle(self):
        # Load poetry config and display errors, if any
        poetry_file = Poetry.locate(Path.cwd())
        config = TomlFile(str(poetry_file)).read()["tool"]["poetry"]
        check_result = Poetry.check(config, strict=True)
        if not check_result["errors"] and not check_result["warnings"]:
            self.info("All set!")

            return 0

        for error in check_result["errors"]:
            self.line("<error>Error: {}</error>".format(error))

        for error in check_result["warnings"]:
            self.line("<warning>Warning: {}</warning>".format(error))

        return 1
Exemplo n.º 3
0
def test_check():
    complete = fixtures_dir / 'complete.toml'
    with complete.open() as f:
        content = toml.loads(f.read())['tool']['poetry']

    assert Poetry.check(content)
Exemplo n.º 4
0
def test_check():
    complete = TomlFile(fixtures_dir / "complete.toml")
    content = complete.read()["tool"]["poetry"]

    assert Poetry.check(content) == {"errors": [], "warnings": []}
Exemplo n.º 5
0
def test_check():
    complete = fixtures_dir / "complete.toml"
    with complete.open() as f:
        content = toml.loads(f.read())["tool"]["poetry"]

    assert Poetry.check(content)
Exemplo n.º 6
0
def test_check():
    complete = TomlFile(fixtures_dir / "complete.toml")
    content = complete.read(raw=True)["tool"]["poetry"]

    assert Poetry.check(content)
Exemplo n.º 7
0
def test_check_fails():
    complete = TomlFile(fixtures_dir / "complete.toml")
    content = complete.read()["tool"]["poetry"]
    content["this key is not in the schema"] = ""
    with pytest.raises(InvalidProjectFile):
        Poetry.check(content)
Exemplo n.º 8
0
 def check(cls, config, strict=False):
     json.SCHEMA_DIR = Path(here / "schemas").as_posix()
     return Poetry.check(config, strict=strict)