def get_next_task_view(self): self.client.login(username="******", password="******") ## get the next task self.task_expectation.check(self) ## tweak the database to put a response and a review in response = Response(task=self.t, user=self.user, start_time=timezone.now()) response.full_clean() response.save() review = Review(response=response, comment="I have reviewed this task.") review.full_clean() review.save() ## check to see if next_task now redirects to review ## if we actually execute the view code, we will get an error, ## because the task associated with the review has no result; ## therefore the code below is a bit hackish review_target = WebTarget("GET", main.views.base.next_task, statuses=(301, 302)) def redirects_to_review(input_context, output_context): return "/review/next/" in output_context["__redirected_to__"] review_expectation = ViewExpectation( Conditions.post(redirects_to_review), review_target) review_expectation.check(self) ## tweak the database to complete the review review.complete = True review.full_clean() review.save() ## try getting the next task again self.task_expectation.check(self)
def get_next_task_view(self): self.client.login(username="******", password="******") ## get the next task self.task_expectation.check(self) ## tweak the database to put a response and a review in response = Response(task=self.t, user=self.user, start_time=datetime.datetime.now()) response.full_clean() response.save() review = Review(response=response, comment="I have reviewed this task.") review.full_clean() review.save() ## check to see if next_task now redirects to review ## if we actually execute the view code, we will get an error, ## because the task associated with the review has no result; ## therefore the code below is a bit hackish review_target = WebTarget("GET", main.views.base.next_task, statuses=(301, 302)) def redirects_to_review(input_context, output_context): return "/review/next/" in output_context["__redirected_to__"] review_expectation = ViewExpectation(Conditions.post(redirects_to_review), review_target) review_expectation.check(self) ## tweak the database to complete the review review.complete = True review.full_clean() review.save() ## try getting the next task again self.task_expectation.check(self)