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
19 students: Bilbo Baggins, Frodo Baggins, Aragorn
89 pgp-key: 0x0123456789ABCDEF
98 emails: bb@shire.org, bb@greyhavens.net
105 emails: a@awesome.gov
109 class StubCourse (object):
110 """Manage a course directory for testing.
112 >>> course = StubCourse()
113 >>> course.print_tree()
117 def __init__(self, load=True):
118 self.basedir = _tempfile.mkdtemp(prefix='pygrader-tmp-')
120 self.mailbox = _os_path.join(self.basedir, 'mail')
121 course_conf = _os_path.join(self.basedir, 'course.conf')
122 with open(course_conf, 'w') as f:
125 self.course = _load_course(basedir=self.basedir)
131 _shutil.rmtree(self.basedir)
136 for dirpath,dirnames,filenames in _os.walk(self.basedir):
137 for dirname in dirnames:
138 paths.append(_os_path.join(dirpath, dirname))
139 for filename in filenames:
140 paths.append(_os_path.join(dirpath, filename))
141 for i,path in enumerate(paths):
142 paths[i] = _os_path.relpath(path, self.basedir)
146 def print_tree(self):
147 for path in self.tree():