Esempio n. 1
0
def test_get_workspace_deps_with_wrong_name():
    pj = PackageJson("/packages/foo/package.json")
    pj.data = {
        "dependencies": {
            "@yandex-int/bar": "workspace:../bar",
        },
    }

    def load_mock(cls, path):
        p = PackageJson(path)
        p.data = {
            "name": "@shouldbe/{}".format(os.path.basename(os.path.dirname(path))),
        }
        return p
    PackageJson.load = classmethod(load_mock)

    with pytest.raises(PackageJsonWorkspaceError) as e:
        pj.get_workspace_deps()

    assert str(e.value) == "Workspace dependency name mismatch, found '@yandex-int/bar' instead of '@shouldbe/bar' in /packages/foo/package.json"
Esempio n. 2
0
def test_get_workspace_deps_ok():
    pj = PackageJson("/packages/foo/package.json")
    pj.data = {
        "dependencies": {
            "@yandex-int/bar": "workspace:../bar",
        },
        "devDependencies": {
            "@yandex-int/baz": "workspace:../baz",
        },
    }

    def load_mock(cls, path):
        p = PackageJson(path)
        p.data = {
            "name": "@yandex-int/{}".format(os.path.basename(os.path.dirname(path))),
        }
        return p
    PackageJson.load = classmethod(load_mock)

    ws_deps = pj.get_workspace_deps()

    assert len(ws_deps) == 2
    assert ws_deps[0].path == "/packages/bar/package.json"
    assert ws_deps[1].path == "/packages/baz/package.json"