Exemplo n.º 1
0
def test_copy_assignment_files(default_config, tmp_path):
    """Test that files are moved to the template repo directory and that
    ignored files are NOT moved.
    """
    default_config["course_directory"] = tmp_path
    assignment = "assignment1"
    files_to_ignore = default_config["files_to_ignore"]
    # first, set up the test course materials directory
    # and create some temporary files
    cmpath = Path(
        tmp_path, default_config["course_materials"], "release", assignment
    )
    cmpath.mkdir(parents=True)
    cmpath.joinpath("file1.txt").touch()
    cmpath.joinpath("file2.txt").touch()
    cmpath.joinpath(".DS_Store").touch()

    template_repo = abctemplate.create_template_dir(default_config, assignment)
    abctemplate.copy_assignment_files(
        default_config, template_repo, assignment
    )
    # Test that both text files have been moved to the template dir but that
    # the system .DS_Store is not there
    for afile in os.listdir(cmpath):
        if afile not in files_to_ignore:
            assert afile in os.listdir(template_repo)
        else:
            print(afile)
            assert afile not in os.listdir(template_repo)
Exemplo n.º 2
0
def test_copy_assignment_dirs(default_config, tmp_path, capfd):
    """Test that when there is a directory in the extra_files dir, things
    still copy as expected.
    """
    default_config["course_directory"] = tmp_path
    assignment = "assignment1"
    # first, set up the test course materials directory
    # and create some temporary files
    cmpath = Path(
        tmp_path, default_config["course_materials"], "release", assignment
    )
    cmpath.mkdir(parents=True)
    cmpath.joinpath("dummy-dir").mkdir()

    # Manually create the dir to just test the copy function
    template_path = Path(
        tmp_path, default_config["template_dir"], assignment + "-template"
    )
    template_path.mkdir(parents=True)
    abctemplate.copy_assignment_files(
        default_config, template_path, assignment
    )
    out, err = capfd.readouterr()
    print(out)
    assert "Oops - looks like" in out
Exemplo n.º 3
0
def test_copy_assignment_files_fails_nodir(default_config, tmp_path):
    # test that fails if nbgrader dir does not exist
    default_config["course_directory"] = tmp_path
    assignment = "assignment1"
    template_repo = abctemplate.create_template_dir(default_config, assignment)
    with pytest.raises(SystemExit):
        abctemplate.copy_assignment_files(default_config, template_repo,
                                          assignment)
Exemplo n.º 4
0
def test_copy_assignment_files(default_config, tmp_path):
    # test that contents are the same for target and source directory
    default_config["course_directory"] = tmp_path
    assignment = "assignment1"
    # first, set up the test nbgrader directory
    nbpath = Path(tmp_path, default_config["nbgrader_dir"], "release",
                  assignment)
    nbpath.mkdir(parents=True)
    # create some temporary files
    nbpath.joinpath("file1.txt").touch()
    nbpath.joinpath("file2.txt").touch()
    template_repo = abctemplate.create_template_dir(default_config, assignment)
    abctemplate.copy_assignment_files(default_config, template_repo,
                                      assignment)
    assert os.listdir(nbpath) == os.listdir(template_repo)