def test_wrong_attitude_returns_error(self): request = construct_dummy_request( matchdict={ 'slug': self.issue_cat_or_dog.slug, 'statement_id': self.statement_cat_or_dog.uid, 'attitude': 'not-an-attitude' }) response = apiviews.discussion_justify_statement(request) self.assertIsInstance(response, httpexceptions.HTTPError)
def test_wrong_statement_returns_error(self): request = construct_dummy_request( match_dict={ 'slug': self.issue_cat_or_dog.slug, 'statement_id': -1, 'attitude': Attitudes.AGREE.value }) response = apiviews.discussion_justify_statement(request) self.assertIsInstance(response, httpexceptions.HTTPError)
def test_successful_discussion_justify_statement(self): request = construct_dummy_request( matchdict={ 'slug': self.issue_cat_or_dog.slug, 'statement_id': self.statement_cat_or_dog.uid, 'attitude': Attitudes.AGREE.value }) response = apiviews.discussion_justify_statement(request) self.assertTrue(response) self.assertIsInstance(response, dict) self.assertIn('statement', request.validated) self.assertIn('issue', request.validated) self.assertIn('user', request.validated) self.assertIn('attitude', request.validated)