예제 #1
0
 def setUp(self):
     """Create a *very* fake models.File object"""
     # XXX: we should use a real mocking library probably
     self.myFile = FileModel()
     fh, fpath = tempfile.mkstemp(suffix='.jpeg')
     self.myFile.file = FieldFile(open(fpath, 'w'))
     self.myFile.file.write('\n')
예제 #2
0
 def __manufacture_file(self, title='(unset title)'):
     fh, fpath = tempfile.mkstemp(suffix='.jpeg')
     course_handle = self.contentsection.course.handle
     new_f = FileModel(section=self.contentsection,
                       title=title,
                       file=FieldFile(open(fpath, 'w')),
                       handle=course_handle)
     new_f.file.write('\n')
     new_f.save()
     new_f.image = new_f.create_ready_instance()
     new_f.image.save()
     self.files.append(new_f)
     return new_f
예제 #3
0
 def setUp(self):
     super(CourseMaterialsPageAndContentsTest, self).setUp()
     self.course = CourseModel.objects.get(id=1)
     self.section = self.course.contentsection_set.all()[0]
     self.poorfile = FileModel(course=self.course,
                               section=self.section,
                               handle=self.course.handle,
                               live_datetime=datetime.datetime(
                                   9999, 12, 12, 1, 1, 1),
                               title="XXXDELETEMETESTXXX")
     self.poorfile.save()
     self.poorfile.create_ready_instance()
     self.poorfile.image.save()