Commits

Olemis Lang committed d6d43ab

Trac RPC [ refs rpc-306 ] Test case to verify import of sample wiki data

Comments (0)

Files changed (1)

trunk/tracrpc/tests/admin.py

                                                'feed2.png', 'update 2\n',
                                                xmlrpclib.Binary(image_in.getvalue())]
                                    }], 'user2', xmlrpclib.DateTime(timestamp))
-        # TODO: Assertions for attachment meta-data
         self.assertEquals(image_in.getvalue(), self.admin.wiki.getAttachment(
                                                 'TestAdminAttachments/feed2.png').data)
         # Update attachment (adding new)
                                    }], 'user2', xmlrpclib.DateTime(timestamp))
         self.assertEquals(image_in.getvalue(), self.admin.wiki.getAttachment(
                                                 'TestAdminAttachments/feed2.2.png').data)
-        # TODO: Assertions for attachment meta-data
-
         # List attachments
         self.assertEquals(['TestAdminAttachments/feed2.2.png', 'TestAdminAttachments/feed2.png'],
                         sorted(self.admin.wiki.listAttachments('TestAdminAttachments')))
         # List attachments again
         self.assertEquals([], self.admin.wiki.listAttachments('TestAdminAttachments'))
 
+    def test_admin_import_wiki_sample(self):
+        # Import data
+        # See http://trac-hacks.org/wiki/SubProjectsPatch (version=3)
+        date_v1 = datetime.datetime(2008, 3, 21, 22, 33, 48)
+        date_v2 = datetime.datetime(2008, 3, 21, 22, 35, 26)
+        date_v3 = datetime.datetime(2008, 3, 22, 12, 56, 24)
+        date_attachment = datetime.datetime(2011, 2, 15, 11, 49, 26)
+
+        self.admin.admin.exec_as([{'methodName' : 'wiki.putPage',
+                                   'params' : ['AdminImportWikiSample', 'Ver 1',
+                                             {'comment' : 'created by progrium'}]
+                                   }], 'progrium', xmlrpclib.DateTime(date_v1))
+        self.admin.admin.exec_as([{'methodName' : 'wiki.putPage',
+                                   'params' : ['AdminImportWikiSample', 'Ver 2',
+                                             {'comment' : 'version 2'}]
+                                   }], 'progrium', xmlrpclib.DateTime(date_v2))
+        self.admin.admin.exec_as([{'methodName' : 'wiki.putPage',
+                                   'params' : ['AdminImportWikiSample', 'Ver 3',
+                                             {'comment' : 'version 3'}]
+                                   }], 'ThurnerRupert',
+                                 xmlrpclib.DateTime(date_v3))
+
+        # Attach file
+        self.admin.admin.exec_as([{'methodName' : 'wiki.putAttachmentEx',
+                                   'params' : ['AdminImportWikiSample',
+                                             'file.txt', 'Image file',
+                                             xmlrpclib.Binary('contents ok')]
+                                   }], 'k.antczak@domain.com',
+                                 xmlrpclib.DateTime(date_attachment))
+
+        # Assertions
+        self.assertEquals({'comment': 'version 3',
+                           'lastModified': xmlrpclib.DateTime(date_v3),
+                           'version': 3, 'name': 'AdminImportWikiSample',
+                           'author': 'ThurnerRupert'},
+                          self.admin.wiki.getPageInfo('AdminImportWikiSample'))
+        self.assertEquals([{'comment': 'created by progrium',
+                            'lastModified': xmlrpclib.DateTime(date_v1), 
+                            'version': 1, 'name': 'AdminImportWikiSample',
+                            'author': 'progrium'}, 
+                           {'comment': 'version 2', 
+                            'lastModified': xmlrpclib.DateTime(date_v2),
+                            'version': 2, 'name': 'AdminImportWikiSample',
+                            'author': 'progrium'}, 
+                           {'comment': 'version 3',
+                            'lastModified': xmlrpclib.DateTime(date_v3),
+                            'version': 3, 'name': 'AdminImportWikiSample',
+                            'author': 'ThurnerRupert'}],
+                          [self.admin.wiki.getPageInfoVersion('AdminImportWikiSample', v)
+                           for v in xrange(1, 4)])
+        self.assertEquals([['file.txt', 'Image file', len('contents ok'),
+                           xmlrpclib.DateTime(date_attachment),
+                           'k.antczak@domain.com']],
+                          self.admin.wiki.listAttachmentsEx('AdminImportWikiSample'))
+
 
 class RpcAdminMilestoneTestCase(TracRpcTestCase):
     BH_IN_DEFAULT_PRODUCT = True