Пример #1
0
def test_valid():
    """
    Tests that a valid config file contains the required
    parameter titles
    """
    load_config()
    load_and_validate()
Пример #2
0
def test_valid():
    """
    Tests that a valid config file does not throw
    any errors when validated
    """
    load_config()
    load_and_validate()
Пример #3
0
def test_missing_subtype_module():
    """
    """
    load_config(python={
        "include_main_file": False,
        "include_init_files": False
    })
    load_and_validate()
Пример #4
0
def test_get_sidebar_default():
    """
    """
    load_config(exclude=["sidebar"])
    load_and_validate()

    response = config_manager.get("sidebar")
    assert response is False
Пример #5
0
def test_get_python_default():
    """
    """
    load_config(exclude=["python"])
    load_and_validate()

    response = config_manager.get("python")
    assert response is None
Пример #6
0
def test_get_title_prefix_default():
    """
    """
    load_config(exclude=["title_prefix"])
    load_and_validate()

    response = config_manager.get("title_prefix")
    assert response == ""
Пример #7
0
def test_get_sidebar():
    """
    """
    expected = True

    load_config(sidebar=expected)
    load_and_validate()

    response = config_manager.get("sidebar")
    assert response == expected
Пример #8
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
Пример #9
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
Пример #10
0
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
Пример #11
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
Пример #12
0
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()
Пример #13
0
def test_not_defined():
    """
    Tests that a this config is optional
    """
    load_config(exclude=["python"])
    load_and_validate()
Пример #14
0
def test_not_defined():
    """
    """
    load_config(exclude=["sidebar"])
    load_and_validate()
Пример #15
0
def test_not_defined():
    """
    """
    load_config(exclude=["title_prefix"])
    load_and_validate()