from unittest import makeSuite from base import SquishdotBase from re import search from string import index from DateTime import DateTime class PostingTests(SquishdotBase): def testAddArticle(self): "Check the SquishSite.addPosting method works" id = self._addPosting(title = 'testSquishSiteAddPosting', author = 'tester', body = 'body', email = 'email', notify = 1, encoding = 'Plain', subject = 'test subject', summary = 'summary', dept = 'dept') Posting = self.Site[id] assert Posting.title =='testSquishSiteAddPosting' assert Posting.author =='tester' assert Posting.body ==['body'] assert Posting.email =='email' assert Posting.notify ==1 assert Posting.encoding =='Plain' assert Posting.subject =='test subject' assert Posting.summary ==['summary'] assert Posting.dept =='dept' def testAddArticleTTW(self): "Check the SquishSite.addPosting method works TTW" REQUEST=self.Site.REQUEST RESPONSE=REQUEST.RESPONSE REQUEST['title'] = 'testSquishSiteAddPosting' REQUEST['author'] = 'tester' REQUEST['body'] = 'body' REQUEST['email'] = 'email' REQUEST['notify'] = 1 REQUEST['encoding'] = 'Plain' REQUEST['subject'] = 'test subject' REQUEST['summary'] = 'summary' REQUEST['dept'] = 'dept' r = str(self.Site.addPosting(REQUEST=REQUEST,RESPONSE=RESPONSE)) Posting = self._getPosting(title="testSquishSiteAddPosting") # check return value index(r,'Your article has been posted') assert Posting.title =='testSquishSiteAddPosting' assert Posting.author =='tester' assert Posting.body ==['body'] assert Posting.email =='email' assert Posting.notify ==1 assert Posting.encoding =='Plain' assert Posting.subject =='test subject' assert Posting.summary ==['summary'] assert Posting.dept =='dept' def testAddArticleIncomplete(self): "Check the SquishSite.addPosting handles incomplete postings correctly" self.Site.REQUEST.HTTP_REFERER='where I came from' result = self._addPosting(title = 'testSquishSiteAddPostingIncomplete') assert search('