Beispiel #1
0
def test_invalid_element_type():
    """
    tests that a complex type with an invalid
    element type throws an error
    """
    load_config(sources=["path1/", 2])
    load_and_validate_fails()
Beispiel #2
0
def test_invalid_type():
    """
    tests that a config file with an invalid type
    for sources throws an error
    """
    load_config(sources="wrong")
    load_and_validate_fails()
Beispiel #3
0
def test_invalid_name():
    """
    tests that a missing config parameter that is required
    throws an error
    """
    load_config(exclude=["sources"])
    load_and_validate_fails()
Beispiel #4
0
def test_tilde_in_source():
    """
    Tests that a source does not contain any non relative paths
    i.e. tilde (~)
    """
    load_config(sources=["path1/tets", "~/path2/wrong.py"])
    load_and_validate_fails()
def test_valid():
    """
    Tests that a valid config file contains the required
    parameter titles
    """
    load_config()
    load_and_validate()
Beispiel #6
0
def test_valid():
    """
    Tests that a valid config file does not throw
    any errors when validated
    """
    load_config()
    load_and_validate()
Beispiel #7
0
def test_get_title_prefix_default():
    """
    """
    load_config(exclude=["title_prefix"])
    load_and_validate()

    response = config_manager.get("title_prefix")
    assert response == ""
def test_get_python_default():
    """
    """
    load_config(exclude=["python"])
    load_and_validate()

    response = config_manager.get("python")
    assert response is None
def test_missing_subtype_module():
    """
    """
    load_config(python={
        "include_main_file": False,
        "include_init_files": False
    })
    load_and_validate()
Beispiel #10
0
def test_get_sidebar_default():
    """
    """
    load_config(exclude=["sidebar"])
    load_and_validate()

    response = config_manager.get("sidebar")
    assert response is False
def test_invalid_subtype_module():
    """
    """
    load_config(python={
        "include_init_files": False,
        "include_main_file": False,
        "module": 6,
    })
    load_and_validate_fails()
Beispiel #12
0
def test_get_titles():
    """
    """
    expected = [{"source": "mysourcefile.py", "title": "wowsuchdocs"}]

    load_config(titles=expected)
    load_and_validate()

    response = config_manager.get("titles")
    assert response == expected
Beispiel #13
0
def test_get_title_prefix():
    """
    """
    expected = "myprefix"

    load_config(title_prefix=expected)
    load_and_validate()

    response = config_manager.get("title_prefix")
    assert response == expected
Beispiel #14
0
def test_get_sidebar():
    """
    """
    expected = True

    load_config(sidebar=expected)
    load_and_validate()

    response = config_manager.get("sidebar")
    assert response == expected
def test_get_python():
    """
    """
    expected = {
        "include_init_files": True,
        "include_main_file": True,
        "module": "mymod",
    }

    load_config(python=expected)
    load_and_validate()

    response = config_manager.get("python")
    assert response == expected
Beispiel #16
0
def test_get_values():
    """
    tests that config values are loaded properly
    """
    expected = [
        "path1/*",
        "path1/anotherpath/*",
        "path1/anotherpath2/",
        "path1/anotherpath2/file1.py",
    ]

    load_config(sources=expected)
    load_and_validate()

    response = config_manager.get("sources")
    assert len(expected) == len(response)
    for path in expected:
        assert path in response
def test_repo_manager_simple_config():
    """
    Tests running the repo manager with the
    most basic config that can be provided
    """
    load_config(sources=["biit_server/"],
                title_prefix="",
                title_suffix="",
                python={})
    load_and_validate()

    Documenter.install()

    owner = "biit-407"
    repo = "biit-server"
    ghapi = GithubAPI(os.environ["GH_PAT"])
    rm = RepoManager(owner, repo, ghapi)

    rm.setup()

    rm.install()

    rm.document(sources=["biit_server/"], extensions=["py"])
    # no publish, just testing

    files_to_check = FileUtil.query_directory("../biit-server/biit_server/",
                                              [".py"])
    files_found = FileUtil.query_directory("../biit-server-wiki/", [".md"])

    for fc in files_to_check:
        fc_name = fc[fc.index("biit_server"):-3]
        fc_name = fc_name.replace("/", ".")
        found = False
        for ff in files_found:
            if fc_name in ff:
                found = True
                break
        if fc_name.endswith("__init__") or fc_name.endswith("__main__"):
            continue
        assert found, f"could not find [{fc_name}]"

    rm.cleanup()
Beispiel #18
0
def test_invalid_subtype_title():
    """
    """
    load_config(titles=[{"source": "valid", "title": 2}])
    load_and_validate_fails()
Beispiel #19
0
def test_missing_subtype_title():
    """
    """
    load_config(titles=[{"source": "valid"}])
    load_and_validate_fails()
Beispiel #20
0
def test_not_defined():
    """
    """
    load_config(exclude=["sidebar"])
    load_and_validate()
def test_invalid_type():
    """
    """
    load_config(python=3)
    load_and_validate_fails()
def test_not_defined():
    """
    Tests that a this config is optional
    """
    load_config(exclude=["python"])
    load_and_validate()
Beispiel #23
0
def test_invalid_type():
    """
    """
    load_config(titles=3)
    load_and_validate_fails()
Beispiel #24
0
def test_not_defined():
    """
    """
    load_config(exclude=["title_prefix"])
    load_and_validate()
Beispiel #25
0
def test_invalid_type():
    """
    """
    load_config(sidebar=3)
    load_and_validate_fails()