Back to index

moin  1.9.0~rc2
Public Member Functions
MoinMoin._tests.test_packages.TestRealPackageInstallation Class Reference

List of all members.

Public Member Functions

def create_package
def testAttachments_after_page_creation
def testAttachments_without_page_creation

Detailed Description

Definition at line 120 of file test_packages.py.


Member Function Documentation

Definition at line 123 of file test_packages.py.

00123 
00124     def create_package(self, script, page=None):
00125         # creates the package example zip file
00126         userid = user.getUserIdentification(self.request)
00127         COMPRESSION_LEVEL = zipfile.ZIP_DEFLATED
00128         zip_file = tempfile.mkstemp(suffix='.zip')[1]
00129         zf = zipfile.ZipFile(zip_file, "w", COMPRESSION_LEVEL)
00130         if page:
00131             timestamp = wikiutil.version2timestamp(page.mtime_usecs())
00132             zi = zipfile.ZipInfo(filename="1", date_time=datetime.fromtimestamp(timestamp).timetuple()[:6])
00133             zi.compress_type = COMPRESSION_LEVEL
00134             zf.writestr(zi, page.get_raw_body().encode("utf-8"))
00135         zf.writestr("1_attachment", "sample attachment")
00136         zf.writestr(MOIN_PACKAGE_FILE, script.encode("utf-8"))
00137         zf.close()
00138         return zip_file

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 139 of file test_packages.py.

00139 
00140     def testAttachments_after_page_creation(self):
00141         become_trusted(self.request)
00142         pagename = u'PackageTestPageCreatedFirst'
00143         page = create_page(self.request, pagename, u"This page has not yet an attachments dir")
00144         script = u"""MoinMoinPackage|1
00145 AddRevision|1|%(pagename)s
00146 AddAttachment|1_attachment|my_test.txt|%(pagename)s
00147 Print|Thank you for using PackagePages!
00148 """ % {"pagename": pagename}
00149         zip_file = self.create_package(script, page)
00150         package = ZipPackage(self.request, zip_file)
00151         package.installPackage()
00152         assert Page(self.request, pagename).exists()
00153         assert AttachFile.exists(self.request, pagename, "my_test.txt")
00154 
00155         nuke_page(self.request, pagename)
00156         os.unlink(zip_file)

Here is the call graph for this function:

Definition at line 157 of file test_packages.py.

00157 
00158     def testAttachments_without_page_creation(self):
00159         become_trusted(self.request)
00160         pagename = u"PackageAttachmentAttachWithoutPageCreation"
00161         script = u"""MoinMoinPackage|1
00162 AddAttachment|1_attachment|my_test.txt|%(pagename)s
00163 Print|Thank you for using PackagePages!
00164 """ % {"pagename": pagename}
00165         zip_file = self.create_package(script)
00166         package = ZipPackage(self.request, zip_file)
00167         package.installPackage()
00168         assert not Page(self.request, pagename).exists()
00169         assert AttachFile.exists(self.request, pagename, "my_test.txt")
00170 
00171         nuke_page(self.request, pagename)
00172         os.unlink(zip_file)
00173 

Here is the call graph for this function:


The documentation for this class was generated from the following file: