def add_attachment(self, filename, data): """ Add a binary attachment. Can be called multiple times to attach multiple files :param filename: name of the file to attach :type action_verb: string :param filename: file data to attach :type action_verb: binary """ attachment = create_attachment(filename, data) # Init document viewer settings (prevents writes on read) Settings(attachment) add_attachments([ attachment, ], self.attachments)
def test_create_attachment(self): file_field = self._create_test_file_field() att = create_attachment(file_field.filename, file_field.read()) self.assertTrue(att.file.size > 0) self.assertEquals(att.id, file_field.filename)
def _create_test_temp_attachment(self, token): filename = "{0}-test.pdf".format(token) attachment = create_attachment(filename, '') return attachment