Skip to content

Commit

Permalink
issues #9 part 2, test extracting specific students.
Browse files Browse the repository at this point in the history
  • Loading branch information
ConorSheehan1 committed Apr 19, 2020
1 parent b5c04e9 commit 32aca2d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,6 @@ dmypy.json
# Editor config
.idea
.vscode

# Docx lock file
*.~lock*
20 changes: 19 additions & 1 deletion tests/integration/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from src.file_management.compile import compile_c


class TestMainSafeMode(unittest.TestCase):
class Base:
# needed as class variables to run teardown after all tests, instead of each test.
cwd = os.path.join("tests", "fixtures")
safe_cwd = os.path.join(cwd, "example")
Expand Down Expand Up @@ -61,6 +61,8 @@ def test_01_safe_mode(self):
assert os.path.exists(self.safe_cwd)
assert os.path.exists(self.zip_path)


class TestMainSafeModeSharedState(Base, unittest.TestCase):
def test_02_unzip(self):
"""
unzip_outer should unzip the main .zip archive
Expand Down Expand Up @@ -121,5 +123,21 @@ def test_07_feedback_content(self):
for expected_cell, actual_cell in zip(expected_row.cells, actual_row.cells):
assert expected_cell.text == actual_cell.text


class TestMainSafeModeSpecificStudents(Base, unittest.TestCase):
def test_02_unzip(self):
"""
when students are passed, unzip_outer should only extract files containing that students name
"""
assert not os.path.exists(self.example_student_dir)
unzip_outer(self.safe_zip_path, ["fake_student", "other_fake_student"])

# final_fake_student is the only one not extracted, all others are extracted
assert not os.path.exists(self.example_student_dir)
for dirname in ["fake_student_2012345", "other_fake_student_2012346"]:
student_dir = os.path.join(self.safe_cwd, dirname)
assert os.path.exists(student_dir)


if __name__ == "__main__":
unittest.main()

0 comments on commit 32aca2d

Please sign in to comment.