Esempio n. 1
0
def test_read_config_given_valid_json_returns_nested_objects(filename_for_sample_valid_config):
    # Act
    config = confreader.read_config(filename_for_sample_valid_config)

    # Assert
    assert len(vars(config)) == 1
    assert config.locations.problem_root == "problems"
    assert config.locations.report_root == "reports"
Esempio n. 2
0
def read_config(args):
    if args.conf is not None:
        config_file = os.path.abspath(args.conf)
    else:
        config_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, "conf"))
        config_file = os.path.join(config_dir, "grader.conf")

    if not os.path.exists(config_file):
        raise EnvironmentError("Configuration file '{config_file}' not found. Please create one or copy it from grader.conf.template.".format(**locals()))
    return confreader.read_config(config_file)
Esempio n. 3
0
def read_problem_config(problem):
    config_filename = os.path.join(problem.root_dir, "problem.conf")
    return confreader.read_config(config_filename)
Esempio n. 4
0
def test_read_config_given_nonexistent_file_throws(non_existent_filename):
    # Assert
    with pytest.raises(Exception):
        config = confreader.read_config(non_existent_filename)
Esempio n. 5
0
def test_read_config_given_invalid_json_throws(filename_for_invalid_config):
    # Assert
    with pytest.raises(Exception):
        config = confreader.read_config(filename_for_invalid_config)