def verify_expectations(self): for attr, (count, arg_matchers, kw_matchers) in self.expectations.iteritems(): count.verify(attr) assert_that(attr, is_in(self.received), "expected to receive %s but was not recorded" % (attr)) #TODO: error message might help! for (args, kwargs) in self.received[attr]: map(lambda (arg, matcher): assert_that(arg, matcher), zip(args, arg_matchers)) #TODO: loop around the expected matchers not the actual inputs? for name, value in kwargs.iteritems(): assert_that(name, is_in(kw_matchers), "expected named argument %s but was not recorded" % (name)) assert_that(value, kw_matchers[name])
def ItShouldContainAFormWithTheNewBlogPostUrlAsItsAction(self): newBlogPostPage = self.__getNewBlogPostPage() assert_that(newBlogPostPage, is_(containining_dom_object("form[action='%s'] " %(reverse("newBlog") ) ) ) )
def verify(self, name): assert_that(self.fulfilled, is_(True), "expected %s to be called %s %s times, but was %s" % (name, self.checktype(), self.expected_ccount, self.ccount))
def ItShouldNotRaiseAnExceptionWhenLinkIsFound(self): assert_that( "<a href='/potato'></a>", is_(containingALinkTowards("/potato")))
def ItShouldRaiseAnExceptionWhenLinkIsNotFound(self): try: assert_that( "<a href='/rotato'></a>", is_(containingALinkTowards("/potato"))) raise Exception except (AssertionError, ), e: pass
def ItShouldContainTheSubmitBlogPostButton(self): assert_that(self.__getNewBlogPostTemplateRendered(), is_(containining_dom_object("#id_create_blog_post")))
def ItShouldContainTheContentInputField(self): assert_that(self.__getNewBlogPostTemplateRendered(), is_(containining_dom_object("#id_content")))
def ItShouldContainTheTitleInputField(self): print self.__getNewBlogPostTemplateRendered() assert_that(self.__getNewBlogPostTemplateRendered(), containining_dom_object("#id_title"))