Esempio n. 1
0
def test_gatorgrader_home_is_set_after_os_dictionary_set_no_trailing(tmpdir):
    """Ensure that the GATORGRADER_HOME environment variable is set."""
    tmpdir.mkdir("gatorgrader")
    os.environ["GATORGRADER_HOME"] = str(tmpdir) + "/" + "gatorgrader"
    gatorgrader_home = util.get_gatorgrader_home()
    assert gatorgrader_home is not None
    assert "gatorgrader" in gatorgrader_home
Esempio n. 2
0
def test_gatorgrader_home_is_set_after_os_dictionary_set_wrong_directory(
        tmpdir):
    """Ensure that the GATORGRADER_HOME environment variable is set."""
    os.environ["GATORGRADER_HOME"] = str(tmpdir) + "/" + "INCORRECT"
    gatorgrader_home = util.get_gatorgrader_home()
    assert gatorgrader_home is not None
    assert "gatorgrader" in gatorgrader_home
Esempio n. 3
0
def get_source(checker_paths=[]):
    """Load all of the checkers using pluginbase."""
    # define the "package" in which the checks reside
    # the term "package" corresponds to "module.sub-module"
    checker_base = PluginBase(package=constants.packages.Checks)
    # remove any directories from the path listings that are Nothing (i.e., "")
    # this case occurs when the optional --checkerdir is not provided on command-line
    if constants.markers.Nothing in checker_paths:
        checker_paths.remove(constants.markers.Nothing)
    # Create the directory where the internal checkers live inside of GatorGrader.
    # Note that this directory includes the home for GatorGrader, which can be set
    # by an environment variable and otherwise defaults to the directory from which
    # GatorGrader was run and then the directory where internal checkers are stored.
    internal_checker_path = files.create_path(
        constants.checkers.Internal_Checkers_Dir,
        home=util.get_gatorgrader_home())
    # create the listing of the paths that could contain checkers, including
    # all of the provided paths for external checkers and the directory that
    # contains all of the internal checkers provided by GatorGrader
    all_checker_paths = checker_paths + [str(internal_checker_path)]
    # Create and return a source of checkers using PluginBase.
    # The documentation for this function advices that you
    # give an identifier to the source for the plugins
    # because this will support saving and transfer, if needed.
    # Only perform this operation if the checker source is None,
    # meaning that it has not already been initialized.
    # pylint: disable=global-statement
    global CHECKER_SOURCE
    if CHECKER_SOURCE is None:
        CHECKER_SOURCE = checker_base.make_plugin_source(
            identifier=constants.checkers.Plugin_Base_Identifier,
            searchpath=all_checker_paths,
        )
    return CHECKER_SOURCE
Esempio n. 4
0
def test_gatorgrader_home_is_set():
    """Ensure that the GATORGRADER_HOME environment variable is set."""
    testargs = [os.getcwd()]
    with patch.object(sys, "argv", testargs):
        gatorgrader_home = util.get_gatorgrader_home()
        # If GATORGRADER_HOME is not set, then it will be set
        # by default to the home directory. These assertions
        # use Pathlib objects to do the comparison so as to
        # ensure that they pass across all operating systems
        current_working_directory = files.create_program_path()
        assert gatorgrader_home is not None
        assert files.create_path(home=gatorgrader_home) == files.create_path(
            home=current_working_directory)
Esempio n. 5
0
def invoke_file_in_directory_check(filecheck, directory):
    """Check to see if the file is in the directory"""
    # get the home directory for checking and then check for file
    gatorgrader_home = util.get_gatorgrader_home()
    was_file_found = files.check_file_in_directory(
        filecheck, gatorgrader_home + directory)
    # construct the message about whether or not the file exists
    # note that no diagnostic is needed and the result is boolean
    message = ("The file " + filecheck + " exists in the " + directory +
               SPACE + "directory")
    # produce the final report and return the result
    # note that update_report is not called because
    # there will never be a diagnostic for this invoke
    report.add_result(message, was_file_found, NO_DIAGNOSTIC)
    return was_file_found
Esempio n. 6
0
def invoke_file_in_directory_check(filecheck, directory):
    """Check to see if the file is in the directory"""
    # get the home directory for checking and then check for file
    gatorgrader_home = util.get_gatorgrader_home()
    was_file_found = files.check_file_in_directory(
        filecheck, gatorgrader_home + directory
    )
    # construct the message about whether or not the file exists
    message = (
        "The file " + filecheck + " exists in the " + directory + SPACE + "directory"
    )
    # diagnostic is created when file does not exist in specified directory
    # call report_result to update report for this check
    diagnostic = (
        "Did not find the specified file in the " + directory + SPACE + "directory"
    )
    report_result(was_file_found, message, diagnostic)
    return was_file_found
Esempio n. 7
0
def test_gatorgrader_home_is_set_after_os_dictionary_set():
    """Ensure that the gatorgrader_HOME environment variable is set"""
    os.environ[
        "GATORGRADER_HOME"] = "/home/gkapfham/working/source/gatorgrader/"
    gatorgrader_home = util.get_gatorgrader_home()
    assert gatorgrader_home is not None
Esempio n. 8
0
def test_gatorgrader_home_is_set():
    """Ensure that the gatorgrader_HOME environment variable is set"""
    gatorgrader_home = util.get_gatorgrader_home()
    assert gatorgrader_home is not None