4 import os.path as _os_path
5 import shutil as _shutil
6 import tempfile as _tempfile
8 from pygrader.storage import load_course as _load_course
14 assignments: Attendance 1, Attendance 2, Attendance 3, Attendance 4,
15 Attendance 5, Attendance 6, Attendance 7, Attendance 8, Attendance 9,
16 Assignment 1, Assignment 2, Exam 1, Exam 2
20 students: Bilbo Baggins, Frodo Baggins, Aragorn
88 nickname: phys-101 robot
89 emails: phys101@tower.edu
95 pgp-key: 0x0123456789ABCDEF
104 emails: bb@shire.org, bb@greyhavens.net
111 emails: a@awesome.gov
115 class StubCourse (object):
116 """Manage a course directory for testing.
118 >>> course = StubCourse()
119 >>> course.print_tree()
123 def __init__(self, load=True):
124 self.basedir = _tempfile.mkdtemp(prefix='pygrader-tmp-')
126 self.mailbox = _os_path.join(self.basedir, 'mail')
127 course_conf = _os_path.join(self.basedir, 'course.conf')
128 with open(course_conf, 'w') as f:
131 self.course = _load_course(basedir=self.basedir)
137 _shutil.rmtree(self.basedir)
142 for dirpath,dirnames,filenames in _os.walk(self.basedir):
143 for dirname in dirnames:
144 paths.append(_os_path.join(dirpath, dirname))
145 for filename in filenames:
146 paths.append(_os_path.join(dirpath, filename))
147 for i,path in enumerate(paths):
148 paths[i] = _os_path.relpath(path, self.basedir)
152 def print_tree(self):
153 for path in self.tree():