def test_project_config_validation_full(): config = { "vars": {"some_var": 20}, "directories": ["assets", "configs", "corpus", "scripts", "training"], "assets": [ { "dest": "x", "url": "https://example.com", "checksum": "63373dd656daa1fd3043ce166a59474c", }, { "dest": "y", "git": { "repo": "https://github.com/example/repo", "branch": "develop", "path": "y", }, }, ], "commands": [ { "name": "train", "help": "Train a model", "script": ["python -m spacy train config.cfg -o training"], "deps": ["config.cfg", "corpus/training.spcy"], "outputs": ["training/model-best"], }, {"name": "test", "script": ["pytest", "custom.py"], "no_skip": True}, ], "workflows": {"all": ["train", "test"], "train": ["train"]}, } errors = validate(ProjectConfigSchema, config) assert not errors
def test_doc_to_json_span(doc): """Test that Doc.to_json() includes spans""" doc.spans["test"] = [Span(doc, 0, 2, "test"), Span(doc, 0, 1, "test")] json_doc = doc.to_json() assert "spans" in json_doc assert len(json_doc["spans"]) == 1 assert len(json_doc["spans"]["test"]) == 2 assert json_doc["spans"]["test"][0]["start"] == 0 assert not schemas.validate(schemas.DocJSONSchema, json_doc)
def test_doc_to_json_underscore(doc): Doc.set_extension("json_test1", default=False) Doc.set_extension("json_test2", default=False) doc._.json_test1 = "hello world" doc._.json_test2 = [1, 2, 3] json_doc = doc.to_json(underscore=["json_test1", "json_test2"]) assert "_" in json_doc assert json_doc["_"]["json_test1"] == "hello world" assert json_doc["_"]["json_test2"] == [1, 2, 3] assert not schemas.validate(schemas.DocJSONSchema, json_doc)
def test_doc_to_json(doc): json_doc = doc.to_json() assert json_doc["text"] == "c d e " assert len(json_doc["tokens"]) == 3 assert json_doc["tokens"][0]["pos"] == "VERB" assert json_doc["tokens"][0]["tag"] == "VBP" assert json_doc["tokens"][0]["dep"] == "ROOT" assert len(json_doc["ents"]) == 1 assert json_doc["ents"][0]["start"] == 2 # character offset! assert json_doc["ents"][0]["end"] == 3 # character offset! assert json_doc["ents"][0]["label"] == "ORG" assert not schemas.validate(schemas.DocJSONSchema, json_doc)
def test_project_config_validation2(config, n_errors): errors = validate(ProjectConfigSchema, config) assert len(errors) == n_errors